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, 23 Jul 2004 00:29:00 GMT
taylor      2004/07/22 17:29:00

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager
                        ApplicationServerPAM.java
               jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager
                        DeploymentRegistration.java
               commons/src/java/org/apache/jetspeed/container
                        JetspeedContainerServlet.java
  Log:
  Optional Generic Deployment feature
  Added support to retry deployments, and over a time period and eventually give up
  
  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.5       +35 -37    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/ApplicationServerPAM.java
  
  Index: ApplicationServerPAM.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/ApplicationServerPAM.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ApplicationServerPAM.java	22 Jul 2004 23:38:39 -0000	1.4
  +++ ApplicationServerPAM.java	23 Jul 2004 00:29:00 -0000	1.5
  @@ -293,17 +293,16 @@
           }
       }
       
  -    public void registerPortletApplication(FileSystemHelper fileSystem, 
  -                                           String portletApplicationName)
  +    public boolean registerPortletApplication(FileSystemHelper fileSystem, 
  +                                              String portletApplicationName)
       throws RegistryException
       {
           MutablePortletApplication pa = 
               registry.getPortletApplication(portletApplicationName);
           if (pa != null)
           {
  -            // get the deployment date
  -            System.out.println("PA " + portletApplicationName + " is already deployed.");
  -            return;
  +            // TODO: get the deployment date
  +            return false;
           }
           
           PortletApplicationWar paWar = null;
  @@ -324,39 +323,38 @@
           
           try
           {
  -        app = paWar.createPortletApp();
  -        
  -        if (app == null)
  -        {
  -        String msg = "Error loading portlet.xml: ";
  -        log.error(msg);
  -        throw new RegistryException(msg);
  -        }
  -        
  -        
  -        app.setApplicationType(MutablePortletApplication.WEBAPP);
  -        
  -        // load the web.xml
  -        log.info("Loading web.xml into memory....");
  -        MutableWebApplication webapp = paWar.createWebApp();
  -        paWar.validate();
  -        app.setWebApplicationDefinition(webapp);
  -        
  -        // save it to the registry
  -        log.info("Saving the portlet.xml in the registry...");
  -        store.getTransaction().begin();
  -        registry.registerPortletApplication(app);
  -        log.info("Committing registry changes...");
  -        store.getTransaction().commit();
  +            app = paWar.createPortletApp();
  +            
  +            if (app == null)
  +            {
  +                String msg = "Error loading portlet.xml: ";
  +                log.error(msg);
  +                throw new RegistryException(msg);
  +            }
  +                        
  +            app.setApplicationType(MutablePortletApplication.WEBAPP);
  +        
  +            // load the web.xml
  +            log.info("Loading web.xml into memory...." + portletApplicationName);
  +            MutableWebApplication webapp = paWar.createWebApp();
  +            paWar.validate();
  +            app.setWebApplicationDefinition(webapp);
  +            
  +            // save it to the registry
  +            log.info("Saving the portlet.xml in the registry..." + portletApplicationName);
  +            store.getTransaction().begin();
  +            registry.registerPortletApplication(app);
  +            log.info("Committing registry changes..."  + portletApplicationName);
  +            store.getTransaction().commit();
           }
           catch (Exception e)
           {
  -        String msg = "Unable to register portlet application, " + paName + ", through the
portlet registry: "
  -        + e.toString();
  -        log.error(msg, e);
  -        store.getTransaction().rollback();
  -        throw new RegistryException(msg, e);
  -    }
  -
  -}    
  +            String msg = "Unable to register portlet application, " + paName + ", through
