2 Replies Latest reply on Apr 6, 2009 10:36 PM by Arbi Sookazian

    any way to defer Seam initialization to first request to webapp rather than at webapp start time?

    Ian Springer Master


      Is there any way to configure Seam to defer its initialization to happen upon first request to webapp rather than at webapp start time? If not, is this a feature that could be added?

      Here's some details on why I'm looking for this. I am working on the new Admin Console for JBAS 5.1, which is based on the Embedded Jopr project. The Admin Console is a WAR that includes Seam, and will be shipped as part of JBAS 5.1. When JBAS starts up, it deploys and starts the Admin Console WAR. The WAR takes 8-10 seconds to start up, 95% of which is Seam initialization. We would like to avoid adding an additional 8-10 to the out-of-box overall JBAS startup time, which is why I'm looking for a way to put off the Seam init until the first time someone actually tries to hit the Admin Console WAR.

      See also:


        • 1. Re: any way to defer Seam initialization to first request to webapp rather than at webapp start time?
          Arbi Sookazian Master

          Your concept is similar to lazy loading in ORM frameworks like Hibernate.

          Specifically, are you referring to skipping the following in the server.log during JBoss AS Seam app deploy?

          13:19:03,018 INFO  [Initialization] Installing components...
          13:19:03,065 INFO  [Component] Component: applicationMetaData, scope: SESSION, type: STATEFUL_SESSION_BEAN, class: com.cox.bets.session.ApplicationMetaDataAction, JNDI: BETS/ApplicationMetaDataAction/local
          13:19:03,096 INFO  [Component] Component: arbiTestView, scope: CONVERSATION, type: ENTITY_BEAN, class: 
          13:19:03,643 INFO  [Initialization] done initializing Seam

          I'm not sure if the functionality you're asking for is available or not (as a config in components.xml).  I haven't heard anybody ask about this or covered in ref docs or Seam books up to 2.1.x.

          The Seam devs would know better...

          • 2. Re: any way to defer Seam initialization to first request to webapp rather than at webapp start time?
            Arbi Sookazian Master

            I'm not sure how/what calls the public init() method below, but here is the pertinent code in Seam 2.1.1.GA org.jboss.seam.init.Initialization class.  It looks like it is not configurable to lazy load the components.  Perhaps someone will prove me wrong...

            public Initialization init()
                  log.info("initializing Seam");
                  if (standardDeploymentStrategy == null)
                     throw new IllegalStateException("No deployment strategy!");
                  Contexts.getApplicationContext().set(Component.PROPERTIES, properties);
                  addComponent( new ComponentDescriptor(Init.class), Contexts.getApplicationContext());
                  Init init = (Init) Component.getInstance(Init.class, ScopeType.APPLICATION);
                  // Make the deployment strategies available in the contexts. This gives
                  // access to custom deployment handlers for processing custom annotations
                  Contexts.getEventContext().set(StandardDeploymentStrategy.NAME, standardDeploymentStrategy);
                  ComponentDescriptor desc = findDescriptor(Jbpm.class);
                  if (desc != null && desc.isInstalled())
                  // Add the war root deployment
                  warRootDeploymentStrategy = new WarRootDeploymentStrategy(
                        Thread.currentThread().getContextClassLoader(), warRoot, new File[] { warClassesDirectory, warLibDirectory, hotDeployDirectory });
                  Contexts.getEventContext().set(WarRootDeploymentStrategy.NAME, warRootDeploymentStrategy);
                  hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader(), isHotDeployEnabled(init));
                  Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
                  init.setHotDeployPaths( hotDeploymentStrategy.getHotDeploymentPaths() );
                  if (hotDeploymentStrategy.available())
                  for (String globalImport: globalImports)
                  log.info("done initializing Seam");
                  return this;