You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by dj...@apache.org on 2011/01/08 10:20:30 UTC

svn commit: r1056673 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-el10/src/main/java/org/apache/webbeans/el10/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/j...

Author: djencks
Date: Sat Jan  8 09:20:29 2011
New Revision: 1056673

URL: http://svn.apache.org/viewvc?rev=1056673&view=rev
Log:
OWB-503.  Fix a lot of problems from making ContextFactory methods non-static.  Remove circular loop between WebBeansContext and SingletonService; make SingletonService only manage WebBeansContexts

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-el10/src/main/java/org/apache/webbeans/el10/EL10Resolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/plugin/OpenWebBeansJsfPlugin.java
    openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/WebBeansPhaseListener.java
    openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/plugin/OpenWebBeansJsfPlugin.java
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
    openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/SingletonService.java
    openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/SessionContextManager.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/test/EnterpriseTestLifeCycle.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java Sat Jan  8 09:20:29 2011
@@ -63,6 +63,7 @@ import org.apache.webbeans.intercept.Int
 import org.apache.webbeans.intercept.InterceptorUtil;
 import org.apache.webbeans.intercept.InvocationContextImpl;
 import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.util.SecurityUtil;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -161,10 +162,10 @@ public class OpenWebBeansEjbInterceptor 
         { 
             logger.debug("Intercepting EJB method {0} ", ejbContext.getMethod());
         }