the portlet registry: "
  +            + e.toString();
  +            log.error(msg, e);
  +            store.getTransaction().rollback();
  +            throw new RegistryException(msg, e);
  +        }
  +        return true;
  +    }    
   }
  
  
  
  1.2       +2 -2      jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/DeploymentRegistration.java
  
  Index: DeploymentRegistration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/tools/pamanager/DeploymentRegistration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentRegistration.java	22 Jul 2004 23:38:39 -0000	1.1
  +++ DeploymentRegistration.java	23 Jul 2004 00:29:00 -0000	1.2
  @@ -27,7 +27,7 @@
    */
   public interface DeploymentRegistration
   {
  -    void registerPortletApplication(
  +    boolean registerPortletApplication(
               FileSystemHelper fileSystem, 
               String portletApplicationName)
           throws RegistryException;    
  
  
  
  1.11      +67 -32    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JetspeedContainerServlet.java	22 Jul 2004 23:38:39 -0000	1.10
  +++ JetspeedContainerServlet.java	23 Jul 2004 00:29:00 -0000	1.11
  @@ -87,7 +87,7 @@
                   String registerAtInit = config.getInitParameter("registerAtInit");
                   if (null != registerAtInit)
                   {
  -                    System.out.println("*** Registering at INIT: " + context.getServletContextName());
  +                    log.info("Considering PA for registration during servlet init: " +
context.getServletContextName());
                       String portletApplication = config.getInitParameter("portletApplication");
                       if (null == portletApplication)
                       {
  @@ -99,7 +99,7 @@
                   }
                   else
                   {
  -                    System.out.println("*** Not Registering at INIT: " + context.getServletContextName());
  +                    log.info("Will not register this PA during servlet init: " + context.getServletContextName());
                   }
                   
               }
  @@ -118,42 +118,77 @@
   
       
       private void registerPortletApplication(ServletContext context, String portletApplicationName)
  +    throws ServletException
       {
  -        System.out.println("*** Registering PA: " + portletApplicationName);
  +        final int INITIAL_WAIT = 5 * 1000; // initially wait 5 seconds
  +        final int LONGER_WAIT =  300 * 1000; // longer wait stage 5 minutes
  +        final int SLOW_DOWN_THRESHOLD = 20; // after 20 tries and 1 minute, fall back to
longer wait
  +        int tries = 0;
  +        
           //InputStream portletStream = null;
           //InputStream servletStream = null;
           
  -        try
  +        //portletStream = context.getResourceAsStream("WEB-INF/portlet.xml");
  +        //servletStream = context.getResourceAsStream("WEB-INF/web.xml");
  +        
  +        boolean registrarNotAvailable = true;
  +        
  +        while (registrarNotAvailable)
           {
  -            //portletStream = context.getResourceAsStream("WEB-INF/portlet.xml");
  -            //servletStream = context.getResourceAsStream("WEB-INF/web.xml");
  -                                   
  -            PortletServices services = JetspeedPortletServices.getSingleton();        
                
  -            DeploymentRegistration registrar =
  -                (DeploymentRegistration)services.getService("PAM"); 
  -            
  -            if (registrar != null)
  -            {
  -                System.out.println("registrar found: " + registrar);
  -                FileSystemHelper webapp = new DirectoryHelper(new File(context.getRealPath("/")));
  -                registrar.registerPortletApplication(webapp, portletApplicationName);
  -                System.out.println("done registering " + registrar);                
  +            try
  +            {
  +                PortletServices services = JetspeedPortletServices.getSingleton();
  +                if (services != null)
  +                {
  +                    DeploymentRegistration registrar =
  +                        (DeploymentRegistration)services.getService("PAM"); 
  +                
  +                    if (registrar != null)
  +                    {
  +                        FileSystemHelper webapp = new DirectoryHelper(new File(context.getRealPath("/")));
  +                        if (registrar.registerPortletApplication(webapp, portletApplicationName))
  +                        {
  +                            log.info("Portlet Application Registered at Servlet Init: "
+ portletApplicationName);
  +                        }
  +                        else
  +                        {
  +                            log.info("Portlet Application did not change. Not Registered
at Servlet Init: " + portletApplicationName);
  +                        }
  +                        break;
  +                    }
  +                }                
               }
  -            else
  +            catch (Exception e)
               {
  -                System.out.println("registry not yet available...");
  -            }            
  -        }
  -        catch (Exception e)
  -        {
  -            e.printStackTrace();
  -        }
  -        finally
  -        {
  -            //closeStream(portletStream);
  -            //closeStream(servletStream);
  -        }
  -        
  +                if (tries < 3)
  +                {
  +                    e.printStackTrace();
  +                }
  +                log.error("Failed to register PA: " + portletApplicationName);
  +            }
  +            finally
  +            {
  +                //closeStream(portletStream);
  +                //closeStream(servletStream);
  +            }    
  +            log.error("*** Jetspeed Runtime Registration: Portlet Services not available
for registering PA: " + portletApplicationName);
  +            try
  +            {
  +                tries++;
  +                if (tries > SLOW_DOWN_THRESHOLD)
  +                {
  +                    Thread.sleep(LONGER_WAIT);
  +                }
  +                else
  +                {
  +                    Thread.sleep(INITIAL_WAIT);
  +                }
  +            }
  +            catch (InterruptedException e)
  +            {
  +                throw new ServletException("Servlet init interrupted for " + portletApplicationName);
  +            }
  +        }        
       }
   
       /*
  
  
  

---------------------------------------------------------------------
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