[webbeans-commits] Webbeans SVN: r1715 - in ri/trunk: webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap and 3 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Feb 26 06:22:53 EST 2009


Author: pete.muir at jboss.org
Date: 2009-02-26 06:22:53 -0500 (Thu, 26 Feb 2009)
New Revision: 1715

Removed:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle2.java
Modified:
   ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java
Log:
New bootstrap for WB

Modified: ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java
===================================================================
--- ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -26,7 +26,6 @@
       this.lifecycle = new MockLifecycle();
       try
       {
-         lifecycle.initialize();  
          ManagerImpl manager = lifecycle.getBootstrap().getManager();
          if (enabledDeploymentTypes != null)
          {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -27,6 +27,13 @@
 import org.jboss.webbeans.bean.standard.ManagerBean;
 import org.jboss.webbeans.bootstrap.api.Bootstrap;
 import org.jboss.webbeans.bootstrap.api.helpers.AbstractBootstrap;
+import org.jboss.webbeans.context.ApplicationContext;
+import org.jboss.webbeans.context.ConversationContext;
+import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.RequestContext;
+import org.jboss.webbeans.context.SessionContext;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
 import org.jboss.webbeans.conversation.ConversationImpl;
 import org.jboss.webbeans.conversation.JavaSEConversationTerminator;
 import org.jboss.webbeans.conversation.NumericConversationIdGenerator;
@@ -77,6 +84,7 @@
       this.manager = new ManagerImpl(getNamingContext(), getEjbResolver(), getResourceLoader());
       getManager().getNaming().bind(ManagerImpl.JNDI_KEY, getManager());
       CurrentManager.setRootManager(manager);
+      initializeContexts();
    }
    
    public ManagerImpl getManager()
@@ -126,6 +134,13 @@
          {
             throw new IllegalStateException("ResourceLoader not set");
          }
+         if (getApplicationContext() == null)
+         {
+            throw new IllegalStateException("No application context BeanStore set");
+         }
+         beginApplication(getApplicationContext());
+         BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
+         beginDeploy(requestBeanStore);
          // Must populate EJB cache first, as we need it to detect whether a
          // bean is an EJB!
          manager.getEjbDescriptorCache().addAll(getEjbDiscovery().discoverEjbs());
@@ -143,6 +158,7 @@
          manager.getResolver().resolveInjectionPoints();
          new BeanValidator(manager).validate();
          manager.fireEvent(manager, new DeployedLiteral());
+         endDeploy(requestBeanStore);
       }
    }
 
@@ -156,5 +172,42 @@
       Package pkg = WebBeansBootstrap.class.getPackage();
       return pkg != null ? pkg.getImplementationVersion() : null;
    }
+   
+   protected void initializeContexts()
+   {
+      manager.addContext(DependentContext.create());
+      manager.addContext(RequestContext.create());
+      manager.addContext(SessionContext.create());
+      manager.addContext(ApplicationContext.create());
+      manager.addContext(ConversationContext.create());
+   }
 
+   protected void beginApplication(BeanStore applicationBeanStore)
+   {
+      log.trace("Starting application");
+      ApplicationContext.INSTANCE.setBeanStore(applicationBeanStore);
+      ApplicationContext.INSTANCE.setActive(true);
+
+   }
+
+   protected void beginDeploy(BeanStore requestBeanStore)
+   {
+      RequestContext.INSTANCE.setBeanStore(requestBeanStore);
+      RequestContext.INSTANCE.setActive(true);
+   }
+
+   protected void endDeploy(BeanStore requestBeanStore)
+   {
+      RequestContext.INSTANCE.setBeanStore(null);
+      RequestContext.INSTANCE.setActive(false);
+   }
+
+   protected void endApplication(BeanStore applicationBeanStore)
+   {
+      log.trace("Ending application");
+      ApplicationContext.INSTANCE.destroy();
+      ApplicationContext.INSTANCE.setActive(false);
+      ApplicationContext.INSTANCE.setBeanStore(null);
+   }
+
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -54,13 +54,8 @@
       bootstrap.setEjbResolver(MOCK_EJB_RESOLVER);
       bootstrap.setResourceLoader(MOCK_RESOURCE_LOADER);
       bootstrap.setWebBeanDiscovery(webBeanDiscovery);
