[jboss-cvs] jboss-seam/src/main/org/jboss/seam/contexts ...

Peter Muir peter at bleepbleep.org.uk
Tue Apr 24 05:30:00 EDT 2007


  User: pmuir   
  Date: 07/04/24 05:30:00

  Modified:    src/main/org/jboss/seam/contexts  Lifecycle.java
  Log:
  Tidy up and move postInitialization event to after startup of application scoped components
  
  Revision  Changes    Path
  1.86      +26 -29    jboss-seam/src/main/org/jboss/seam/contexts/Lifecycle.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Lifecycle.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/contexts/Lifecycle.java,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -b -r1.85 -r1.86
  --- Lifecycle.java	8 Mar 2007 17:16:16 -0000	1.85
  +++ Lifecycle.java	24 Apr 2007 09:30:00 -0000	1.86
  @@ -19,6 +19,7 @@
   import org.jboss.seam.Seam;
   import org.jboss.seam.core.BusinessProcess;
   import org.jboss.seam.core.ConversationEntries;
  +import org.jboss.seam.core.Events;
   import org.jboss.seam.core.Init;
   import org.jboss.seam.core.Manager;
   import org.jboss.seam.core.Mutable;
  @@ -28,7 +29,7 @@
   /**
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.85 $
  + * @version $Revision: 1.86 $
    */
   public class Lifecycle
   {
  @@ -132,7 +133,22 @@
   
      public static void endInitialization()
      {
  -	   //instantiate all application-scoped @Startup components
  +      startup(ScopeType.APPLICATION);
  +      
  +      Events.instance().raiseEvent("org.jboss.seam.postInitialization");
  +      
  +      // Clean up contexts used during initialization
  +      Contexts.destroy( Contexts.getConversationContext() );
  +      Contexts.conversationContext.set(null);
  +      Contexts.destroy( Contexts.getEventContext() );
  +      Contexts.eventContext.set(null);
  +      Contexts.sessionContext.set(null);
  +      Contexts.applicationContext.set(null);
  +   }
  +   
  +   private static void startup(ScopeType scopeType)
  +   {
  +      // instantiate all components in the given scope
         Context context = Contexts.getApplicationContext();
         for ( String name: context.getNames() )
         {
  @@ -140,19 +156,12 @@
       	   if ( object!=null && (object instanceof Component) )
       	   {
   	         Component component = (Component) object;
  -	         if ( component.isStartup() && component.getScope()==ScopeType.APPLICATION )
  +            if ( component.isStartup() && component.getScope()==scopeType )
   	         {
                  startup(component);
   	         }
       	   }
         }
  -
  -      Contexts.destroy( Contexts.getConversationContext() );
  -      Contexts.conversationContext.set(null);
  -      Contexts.destroy( Contexts.getEventContext() );
  -      Contexts.eventContext.set(null);
  -      Contexts.sessionContext.set(null);
  -      Contexts.applicationContext.set(null);
      }
   
      private static void startup(Component component)
  @@ -223,19 +232,7 @@
         Context tempSessionContext = new WebSessionContext(session);
         Contexts.sessionContext.set(tempSessionContext);
   
  -      //instantiate all session-scoped @Startup components
  -      for ( String name : Contexts.getApplicationContext().getNames() )
  -      {
  -         Object object = Contexts.getApplicationContext().get(name);
  -         if ( object!=null && (object instanceof Component) ) 
  -         {
  -            Component component = (Component) object;
  -            if ( component.isStartup() && component.getScope() == ScopeType.SESSION )
  -            {
  -               startup(component);
  -            }
  -         }
  -      }
  +      startup(ScopeType.SESSION);
   
         Contexts.sessionContext.set(null);
         
  
  
  



More information about the jboss-cvs-commits mailing list