portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container JetspeedContainerServlet.java
Date Fri, 20 Aug 2004 05:06:41 GMT
taylor      2004/08/19 22:06:41

  Modified:    commons/src/java/org/apache/jetspeed/container
                        JetspeedContainerServlet.java
  Log:
  add logging back in
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.17      +45 -42    jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
  
  Index: JetspeedContainerServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JetspeedContainerServlet.java	19 Aug 2004 17:29:22 -0000	1.16
  +++ JetspeedContainerServlet.java	20 Aug 2004 05:06:41 -0000	1.17
  @@ -52,7 +52,7 @@
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
    * @version $Id$
    */
  -public class JetspeedContainerServlet extends HttpServlet implements ServletContainerConstants
  +public class JetspeedContainerServlet extends HttpServlet 
   {
    //   private final static Log log = LogFactory.getLog(JetspeedContainerServlet.class);
      // private final static Log console = LogFactory.getLog(CONSOLE_LOGGER);
  @@ -68,9 +68,10 @@
       // -------------------------------------------------------------------
       // I N I T I A L I Z A T I O N
       // -------------------------------------------------------------------
  -    private static final String INIT_START_MSG = "Jetspeed Container Starting Initialization...";
  -    private static final String INIT_DONE_MSG = "Jetspeed Container Initialization complete,
Ready to service requests.";
  -
  +    private static final String JCS = "JetspeedContainerServlet: ";
  +    private static final String INIT_START_MSG = JCS + "starting initialization of context
";
  +    private static final String INIT_DONE_MSG = JCS + "Initialization complete for context
";
  +    
       /**
        * Intialize Servlet.
        */
  @@ -78,43 +79,48 @@
       {
           synchronized (this.getClass())
           {            
  -            // log.info(INIT_START_MSG + " " + config.getServletContext().getRealPath("/"));
               super.init(config);
  -
  +            ServletContext context = getServletContext();
  +            String name = context.getServletContextName();
  +            if (name == null || name.length() == 0)
  +            {
  +                name = context.getRealPath("/");
  +                if (name == null)
  +                {
  +                    name = "Jetspeed";
  +                }
  +            }
  +            context.log(INIT_START_MSG + name);            
  +            System.out.println(INIT_START_MSG + name);            
   
               try
               {                
  -                ServletContext context = config.getServletContext();
  -                webappRoot = config.getServletContext().getRealPath("/");             
  
                   String registerAtInit = config.getInitParameter("registerAtInit");
                   if (null != registerAtInit)
                   {
  -                    // log.info("Considering PA for registration during servlet init: "
+ context.getServletContextName());
  +                    context.log(JCS + "Considering PA for registration during servlet init:
" + name);
                       String portletApplication = config.getInitParameter("portletApplication");
                       if (null == portletApplication)
                       {
  -                        throw new ServletException("Portlet Application Name not supplied
in Init Parameters.");
  +                        throw new ServletException(JCS + "Portlet Application Name not
supplied in Init Parameters.");
                       }
                       
                       registerPortletApplication(context, portletApplication);
                       
  -                }
  -                else
  -                {
  -                    // log.info("Will not register this PA during servlet init: " + context.getServletContextName());
  -                }
  -                
  +                }                
               }
               catch (Exception e)
               {
                   initFailure = e;
  -                // log.fatal("Jetspeed: init() failed: ", e);
  -                // System.err.println(ExceptionUtils.getStackTrace(e));
  -                throw new ServletException("Jetspeed: init() failed", e);
  +                String message = JCS + "Initialization of servlet " + name + " failed.";
  +                context.log(message, e);
  +                System.err.println(message);
  +                e.printStackTrace(System.err);                
  +                throw new ServletException(message, e);
               }
   
  -            // console.info(INIT_DONE_MSG);
  -            // log.info(INIT_DONE_MSG + " " + config.getServletContext().getRealPath("/"));
  +            context.log(INIT_DONE_MSG + name);
  +            System.out.println(INIT_DONE_MSG + name);
           }
       }
   
  @@ -122,22 +128,23 @@
       throws ServletException
       {
   
  -        // log.info("Attempting to register portlet application: name=" + portletApplicationName);
  -        if (attemptRegistration(context, portletApplicationName)) {
  -            // log.info("Registered portlet application: name=" + portletApplicationName);
  +        context.log(JCS + "Attempting to register portlet application: name=" + portletApplicationName);
  +        if (attemptRegistration(context, portletApplicationName)) 
  +        {
  +            context.log(JCS + "Registered portlet application: name=" + portletApplicationName);
           }
   
  -        // log.info("Could not registered protlet application; starting back ground thread
to register when jetspeed comes online: name=" + portletApplicationName);
  +        context.log(JCS + "Could not registered portlet application; starting back ground
thread to register when jetspeed comes online: name=" + portletApplicationName);
           final Timer timer = new Timer(true);
           timer.schedule(
                   new TimerTask() {
                       public void run() {
  -                        // log.info("Attempting to register portlet application: name="
+ portletApplicationName);
  +                        context.log(JCS + "Attempting to register portlet application:
name=" + portletApplicationName);
                           if (attemptRegistration(context, portletApplicationName)) {
  -                            // log.info("Registered portlet application: name=" + portletApplicationName);
  +                            context.log(JCS + "Registered portlet application: name=" +
portletApplicationName);
                               timer.cancel();
                           } else {
  -                            // log.info("Could not register portlet application; will try
again later: name=" + portletApplicationName);
  +                            context.log(JCS + "Could not register portlet application;
will try again later: name=" + portletApplicationName);
                           }
                       }
                   },
  @@ -160,11 +167,11 @@
                       FileSystemHelper webapp = new DirectoryHelper(new File(context.getRealPath("/")));
                       if (registrar.registerPortletApplication(webapp, portletApplicationName))
                       {
  -                        // log.info("Portlet Application Registered at Servlet Init: "
+ portletApplicationName);
  +                        context.log(JCS + "Portlet Application Registered at Servlet Init:
" + portletApplicationName);
                       }
                       else
                       {
  -                        // log.info("Portlet Application did not change. Not Registered
at Servlet Init: " + portletApplicationName);
  +                        context.log(JCS + "Portlet Application did not change. Not Registered
at Servlet Init: " + portletApplicationName);
                       }
                       return true;
                   }
  @@ -172,7 +179,7 @@
           }
           catch (Exception e)
           {
  -            // log.error("Failed to register PA: " + portletApplicationName);
  +            context.log(JCS + "Failed to register PA: " + portletApplicationName);
           }
           return false;
       }    
  @@ -208,14 +215,10 @@
                   return;
               }
               
  -            PortletDefinition portletDefinition = JetspeedPortletFactoryProxy.getCurrentPortletDefinition();
  -System.out.println("Got thread local PD = " + portletDefinition);
  -                        
  +            PortletDefinition portletDefinition = JetspeedPortletFactoryProxy.getCurrentPortletDefinition();
                       
               Portlet portlet = JetspeedPortletFactoryProxy.getPortlet(this.getServletConfig(),
portletDefinition);
               portletName = portletDefinition.getName();
   
  -            // log.debug("Rendering: Portlet Class = " + portletDefinition.getClassName());
  -
               if (method == ContainerConstants.METHOD_ACTION)
               {
                   ActionRequest actionRequest = (ActionRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
  @@ -237,8 +240,8 @@
           }
           catch (Throwable t)
           {
  -
  -            // log.error("Error rendering portlet \""+portletName+"\": " + t.toString(),
t);
  +            ServletContext context = getServletContext();
  +            context.log(JCS + "Error rendering portlet \"" + portletName + "\": " + t.toString(),
t);
               try
               {
                   String errorTemplate = getInitParameter("portal.error.page");
  @@ -256,11 +259,11 @@
               }
               catch (Exception e)
               {
  +                context.log(JCS + "Error rendering JetspeedContainerServlet error page:
" + e.toString(), e);                
                   PrintWriter directError = new PrintWriter(response.getWriter());
  -                directError.write("Error occured process includeTemplate(): " + t.toString()
+ "\n\n");
  +                directError.write("Error Rendering portlet: " + portletName + ": " + t.toString()
+ "\n\n");
                   t.printStackTrace(directError);
                   directError.close();
  -                // log.error("Error rendering JetspeedContainerServlet error page: " +
e.toString(), e);
               }
               finally
               {
  @@ -293,7 +296,7 @@
        */
       public final void destroy()
       {
  -        // log.info("Done shutting down!");
  +        getServletContext().log(JCS + "Shutting down portlet app context: " + getServletContext().getServletContextName());
       }
   
       public static final String LOCAL_CLASSES = "/WEB-INF/classes/";
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message