-   }
-   
-   @Override
-   public void initialize()
-   {
+      bootstrap.setApplicationContext(applicationBeanStore);
       bootstrap.initialize();
-      super.initialize();
    }
    
    public MockWebBeanDiscovery getWebBeanDiscovery()
@@ -75,22 +70,18 @@
    
    public void beginApplication()
    {
-      super.beginApplication("Mock", applicationBeanStore);
-      BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
-      super.beginDeploy(requestBeanStore);
       bootstrap.setEjbDiscovery(new MockEjbDiscovery(webBeanDiscovery.discoverWebBeanClasses()));
       bootstrap.boot();
-      super.endDeploy(requestBeanStore);
    }
    
-   public void resetContexts()
+   public void endApplication()
    {
       
    }
    
-   public void endApplication()
+   public void resetContexts()
    {
-      super.endApplication("Mock", applicationBeanStore);
+      
    }
    
    public void beginRequest()

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/AbstractLifecycle.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -1,8 +1,6 @@
 package org.jboss.webbeans.servlet;
 
 import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.context.ApplicationContext;
 import org.jboss.webbeans.context.ConversationContext;
 import org.jboss.webbeans.context.DependentContext;
 import org.jboss.webbeans.context.RequestContext;
@@ -36,48 +34,6 @@
 
    private static LogProvider log = Logging.getLogProvider(AbstractLifecycle.class);
 