-        
+
         try
         {
-            if (WebBeansContext.getInstance().getOpenWebBeansConfiguration().isUseEJBInterceptorActivation()) //default is true
+            if (webBeansContext.getOpenWebBeansConfiguration().isUseEJBInterceptorActivation()) //default is true
             {
                 int result = activateContexts(RequestScoped.class);
                 //Context activities
@@ -197,7 +198,7 @@ public class OpenWebBeansEjbInterceptor 
         }
         finally
         {
-            if (WebBeansContext.getInstance().getOpenWebBeansConfiguration().isUseEJBInterceptorActivation())
+            if (webBeansContext.getOpenWebBeansConfiguration().isUseEJBInterceptorActivation())
             {
                 if(!requestAlreadyActive)
                 {
@@ -352,17 +353,18 @@ public class OpenWebBeansEjbInterceptor 
     {
         ContextsService service = webBeansContext.getService(ContextsService.class);
         Context ctx = service.getCurrentContext(scopeType);
-        
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
         if(scopeType == RequestScoped.class)
         {
             if(ctx != null && !ctx.isActive())
             {
-                ContextFactory.activateContext(scopeType);
+                contextFactory.activateContext(scopeType);
                 return 0;
             }
             else if(ctx == null)
             {
-                ContextFactory.initRequestContext(null);
+                contextFactory.initRequestContext(null);
                 return 1;
             }
             
@@ -371,12 +373,12 @@ public class OpenWebBeansEjbInterceptor 
         ctx = service.getCurrentContext(scopeType);
         if(ctx != null && !ctx.isActive())
         {
-            ContextFactory.activateContext(scopeType);
+            contextFactory.activateContext(scopeType);
             return 0;
         }
         else if(ctx == null)
         {
-            ContextFactory.initApplicationContext(null);
+            contextFactory.initApplicationContext(null);
             return 1;
 
         }     
@@ -391,26 +393,27 @@ public class OpenWebBeansEjbInterceptor 
      */
     private void deActivateContexts(boolean destroy, Class<? extends Annotation> scopeType)
     {
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
         if(scopeType == ApplicationScoped.class)
         {
             if(destroy)
             {
-                ContextFactory.destroyApplicationContext(null);
+                contextFactory.destroyApplicationContext(null);
             }
             else
             {
-                ContextFactory.deActivateContext(ApplicationScoped.class);
+                contextFactory.deActivateContext(ApplicationScoped.class);
             }            
         }
         else
         {
             if(destroy)
             {
-                ContextFactory.destroyRequestContext(null);
+                contextFactory.destroyRequestContext(null);
             }
             else
             {
-                ContextFactory.deActivateContext(RequestScoped.class);
+                contextFactory.deActivateContext(RequestScoped.class);
             }            
         }                
     }
@@ -498,9 +501,10 @@ public class OpenWebBeansEjbInterceptor 
             Class<?> proxyClass = WebBeansContext.getInstance().getJavassistProxyFactory().getInterceptorProxyClasses().get(injectionTarget);
             if (proxyClass == null)
             {
-                ProxyFactory delegateFactory = WebBeansContext.getInstance().getJavassistProxyFactory().createProxyFactory(injectionTarget);
-                proxyClass = WebBeansContext.getInstance().getJavassistProxyFactory().getProxyClass(delegateFactory);
-                WebBeansContext.getInstance().getJavassistProxyFactory().getInterceptorProxyClasses().put(injectionTarget, proxyClass);
+                JavassistProxyFactory proxyFactory = webBeansContext.getJavassistProxyFactory();
+                ProxyFactory delegateFactory = proxyFactory.createProxyFactory(injectionTarget);
+                proxyClass = proxyFactory.getProxyClass(delegateFactory);
+                proxyFactory.getInterceptorProxyClasses().put(injectionTarget, proxyClass);
             }
             Object delegate = proxyClass.newInstance();
             delegateHandler = new DelegateHandler(this.contextual, ejbContext);

Modified: openwebbeans/trunk/webbeans-el10/src/main/java/org/apache/webbeans/el10/EL10Resolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el10/src/main/java/org/apache/webbeans/el10/EL10Resolver.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-el10/src/main/java/org/apache/webbeans/el10/EL10Resolver.java (original)
+++ openwebbeans/trunk/webbeans-el10/src/main/java/org/apache/webbeans/el10/EL10Resolver.java Sat Jan  8 09:20:29 2011
@@ -31,10 +31,8 @@ import javax.enterprise.context.Dependen
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
-import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.el.ELContextStore;
-import org.apache.webbeans.spi.plugins.AbstractOwbJsfPlugin;
 
 public class EL10Resolver extends ELResolver
 {
@@ -61,27 +59,9 @@ public class EL10Resolver extends ELReso
     }
 
     @Override
-    @SuppressWarnings({"unchecked","deprecation"})
+    @SuppressWarnings("unchecked")
     public Object getValue(ELContext context, Object obj, Object property) throws NullPointerException, PropertyNotFoundException, ELException
     {
-        //Check that application is OWB enabled
-        //For JSF applications that are not
-        //OWB enabled, no need to go with this resolver....
-        AbstractOwbJsfPlugin jsfPlugin = WebBeansContext.getInstance().getPluginLoader().getJsfPlugin();
-        
-        //No JSF plugin, sure that not OWB  
-        if(jsfPlugin == null)
-        {
-            return null;
-        }        
-        else
-        {
-            if(!jsfPlugin.isOwbApplication())
-            {
-                return null;
-            }
-        }
-        
         //Bean instance
         Object contextualInstance = null;
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java Sat Jan  8 09:20:29 2011
@@ -109,7 +109,7 @@ public class WebBeansContext
     @Deprecated
     public static WebBeansContext getInstance()
     {
-        WebBeansContext webBeansContext = (WebBeansContext) WebBeansFinder.getSingletonInstance(WebBeansContext.class.getName());
+        WebBeansContext webBeansContext = WebBeansFinder.getSingletonInstance();
 
         return webBeansContext;
     }
@@ -155,7 +155,7 @@ public class WebBeansContext
 //            }
             return null;
         }
-        return serviceInterface.cast(WebBeansFinder.getSingletonInstance(implName));
+        return serviceInterface.cast(get(implName));
     }
 
     public ContextFactory getContextFactory()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansFinder.java Sat Jan  8 09:20:29 2011
@@ -34,7 +34,7 @@ public final class WebBeansFinder
 {   
     //How you use singleton provider ,
     //As a default we use ClassLoader --> Object
-    private static SingletonService singletonService = new DefaultSingletonService();
+    private static SingletonService<WebBeansContext> singletonService = new DefaultSingletonService();
 
     /** safety mechanism to allow setting a special SingletonService only once */
     private static boolean customSingletonServiceUsed = false;
@@ -47,42 +47,20 @@ public final class WebBeansFinder
         //No action
     }
     
-    public static Object getSingletonInstance(String singletonName)
+    public static WebBeansContext getSingletonInstance()
     {
-        return getSingletonInstance(singletonName, WebBeansUtil.getCurrentClassLoader());
+        return singletonService.get(WebBeansUtil.getCurrentClassLoader());
     }
-    
-    public static Object getSingletonInstance(String singletonName, Object key)
-    {
-        return singletonService.get(key, singletonName);
-    }
-    
-    
-    public static Object getExistingSingletonInstance(String singletonName, Object key)
-    {
-        return singletonService.getExist(key, singletonName);
-    }
-    
+
     public static void clearInstances(Object key)
     {
         singletonService.clear(key);
     }
 
-    /**
-     * TODO Delete - only used one place
-     * @param singletonInstance
-     * @return
-     */
-    public static Object getSingletonClassLoader(Object singletonInstance)
-    {
-        return singletonService.getKey(singletonInstance);
-    }
-    
-    // Thirdt pary frameworks can set singleton instance
+    // Third pary frameworks can set singleton instance
     // For example, OpenEJB could provide its own provider
-    // Based on deployment
-    // this must not get set
-    public static void setSingletonService(SingletonService singletonSvc)
+    // This can be called at most once.
+    public static void setSingletonService(SingletonService<WebBeansContext> singletonSvc)
     {
         if (customSingletonServiceUsed && !singletonService.equals(singletonSvc))
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/DefaultSingletonService.java Sat Jan  8 09:20:29 2011
@@ -26,13 +26,12 @@ import java.util.WeakHashMap;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.spi.SingletonService;
 import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.WebBeansUtil;
 
-public class DefaultSingletonService implements SingletonService 
+public class DefaultSingletonService implements SingletonService<WebBeansContext>
 {
     /**
      * Keys --> ClassLoaders
-     * Values --> Maps of singleton class name with object
+     * Values --> WebBeansContext
      */
     private final Map<ClassLoader, WebBeansContext> singletonMap = new WeakHashMap<ClassLoader, WebBeansContext>();
     
@@ -40,64 +39,31 @@ public class DefaultSingletonService imp
 
  
     /**
-     * Gets signelton instance.
-     * @param singletonName singleton class name
-     * @return singleton instance
-     */
-    public  Object getSingletonInstance(String singletonName)
-    {
-       return getSingletonInstance(singletonName, WebBeansUtil.getCurrentClassLoader());
-    }
-    
-    /**
      * Gets singleton instance for deployment.
-     * @param singletonName singleton class name
-     * @param classLoader classloader of the deployment
      * @return signelton instance for this deployment
      */
-    public Object getSingletonInstance(String singletonName, ClassLoader classLoader)
+    public WebBeansContext get(Object key)
     {
-        Object object = null;
-
+        assertClassLoaderKey(key);
+        ClassLoader classLoader = (ClassLoader) key;
         synchronized (singletonMap)
         {
             //util.Track.sync(singletonName);
             
-            WebBeansContext managerMap = singletonMap.get(classLoader);
+            WebBeansContext webBeansContext = singletonMap.get(classLoader);
             //util.Track.get(singletonName);
 
-            if (managerMap == null)
+            if (webBeansContext == null)
             {
-                managerMap = new WebBeansContext();
-                singletonMap.put(classLoader, managerMap);
+                webBeansContext = new WebBeansContext();
+                singletonMap.put(classLoader, webBeansContext);
             }
 
-            // little optimization to potentially remove the second lookup
-            if (WebBeansContext.class.getName().equals(singletonName))
-            {
-                return managerMap;
-            }
-            
-            // WebBeansContext never returns null
-            object = managerMap.get(singletonName);
+            return webBeansContext;
 
-            objectToClassLoaderMap.put(object, new WeakReference<ClassLoader>(classLoader));
         }
-
-        return object;
     }
-    
-    /**
-     * Gets singleton instance if one already exists
-     * @param singletonName singleton class name
-     * @param cl classloader of the deployment
-     * @return singleton instance or null if one doesn't already exist
-     */
-    public Object getExistingSingletonInstance(String singletonName, ClassLoader cl)
-    {
-        throw new UnsupportedOperationException("getExistingSingletonInstance is never used");
-    }
-    
+
     /**
      * Clear all deployment instances when the application is undeployed.
      * @param classLoader of the deployment
@@ -133,7 +99,6 @@ public class DefaultSingletonService imp
         
         return null;
     }
-    
 
     /**
      * {@inheritDoc}
@@ -146,45 +111,6 @@ public class DefaultSingletonService imp
     }
 
     /**
-     * {@inheritDoc}
-     */    
-    @Override
-    public Object get(Object key, String singletonClassName)
-    {
-        assertClassLoaderKey(key);
-        return getSingletonInstance(singletonClassName, (ClassLoader)key);
-    }
-
-    /**
-     * {@inheritDoc}
-     */    
-    @Override
-    public Object getExist(Object key, String singletonClassName)
-    {
-        assertClassLoaderKey(key);
-        return getExistingSingletonInstance(singletonClassName, (ClassLoader)key);
-    }
-
-    /**
-     * {@inheritDoc}
-     */    
-    @Override
-    public boolean isExist(Object key, String singletonClassName)
-    {
-        assertClassLoaderKey(key);
-        return getExistingSingletonInstance(singletonClassName, (ClassLoader)key) != null ? true : false;
-    }
-
-    /**
-     * {@inheritDoc}
-     */    
-    @Override
-    public ClassLoader getKey(Object singleton)
-    {
-        return getSingletonClassLoader(singleton);
-    }
-    
-    /**
      * Assert that key is classloader instance.
      * @param key key
      */

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java Sat Jan  8 09:20:29 2011
@@ -31,9 +31,7 @@ import javax.enterprise.context.Dependen
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
-import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
-import org.apache.webbeans.spi.plugins.AbstractOwbJsfPlugin;
 
 /**
  * JSF or JSP expression language a.k.a EL resolver.
@@ -91,38 +89,18 @@ public class WebBeansELResolver extends 
      * {@inheritDoc}
      */    
     @Override
-    @SuppressWarnings({"unchecked","deprecation"})
+    @SuppressWarnings("unchecked")
     public Object getValue(ELContext context, Object obj, Object property) throws NullPointerException, PropertyNotFoundException, ELException
     {
-        //Check that application is OWB enabled
-        //For JSF applications that are not
-        //OWB enabled, no need to go with this resolver....
-        AbstractOwbJsfPlugin jsfPlugin = WebBeansContext.getInstance().getPluginLoader().getJsfPlugin();
-        
-        //No JSF plugin, sure that not OWB  
-        if(jsfPlugin == null)
-        {
-            return null;
-        }        
-        //If PluginLoader is called by application explicitly
-        //But not OWB application
-        else
-        {
-            if(!jsfPlugin.isOwbApplication())
-            {
-                return null;
-            }
-        }
-        
         //Bean instance
         Object contextualInstance = null;
-        ELContextStore elContextStore = null;
+
         if (obj == null)
         {
             //Name of the bean
             String name = (String) property;
             //Local store, create if not exist
-            elContextStore = ELContextStore.getInstance(true);
+            ELContextStore elContextStore = ELContextStore.getInstance(true);
 
             contextualInstance = elContextStore.findBeanByName(name);
 
@@ -156,7 +134,7 @@ public class WebBeansELResolver extends 
                 }
             }
         }
-        
+
         return contextualInstance;
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java Sat Jan  8 09:20:29 2011
@@ -29,7 +29,6 @@ import org.apache.webbeans.config.OWBLog
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLogger;
-import org.apache.webbeans.spi.plugins.AbstractOwbJsfPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansJavaEEPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
@@ -185,11 +184,6 @@ public class PluginLoader
      */
     public OpenWebBeansEjbPlugin getEjbPlugin()
     {
-        if(!pluginsExist())
-        {
-            return null;
-        }
-        
         for(OpenWebBeansPlugin plugin : this.plugins)
         {
             if(plugin instanceof OpenWebBeansEjbPlugin)
@@ -200,30 +194,6 @@ public class PluginLoader
         
         return null;
     }
-    
-    /**
-     * Gets JSF plugin.
-     * 
-     * @return JSF plugin
-     */
-    public AbstractOwbJsfPlugin getJsfPlugin()
-    {
-        if(!pluginsExist())
-        {
-            return null;
-        }
-        
-        for(OpenWebBeansPlugin plugin : this.plugins)
-        {
-            if(plugin instanceof AbstractOwbJsfPlugin)
-            {
-                return (AbstractOwbJsfPlugin)plugin;
-            }
-        }
-        
-        return null;
-    }   
-    
  
     /**
      * Gets ejb lifecycle annotations plugin
@@ -232,11 +202,6 @@ public class PluginLoader
      */
     public OpenWebBeansEjbLCAPlugin getEjbLCAPlugin()
     {
-        if(!pluginsExist())
-        {
-            return null;
-        }
-        
         for(OpenWebBeansPlugin plugin : this.plugins)
         {
             if(plugin instanceof OpenWebBeansEjbLCAPlugin)
@@ -254,11 +219,6 @@ public class PluginLoader
      */
     public OpenWebBeansJmsPlugin getJmsPlugin()
     {
-        if(!pluginsExist())
-        {
-            return null;
-        }
-        
         for(OpenWebBeansPlugin plugin : this.plugins)
         {
             if(plugin instanceof OpenWebBeansJmsPlugin)
@@ -273,11 +233,6 @@ public class PluginLoader
     
     public OpenWebBeansJavaEEPlugin getJavaEEPlugin()
     {
-        if(!pluginsExist())
-        {
-            return null;
-        }
-        
         for(OpenWebBeansPlugin plugin : this.plugins)
         {
             if(plugin instanceof OpenWebBeansJavaEEPlugin)
@@ -291,11 +246,6 @@ public class PluginLoader
     
     public OpenWebBeansWebPlugin getWebPlugin()
     {
-        if(!pluginsExist())
-        {
-            return null;
-        }
-        
         for(OpenWebBeansPlugin plugin : this.plugins)
         {
             if(plugin instanceof OpenWebBeansWebPlugin)
@@ -307,15 +257,6 @@ public class PluginLoader
         return null;        
     }    
     
-    private boolean pluginsExist()
-    {
-        if(this.plugins == null)
-        {
-            return false;
-        }
-        
-        return true;
-    }
     
     public boolean isShowDown()
     {

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java (original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java Sat Jan  8 09:20:29 2011
@@ -58,13 +58,15 @@ public class WebBeansPhaseListener imple
                 return;
             }
 
-            ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager();
+            WebBeansContext webBeansContext = WebBeansContext.getInstance();
+            ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
 
             if (conversation.isTransient())
             {
                 logger.debug("Destroying the conversation context with cid : [{0}]", conversation.getId());
-                ContextFactory.destroyConversationContext();                                                    
+                ContextFactory contextFactory = webBeansContext.getContextFactory();
+                contextFactory.destroyConversationContext();
             }
             else
             {
@@ -87,14 +89,16 @@ public class WebBeansPhaseListener imple
             //It looks for cid parameter in the JSF request.
             //If request contains cid, then it must restore conversation
             //Otherwise create NonexistentException
-            ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager();
+            WebBeansContext webBeansContext = WebBeansContext.getInstance();
+            ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
             String cid = JSFUtil.getConversationId();
+            ContextFactory contextFactory = webBeansContext.getContextFactory();
 
             if (conversation.isTransient())
             {
                 logger.debug("Creating a new transitional conversation with cid : [{0}]", conversation.getId());
-                ContextFactory.initConversationContext(null);
+                contextFactory.initConversationContext(null);
 
                 //Not restore, throw exception
                 if(cid != null && !cid.equals(""))
@@ -110,14 +114,14 @@ public class WebBeansPhaseListener imple
                 ConversationImpl owbConversation = (ConversationImpl)conversation;
                 if(!owbConversation.getInUsed().compareAndSet(false, true))
                 {
-                    ContextFactory.initConversationContext(null);
+                    contextFactory.initConversationContext(null);
                     //Throw Busy exception
                     throw new BusyConversationException("Propogated conversation with cid=" + cid + " is used by other request. It creates a new transient conversation");
                 }
                 else
                 {
                     ConversationContext conversationContext = conversationManager.getConversationContext(conversation);
-                    ContextFactory.initConversationContext(conversationContext);
+                    contextFactory.initConversationContext(conversationContext);
                 }
             }
         }

Modified: openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/plugin/OpenWebBeansJsfPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/plugin/OpenWebBeansJsfPlugin.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/plugin/OpenWebBeansJsfPlugin.java (original)
+++ openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/plugin/OpenWebBeansJsfPlugin.java Sat Jan  8 09:20:29 2011
@@ -19,17 +19,14 @@
 package org.apache.webbeans.jsf.plugin;
 
 import javax.faces.component.UIComponent;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
 
-import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.spi.plugins.AbstractOwbJsfPlugin;
+import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
 import org.apache.webbeans.util.ClassUtil;
 
-public class OpenWebBeansJsfPlugin extends AbstractOwbJsfPlugin
+public class OpenWebBeansJsfPlugin extends AbstractOwbPlugin
 {
+
     /** {@inheritDoc} */
     public void isManagedBean( Class<?> clazz ) throws WebBeansConfigurationException 
     {
@@ -39,20 +36,4 @@ public class OpenWebBeansJsfPlugin exten
                                                      + " can not implement JSF UIComponent");
         }
     }
-    
-    @Override
-    public boolean isOwbApplication()
-    {
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        if(facesContext == null)
-        {
-            throw new IllegalStateException("FacesContext is null");
-        }
-        
-        ExternalContext ext = facesContext.getExternalContext();
-        ServletContext servletContext = (ServletContext) ext.getContext();
-        Object attribute = servletContext.getAttribute(OpenWebBeansConfiguration.PROPERTY_OWB_APPLICATION);
-        
-        return attribute != null ? true : false;
-    }
 }

Modified: openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/WebBeansPhaseListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/WebBeansPhaseListener.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/WebBeansPhaseListener.java (original)
+++ openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/WebBeansPhaseListener.java Sat Jan  8 09:20:29 2011
@@ -58,13 +58,15 @@ public class WebBeansPhaseListener imple
         if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE) ||
                 phaseEvent.getFacesContext().getResponseComplete())
         {
-            ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager();
+            WebBeansContext webBeansContext = WebBeansContext.getInstance();
+            ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
+            ContextFactory contextFactory = webBeansContext.getContextFactory();
 
             if (conversation.isTransient())
             {
                 logger.debug("Destroying the conversation context with cid : [{0}]", conversation.getId());
-                ContextFactory.destroyConversationContext();                                                    
+                contextFactory.destroyConversationContext();
             }
             else
             {
@@ -92,14 +94,16 @@ public class WebBeansPhaseListener imple
             //It looks for cid parameter in the JSF request.
             //If request contains cid, then it must restore conversation
             //Otherwise create NonexistentException
-            ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager();
+            WebBeansContext webBeansContext = WebBeansContext.getInstance();
+            ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
             String cid = JSFUtil.getConversationId();
+            ContextFactory contextFactory = webBeansContext.getContextFactory();
 
             if (conversation.isTransient())
             {
                 logger.debug("Creating a new transitional conversation with cid : [{0}]", conversation.getId());
-                ContextFactory.initConversationContext(null);
+                contextFactory.initConversationContext(null);
 
                 //Not restore, throw exception
                 if(cid != null && !cid.equals(""))
@@ -115,14 +119,14 @@ public class WebBeansPhaseListener imple
                 ConversationImpl owbConversation = (ConversationImpl)conversation;
                 if(!owbConversation.getInUsed().compareAndSet(false, true))
                 {
-                    ContextFactory.initConversationContext(null);
+                    contextFactory.initConversationContext(null);
                     //Throw Busy exception
                     throw new BusyConversationException("Propogated conversation with cid=" + cid + " is used by other request. It creates a new transient conversation");
                 }
                 else
                 {
                     ConversationContext conversationContext = conversationManager.getConversationContext(conversation);
-                    ContextFactory.initConversationContext(conversationContext);
+                    contextFactory.initConversationContext(conversationContext);
                 }
             }
         }

Modified: openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/plugin/OpenWebBeansJsfPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/plugin/OpenWebBeansJsfPlugin.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/plugin/OpenWebBeansJsfPlugin.java (original)
+++ openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/plugin/OpenWebBeansJsfPlugin.java Sat Jan  8 09:20:29 2011
@@ -18,19 +18,15 @@
  */
 package org.apache.webbeans.jsf12.plugin;
 
-
 import javax.faces.component.UIComponent;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
 
-import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.spi.plugins.AbstractOwbJsfPlugin;
+import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
 import org.apache.webbeans.util.ClassUtil;
 
-public class OpenWebBeansJsfPlugin extends AbstractOwbJsfPlugin
+public class OpenWebBeansJsfPlugin extends AbstractOwbPlugin
 {
+
     /** {@inheritDoc} */
     public void isManagedBean( Class<?> clazz ) throws WebBeansConfigurationException 
     {
@@ -40,23 +36,4 @@ public class OpenWebBeansJsfPlugin exten
                                                      + " can not implement JSF UIComponent");
         }
     }
-
-    @Override
-    public boolean isOwbApplication()
-    {
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        if(facesContext == null)
-        {
-            throw new IllegalStateException("FacesContext is null");
-        }
-        
-        ExternalContext ext = facesContext.getExternalContext();
-        ServletContext servletContext = (ServletContext) ext.getContext();
-        Object attribute = servletContext.getAttribute(OpenWebBeansConfiguration.PROPERTY_OWB_APPLICATION);
-        
-        return attribute != null ? true : false;
-    }
-    
-    
-    
 }

Modified: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java (original)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java Sat Jan  8 09:20:29 2011
@@ -21,10 +21,10 @@ package org.apache.webbeans.ejb;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
-import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
 
@@ -50,8 +50,6 @@ import org.apache.openejb.core.stateful.
 import org.apache.openejb.core.stateless.StatelessContainer;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.spi.ContainerSystem;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.ejb.common.util.EjbDefinitionUtility;
 import org.apache.webbeans.ejb.common.util.EjbUtility;
 import org.apache.webbeans.ejb.component.OpenEjbBean;
@@ -65,6 +63,7 @@ import org.apache.webbeans.spi.Transacti
 import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.util.SecurityUtil;
+import org.apache.webbeans.util.WebBeansUtil;
 
 /**
  * EJB related stuff.
@@ -379,7 +378,7 @@ public class EjbPlugin extends AbstractO
         for (DeploymentInfo deployment : deployments)
         {
             boolean inTest = Boolean.valueOf(SecurityUtil.doPrivilegedGetSystemProperty("EjbPlugin.test", "false"));
-            classLoaderEquality = deployment.getBeanClass().getClassLoader().equals(WebBeansFinder.getSingletonClassLoader(WebBeansContext.getInstance().getPluginLoader()));
+            classLoaderEquality = deployment.getBeanClass().getClassLoader().equals(WebBeansUtil.getCurrentClassLoader());
 
             // Yes, this EJB archive is deployed within this web
             // application

Modified: openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java (original)
+++ openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java Sat Jan  8 09:20:29 2011
@@ -20,6 +20,7 @@ package org.apache.webbeans.test.tck;
 
 import javax.enterprise.context.RequestScoped;
 
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.AbstractContext;
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.RequestContext;
@@ -31,14 +32,17 @@ public class ContextsImpl implements Con
 
     public AbstractContext getRequestContext()
     {
-        RequestContext ctx =  (RequestContext)ContextFactory.getStandardContext(RequestScoped.class);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        RequestContext ctx =  (RequestContext)contextFactory.getStandardContext(RequestScoped.class);
         
         if(ctx == null)
         {
-            ContextFactory.initRequestContext(null);   
+            contextFactory.initRequestContext(null);
         }
         
-        return (AbstractContext) ContextFactory.getStandardContext(ContextTypes.REQUEST);
+        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.REQUEST);
     }
 
     public void setActive(AbstractContext context)
@@ -54,7 +58,10 @@ public class ContextsImpl implements Con
 
     public AbstractContext getDependentContext()
     {
-        return (AbstractContext) ContextFactory.getStandardContext(ContextTypes.DEPENDENT);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.DEPENDENT);
     }
 
     public void destroyContext(AbstractContext context)

Modified: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/SingletonService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/SingletonService.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/SingletonService.java (original)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/SingletonService.java Sat Jan  8 09:20:29 2011
@@ -26,15 +26,14 @@ package org.apache.webbeans.spi;
  * 
  * @version $Rev$ $Date$
  */
-public interface SingletonService
+public interface SingletonService<T>
 {
     /**
      * Get instance for given key and class name.
      * @param key instance key
-     * @param singletonClassName instance class name
      * @return instance
      */
-    public Object get(Object key, String singletonClassName);
+    public T get(Object key);
     
     /**
      * Any clean activity.
@@ -42,28 +41,4 @@ public interface SingletonService
      */
     public void clear(Object key);
     
-    /**
-     * Returns true if singleton exist,
-     * false otherwise.
-     * @param key instance key
-     * @param singletonClassName class name
-     * @return true if singleton exist
-     */
-    public boolean isExist(Object key, String singletonClassName);
-    
-    /**
-     * Returns exist instance or null.
-     * @param key instance key
-     * @param singletonClassName class name
-     * @return exist instance
-     */
-    public Object getExist(Object key, String singletonClassName);
-    
-    /**
-     * Returns key for the given singleton
-     * instance.
-     * @param singleton instance
-     * @return key for given instance
-     */
-    public Object getKey(Object singleton);
 }

Modified: openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java (original)
+++ openwebbeans/trunk/webbeans-test/cditest-owb/src/main/java/org/apache/webbeans/cditest/owb/CdiTestOpenWebBeansContainer.java Sat Jan  8 09:20:29 2011
@@ -62,23 +62,32 @@ public class CdiTestOpenWebBeansContaine
     @Override
     public void startContexts() throws Exception 
     {
-        ContextFactory.initSingletonContext(servletContext);
-        ContextFactory.initApplicationContext(servletContext);
-        ContextFactory.initSessionContext(session);
-        ContextFactory.initConversationContext(null);
-        ContextFactory.initRequestContext(null);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.initSingletonContext(servletContext);
+        contextFactory.initApplicationContext(servletContext);
+        contextFactory.initSessionContext(session);
+        contextFactory.initConversationContext(null);
+        contextFactory.initRequestContext(null);
     }
 
     @Override
     public void startApplicationScope() throws Exception 
     {
-        ContextFactory.initApplicationContext(servletContext);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.initApplicationContext(servletContext);
     }
 
     @Override
     public void startConversationScope() throws Exception 
     {
-        ContextFactory.initConversationContext(null);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.initConversationContext(null);
     }
 
     @Override
@@ -90,23 +99,32 @@ public class CdiTestOpenWebBeansContaine
     @Override
     public void startRequestScope() throws Exception 
     {
-        ContextFactory.initRequestContext(null);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.initRequestContext(null);
     }
 
     @Override
     public void startSessionScope() throws Exception 
     {
-        ContextFactory.initSessionContext(session);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.initSessionContext(session);
     }
 
     @Override
     public void stopContexts() throws Exception 
     {
-        ContextFactory.destroyRequestContext(null);
-        ContextFactory.destroyConversationContext();
-        ContextFactory.destroySessionContext(session);
-        ContextFactory.destroyApplicationContext(servletContext);
-        ContextFactory.destroySingletonContext(servletContext);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.destroyRequestContext(null);
+        contextFactory.destroyConversationContext();
+        contextFactory.destroySessionContext(session);
+        contextFactory.destroyApplicationContext(servletContext);
+        contextFactory.destroySingletonContext(servletContext);
 
         //Comment out for OWB-502
         //ContextFactory.cleanUpContextFactory();
@@ -115,13 +133,19 @@ public class CdiTestOpenWebBeansContaine
     @Override
     public void stopApplicationScope() throws Exception 
     {
-        ContextFactory.destroyApplicationContext(servletContext);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.destroyApplicationContext(servletContext);
     }
 
     @Override
     public void stopConversationScope() throws Exception 
     {
-        ContextFactory.destroyConversationContext();
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.destroyConversationContext();
     }
 
     @Override
@@ -133,13 +157,19 @@ public class CdiTestOpenWebBeansContaine
     @Override
     public void stopRequestScope() throws Exception 
     {
-        ContextFactory.destroyRequestContext(null);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.destroyRequestContext(null);
     }
 
     @Override
     public void stopSessionScope() throws Exception 
     {
-        ContextFactory.destroySessionContext(session);
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+
+        contextFactory.destroySessionContext(session);
     }
     
     public  BeanManager getBeanManager() 

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/SessionContextManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/SessionContextManager.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/SessionContextManager.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/SessionContextManager.java Sat Jan  8 09:20:29 2011
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.context.SessionContext;
 import org.apache.webbeans.util.Asserts;
 
@@ -37,7 +36,7 @@ import org.apache.webbeans.util.Asserts;
 public class SessionContextManager
 {
     /** Session id to SessionContext map*/
-    private Map<String, SessionContext> sessionContexts = null;
+    private final Map<String, SessionContext> sessionContexts;
 
     
     /**
@@ -47,18 +46,7 @@ public class SessionContextManager
     {
         sessionContexts = new ConcurrentHashMap<String, SessionContext>();        
     }
-    
-    /**
-     * Gets singleton instance.
-     * @return instance of session context manager
-     */
-    public static SessionContextManager getInstance()
-    {
-        SessionContextManager sessionContextManager = (SessionContextManager)WebBeansFinder.getSingletonInstance(SessionContextManager.class.getName());        
-        
-        return sessionContextManager;
-    }
-    
+
     /**
      * Adds new session context for the given session id.
      * @param sessionId session id

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java Sat Jan  8 09:20:29 2011
@@ -82,7 +82,7 @@ public class WebContextsService extends 
     private static Map<ServletContext, SingletonContext> currentSingletonContexts = new ConcurrentHashMap<ServletContext, SingletonContext>();
 
     /**Session context manager*/
-    private final SessionContextManager sessionCtxManager = SessionContextManager.getInstance();
+    private final SessionContextManager sessionCtxManager;
 
     /**Conversation context manager*/
     private final ConversationManager conversationManager;
@@ -126,6 +126,7 @@ public class WebContextsService extends 
         supportsConversation =  webBeansContext.getOpenWebBeansConfiguration().supportsConversation();
         failoverService = webBeansContext.getService(FailOverService.class);
         conversationManager = webBeansContext.getConversationManager();
+        sessionCtxManager = webBeansContext.getService(SessionContextManager.class);
     }
     
     /**

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java Sat Jan  8 09:20:29 2011
@@ -57,6 +57,8 @@ public class FailOverBag implements Seri
     SessionContext sessionContext;
     
     Map<Conversation, ConversationContext> conversationContextMap;
+
+    private final WebBeansContext webBeansContext = WebBeansContext.getInstance();
     
     public FailOverBag()
     {
@@ -72,11 +74,11 @@ public class FailOverBag implements Seri
     public void updateOwbFailOverBag(HttpSession session, FailOverService service) 
     {
         // get the session context
-        SessionContextManager sessionManager = SessionContextManager.getInstance();
+        SessionContextManager sessionManager = webBeansContext.getService(SessionContextManager.class);
         sessionContext = sessionManager.getSessionContextWithSessionId(session.getId());
 
         // get all conversation contexts 
-        ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager();
+        ConversationManager conversationManager = webBeansContext.getConversationManager();
         conversationContextMap = conversationManager.getConversationMapWithSessionId(session.getId());
     }
     
@@ -86,13 +88,13 @@ public class FailOverBag implements Seri
         {
             if (sessionContext != null) 
             {
-                SessionContextManager sessionManager = SessionContextManager.getInstance();
+                SessionContextManager sessionManager = webBeansContext.getService(SessionContextManager.class);
                 sessionManager.addNewSessionContext(sessionId, sessionContext);
                 sessionContext.setActive(true);
             }
             if (conversationContextMap != null && !conversationContextMap.isEmpty())
             {
-                ConversationManager conversationManager = WebBeansContext.getInstance().getConversationManager();
+                ConversationManager conversationManager = webBeansContext.getConversationManager();
                 java.util.Iterator<Conversation> it = conversationContextMap.keySet().iterator();
                 while(it.hasNext()) 
                 {

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/WebContainerLifecycle.java Sat Jan  8 09:20:29 2011
@@ -91,7 +91,7 @@ public final class WebContainerLifecycle
      */
     protected void afterStartApplication(Object startupObject) throws Exception
     {
-        String strDelay = getWebBeansContext().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.CONVERSATION_PERIODIC_DELAY,"150000");
+        String strDelay = WebBeansContext.getInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.CONVERSATION_PERIODIC_DELAY,"150000");
         long delay = Long.parseLong(strDelay);
 
         service = Executors.newScheduledThreadPool(1);
@@ -115,7 +115,7 @@ public final class WebContainerLifecycle
                 logger.debug("Default JSPFactroy instance has not found");
             }
         }
-        
+
         // Add BeanManager to the 'javax.enterprise.inject.spi.BeanManager' servlet context attribute
         ServletContext servletContext = (ServletContext)(startupObject);
         servletContext.setAttribute(BeanManager.class.getName(), getBeanManager());

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/test/EnterpriseTestLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/test/EnterpriseTestLifeCycle.java?rev=1056673&r1=1056672&r2=1056673&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/test/EnterpriseTestLifeCycle.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/test/EnterpriseTestLifeCycle.java Sat Jan  8 09:20:29 2011
@@ -20,6 +20,7 @@ package org.apache.webbeans.web.lifecycl
 
 import java.util.Properties;
 
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.corespi.se.DefaultScannerService;
 import org.apache.webbeans.el.ELContextStore;
@@ -47,11 +48,12 @@ public class EnterpriseTestLifeCycle ext
     {
         this.mockHttpSession = new MockHttpSession();
         this.servletContextEvent = new MockServletContextEvent();
-        
-        ContextFactory.initRequestContext(null);
-        ContextFactory.initSessionContext(mockHttpSession);
-        ContextFactory.initConversationContext(null);
-        ContextFactory.initApplicationContext(this.servletContextEvent.getServletContext());        
+        WebBeansContext webBeansContext = getWebBeansContext();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+        contextFactory.initRequestContext(null);
+        contextFactory.initSessionContext(mockHttpSession);
+        contextFactory.initConversationContext(null);
+        contextFactory.initApplicationContext(this.servletContextEvent.getServletContext());
     }
     
     @Override
@@ -63,10 +65,12 @@ public class EnterpriseTestLifeCycle ext
     @Override
     public void beforeStopApplication(Object endObject)
     {
-        ContextFactory.destroyRequestContext(null);
-        ContextFactory.destroySessionContext(this.mockHttpSession);
-        ContextFactory.destroyConversationContext();        
-        ContextFactory.destroyApplicationContext(this.servletContextEvent.getServletContext());
+        WebBeansContext webBeansContext = getWebBeansContext();
+        ContextFactory contextFactory = webBeansContext.getContextFactory();
+        contextFactory.destroyRequestContext(null);
+        contextFactory.destroySessionContext(this.mockHttpSession);
+        contextFactory.destroyConversationContext();
+        contextFactory.destroyApplicationContext(this.servletContextEvent.getServletContext());
 
         //Comment out for OWB-502
         //ContextFactory.cleanUpContextFactory();