-   protected void initialize()
-   {
-      ManagerImpl manager = CurrentManager.rootManager();
-      if (manager == null)
-      {
-         throw new IllegalStateException("Manager has not been initialized, check that Bootstrap.initialize() has run");
-      }
-      manager.addContext(DependentContext.create());
-      manager.addContext(RequestContext.create());
-      manager.addContext(SessionContext.create());
-      manager.addContext(ApplicationContext.create());
-      manager.addContext(ConversationContext.create());
-   }
-
-   protected void beginApplication(String id, BeanStore applicationBeanStore)
-   {
-      log.trace("Starting application " + id);
-      ApplicationContext.INSTANCE.setBeanStore(applicationBeanStore);
-      ApplicationContext.INSTANCE.setActive(true);
-
-   }
-
-   protected void beginDeploy(BeanStore requestBeanStore)
-   {
-      RequestContext.INSTANCE.setBeanStore(requestBeanStore);
-      RequestContext.INSTANCE.setActive(true);
-   }
-
-   protected void endDeploy(BeanStore requestBeanStore)
-   {
-      RequestContext.INSTANCE.setBeanStore(null);
-      RequestContext.INSTANCE.setActive(false);
-   }
-
-   protected void endApplication(String id, BeanStore applicationBeanStore)
-   {
-      log.trace("Ending application " + id);
-      ApplicationContext.INSTANCE.destroy();
-      ApplicationContext.INSTANCE.setActive(false);
-      ApplicationContext.INSTANCE.setBeanStore(null);
-   }
-
    protected void beginSession(String id, BeanStore sessionBeanStore)
    {
       log.trace("Starting session " + id);

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -54,12 +54,6 @@
 
    private static LogProvider log = Logging.getLogProvider(ServletLifecycle.class);
 
-   @Override
-   public void initialize()
-   {
-      // No-op, we'll do the init ourselves!
-   }
-
    /**
     * Starts the application
     * 
@@ -69,13 +63,13 @@
     */
    public void beginApplication(ServletContext servletContext)
    {
-      ServletInitialization servletInitialization = new ServletInitialization(servletContext).initialize();
+      /*ServletInitialization servletInitialization = new ServletInitialization(servletContext).initialize();
       super.initialize();
       super.beginApplication(servletContext.getServletContextName(), new ApplicationBeanStore(servletContext));
       BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
       super.beginDeploy(requestBeanStore);
       servletInitialization.start();
-      super.endDeploy(requestBeanStore);
+      super.endDeploy(requestBeanStore);*/
    }
 
    /**
@@ -83,7 +77,7 @@
     */
    public void endApplication(ServletContext servletContext)
    {
-      super.endApplication(servletContext.getServletContextName(), new ApplicationBeanStore(servletContext));
+      //super.endApplication(servletContext.getServletContextName(), new ApplicationBeanStore(servletContext));
    }
 
    /**

Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle2.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle2.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle2.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -1,135 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.webbeans.servlet;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.context.SessionContext;
-import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
-
-/**
- * Implementation of the Web Beans lifecycle that can react to servlet events.
- * 
- * This implementation does not boot the Web Beans container.
- * 
- * @author Pete Muir
- * @author Nicklas Karlsson
- */
-public class ServletLifecycle2 extends AbstractLifecycle
-{
-   
-   public static final String REQUEST_ATTRIBUTE_NAME = ServletLifecycle2.class.getName() + ".requestBeanStore";
-   
-   public static ServletLifecycle2 instance()
-   {
-      return (ServletLifecycle2) AbstractLifecycle.instance();
-   }
-   
-   static
-   {
-      AbstractLifecycle.setInstance(new ServletLifecycle2());
-   }
-
-   /**
-    * Starts the application
-    * 
-    * Runs the bootstrapper for bean discover and initialization
-    * 
-    * @param context The servlet context
-    */
-   public void beginApplication(ServletContext servletContext)
-   {
-      super.beginApplication(servletContext.getServletContextName(), new ApplicationBeanStore(servletContext));
-   }
-
-   /**
-    * Ends the application
-    */
-   public void endApplication(ServletContext servletContext)
-   {
-      super.endApplication(servletContext.getServletContextName(), new ApplicationBeanStore(servletContext));
-   }
-
-   /**
-    * Begins a session
-    * 
-    * @param session The HTTP session
-    */
-   public void beginSession(HttpSession session)
-   {
-      super.beginSession(session.getId(), null);
-   }
-
-   /**
-    * Ends a session
-    * 
-    * @param session The HTTP session
-    */
-   public void endSession(HttpSession session)
-   {
-      super.endSession(session.getId(), restoreSessionContext(session));
-   }
-   
-   /**
-    * Restore the session from the underlying session object. Also allow the 
-    * session to be injected by the Session manager
-    * 
-    * @param session
-    * @return
-    */
-   protected BeanStore restoreSessionContext(HttpSession session)
-   {
-      BeanStore sessionBeanStore = new HttpSessionBeanStore(session);
-      SessionContext.INSTANCE.setBeanStore(sessionBeanStore);
-      CurrentManager.rootManager().getInstanceByType(HttpSessionManager.class).setSession(session);
-      return sessionBeanStore;
-   }
-   
-   /**
-    * Begins a HTTP request
-    * 
-    * Sets the session into the session context
-    * 
-    * @param request The request
-    */
-   public void beginRequest(HttpServletRequest request)
-   {
-      restoreSessionContext(request.getSession());
-      BeanStore beanStore = new ConcurrentHashMapBeanStore();
-      request.setAttribute(REQUEST_ATTRIBUTE_NAME, beanStore);
-      super.beginRequest(request.getRequestURI(), beanStore);
-   }
-
-   /**
-    * Ends a HTTP request
-    * 
-    * @param request The request
-    */
-   public void endRequest(HttpServletRequest request)
-   {
-      BeanStore beanStore = (BeanStore) request.getAttribute(REQUEST_ATTRIBUTE_NAME);
-      request.removeAttribute(REQUEST_ATTRIBUTE_NAME);
-      super.endRequest(request.getRequestURI(), beanStore);
-      SessionContext.INSTANCE.setBeanStore(null);
-   }
-
-}

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -43,7 +43,6 @@
    public WebBeansListener()
    {
       lifecycle = ServletLifecycle.instance();
-      lifecycle.initialize();
    }
    
    /**

Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java	2009-02-26 11:19:38 UTC (rev 1714)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java	2009-02-26 11:22:53 UTC (rev 1715)
@@ -72,7 +72,6 @@
    public void before() throws Exception
    {
       lifecycle = new MockLifecycle();
-      lifecycle.initialize();
       this.discovery = lifecycle.getWebBeanDiscovery();
       this.manager = lifecycle.getBootstrap().getManager();
       lifecycle.beginApplication();




More information about the weld-commits mailing list