openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1673741 - in /openwebbeans/trunk: webbeans-el22/src/test/java/org/apache/webbeans/el/test/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/a...
Date Wed, 15 Apr 2015 12:32:35 GMT
Author: struberg
Date: Wed Apr 15 12:32:35 2015
New Revision: 1673741

URL: http://svn.apache.org/r1673741
Log:
OWB-1046 finally get rid of old ContextFactory class.

This class is @deprecated for many years now. 
It also already did just delegate through to the ContextsService impl.

Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
Modified:
    openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomAlterablePassivatingContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/contexts/SerializationTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/DecoratorAndInterceptorStackTests.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/DependingInterceptorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InterceptorPerformanceTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/WithInheritedBindingTypeTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
    openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/WebBeansPhaseListener.java
    openwebbeans/trunk/webbeans-porting/src/main/java/org/apache/webbeans/test/tck/ContextsImpl.java
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/lifecycle/test/EnterpriseTestLifeCycle.java

Modified: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java
(original)
+++ openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java
Wed Apr 15 12:32:35 2015
@@ -28,10 +28,13 @@ import java.util.logging.Logger;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.el22.WebBeansELResolver;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.ContextsService;
 import org.junit.Assert;
 import org.junit.Test;
 
 import javax.el.ELContext;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
 
 public class ELPerformanceTest extends AbstractUnitTest
 {
@@ -94,8 +97,9 @@ public class ELPerformanceTest extends A
         @Override
         public void run()
         {
-            WebBeansContext.currentInstance().getContextFactory().initRequestContext(null);
-            WebBeansContext.currentInstance().getContextFactory().initSessionContext(null);
+            ContextsService contextsService = WebBeansContext.currentInstance().getContextsService();
+            contextsService.startContext(RequestScoped.class, null);
+            contextsService.startContext(SessionScoped.class, null);
 
             try
             {
@@ -114,8 +118,8 @@ public class ELPerformanceTest extends A
             }
             finally
             {
-                WebBeansContext.currentInstance().getContextFactory().destroyRequestContext(null);
-                WebBeansContext.currentInstance().getContextFactory().destroySessionContext(null);
+                contextsService.endContext(RequestScoped.class, null);
+                contextsService.endContext(SessionScoped.class, 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=1673741&r1=1673740&r2=1673741&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
Wed Apr 15 12:32:35 2015
@@ -28,7 +28,6 @@ import java.util.Properties;
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.SerializableBeanVault;
-import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.creational.CreationalContextFactory;
 import org.apache.webbeans.conversation.ConversationManager;
 import org.apache.webbeans.decorator.DecoratorsManager;
@@ -69,7 +68,6 @@ public class WebBeansContext
     private final Map<Class<?>, Object> serviceMap = new HashMap<Class<?>,
Object>();
 
     private final WebBeansUtil webBeansUtil = new WebBeansUtil(this);
-    private final ContextFactory contextFactory = new ContextFactory(this);
     private final AlternativesManager alternativesManager = new AlternativesManager(this);
     private final AnnotatedElementFactory annotatedElementFactory = new AnnotatedElementFactory(this);
     private final BeanManagerImpl beanManagerImpl = new BeanManagerImpl(this);
@@ -243,12 +241,6 @@ public class WebBeansContext
         return webBeansUtil;
     }
 
-    @Deprecated
-    public ContextFactory getContextFactory()
-    {
-        return contextFactory;
-    }
-
     public AnnotationManager getAnnotationManager()
     {
         return annotationManager;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Wed Apr 15 12:32:35 2015
@@ -38,6 +38,7 @@ import javax.el.ExpressionFactory;
 import javax.enterprise.context.ContextNotActiveException;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.NormalScope;
+import javax.enterprise.context.spi.AlterableContext;
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
@@ -73,6 +74,8 @@ import org.apache.webbeans.component.cre
 import org.apache.webbeans.component.third.PassivationCapableThirdpartyBeanImpl;
 import org.apache.webbeans.component.third.ThirdpartyBeanImpl;
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.CustomAlterablePassivatingContextImpl;
+import org.apache.webbeans.context.CustomPassivatingContextImpl;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DecoratorComparator;
 import org.apache.webbeans.event.EventMetadataImpl;
@@ -416,13 +419,35 @@ public class BeanManagerImpl implements
 
     public BeanManager addContext(Context context)
     {
-        addContext(context.getScope(), webBeansContext.getContextFactory().getCustomContext(context));
+        addContext(context.getScope(), wrapCustomContext(context));
 
         return this;
 
     }
 
     /**
+     * If the context is passivating then we need to wrap it into a version which
+     * uses the {@link SerializableBeanVault }
+     */
+    public Context wrapCustomContext(Context context)
+    {
+        if (isPassivatingScope(context.getScope()))
+        {
+            if (context instanceof AlterableContext)
+            {
+                return new CustomAlterablePassivatingContextImpl(webBeansContext.getSerializableBeanVault(),
(AlterableContext) context);
+            }
+            else
+            {
+                return new CustomPassivatingContextImpl(webBeansContext.getSerializableBeanVault(),
context);
+            }
+        }
+
+        return context;
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomAlterablePassivatingContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomAlterablePassivatingContextImpl.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomAlterablePassivatingContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomAlterablePassivatingContextImpl.java
Wed Apr 15 12:32:35 2015
@@ -28,7 +28,7 @@ import org.apache.webbeans.container.Ser
  */
 public class CustomAlterablePassivatingContextImpl extends CustomPassivatingContextImpl implements
AlterableContext
 {
-    CustomAlterablePassivatingContextImpl(SerializableBeanVault sbv, AlterableContext context)
+    public CustomAlterablePassivatingContextImpl(SerializableBeanVault sbv, AlterableContext
context)
     {
         super(sbv, context);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomPassivatingContextImpl.java
Wed Apr 15 12:32:35 2015
@@ -34,7 +34,7 @@ public class CustomPassivatingContextImp
     protected final Context context;
 
 
-    CustomPassivatingContextImpl(SerializableBeanVault sbv, Context context)
+    public CustomPassivatingContextImpl(SerializableBeanVault sbv, Context context)
     {
         this.sbv = sbv;
         this.context = context;

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/contexts/SerializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/contexts/SerializationTest.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/contexts/SerializationTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/contexts/SerializationTest.java
Wed Apr 15 12:32:35 2015
@@ -141,7 +141,7 @@ public class SerializationTest extends A
         
         // first we need to actually create a few instances
 
-        Context sessionContext = webBeansContext.getContextFactory().getStandardContext(SessionScoped.class);
+        Context sessionContext = webBeansContext.getBeanManagerImpl().getContext(SessionScoped.class);
         Assert.assertNotNull(sessionContext);
         byte[] ba = serializeObject(sessionContext);
         Assert.assertNotNull(ba);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/DecoratorAndInterceptorStackTests.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/DecoratorAndInterceptorStackTests.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/DecoratorAndInterceptorStackTests.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/decorators/tests/DecoratorAndInterceptorStackTests.java
Wed Apr 15 12:32:35 2015
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.enterprise.context.RequestScoped;
 import javax.enterprise.inject.Default;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.util.AnnotationLiteral;
@@ -30,6 +31,7 @@ import javax.enterprise.util.AnnotationL
 import junit.framework.Assert;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.decorators.multiple.Decorator1;
 import org.apache.webbeans.test.decorators.multiple.Decorator2;
@@ -132,10 +134,11 @@ public class DecoratorAndInterceptorStac
         @Override
         public void run()
         {
+            ContextsService contextsService = WebBeansContext.currentInstance().getContextsService();
             try
             {
                 // this starts the RequestContext for this very thread
-                WebBeansContext.currentInstance().getContextFactory().initRequestContext(null);
+                contextsService.startContext(RequestScoped.class, null);
 
                 for (int i=0; i < 10; i++)
                 {
@@ -147,6 +150,7 @@ public class DecoratorAndInterceptorStac
                 log.log(Level.SEVERE, "Error while executing Decorators in parallel!", e);
                 failed = true;
             }
+            contextsService.endContext(RequestScoped.class, null);
         }
 
         public boolean isFailed()

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/DependingInterceptorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/DependingInterceptorTest.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/DependingInterceptorTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/DependingInterceptorTest.java
Wed Apr 15 12:32:35 2015
@@ -22,12 +22,13 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Set;
 
+import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
 import junit.framework.Assert;
 
-import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.interceptors.beans.ApplicationScopedBean;
 import org.apache.webbeans.test.interceptors.beans.DependentScopedBean;
@@ -80,9 +81,9 @@ public class DependingInterceptorTest ex
 
         TransactionInterceptor.ECHO = false;
 
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        webBeansContext.getContextFactory().destroyRequestContext(null);
-        webBeansContext.getContextFactory().initRequestContext(null);
+        ContextsService contextsService = getWebBeansContext().getContextsService();
+        contextsService.endContext(RequestScoped.class, null);
+        contextsService.startContext(RequestScoped.class, null);
 
         CreationalContext<RequestScopedBean> ctx2 = getBeanManager().createCreationalContext(bean);
         Object reference2 = getBeanManager().getReference(bean, RequestScopedBean.class,
ctx2);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InterceptorPerformanceTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InterceptorPerformanceTest.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InterceptorPerformanceTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/InterceptorPerformanceTest.java
Wed Apr 15 12:32:35 2015
@@ -21,6 +21,7 @@ package org.apache.webbeans.test.interce
 import junit.framework.Assert;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.interceptors.beans.ApplicationScopedBean;
 import org.apache.webbeans.test.interceptors.beans.DependentScopedBean;
@@ -28,6 +29,7 @@ import org.apache.webbeans.test.intercep
 import org.apache.webbeans.test.interceptors.common.TransactionInterceptor;
 import org.junit.Test;
 
+import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import java.util.ArrayList;
@@ -119,9 +121,10 @@ public class InterceptorPerformanceTest
         {
             try
             {
+                ContextsService contextsService = WebBeansContext.currentInstance().getContextsService();
                 for (int req = 0; req < 5; req++)
                 {
-                    WebBeansContext.currentInstance().getContextFactory().initRequestContext(null);
+                    contextsService.startContext(RequestScoped.class, null);
 
                     Set<Bean<?>> beans = getBeanManager().getBeans(RequestScopedBean.class);
                     Assert.assertNotNull(beans);
@@ -146,7 +149,7 @@ public class InterceptorPerformanceTest
                         beanInstance1.getMyService().getJ();
                     }
 
-                    WebBeansContext.currentInstance().getContextFactory().destroyRequestContext(null);
+                    contextsService.endContext(RequestScoped.class, null);
                 }
             }
             catch (Exception e)

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/WithInheritedBindingTypeTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/WithInheritedBindingTypeTest.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/WithInheritedBindingTypeTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/business/tests/WithInheritedBindingTypeTest.java
Wed Apr 15 12:32:35 2015
@@ -22,12 +22,14 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Set;
 
+import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
 import junit.framework.Assert;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.interceptors.business.common.WithInheritedBindingTypeBean;
 import org.apache.webbeans.test.interceptors.common.SecureInterceptor;
@@ -73,9 +75,9 @@ public class WithInheritedBindingTypeTes
         Assert.assertTrue(TransactionInterceptor.ECHO);
         Assert.assertTrue(SecureInterceptor.ECHO);
 
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        webBeansContext.getContextFactory().destroyRequestContext(null);
-        webBeansContext.getContextFactory().initRequestContext(null);
+        ContextsService contextsService = WebBeansContext.currentInstance().getContextsService();
+        contextsService.endContext(RequestScoped.class, null);
+        contextsService.startContext(RequestScoped.class, null);
 
         reference = getBeanManager().getReference(bean, WithInheritedBindingTypeBean.class,
ctx);
         beanInstance = (WithInheritedBindingTypeBean)reference;

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java?rev=1673741&r1=1673740&r2=1673741&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java
Wed Apr 15 12:32:35 2015
@@ -20,6 +20,7 @@ package org.apache.webbeans.test.portabl
 
 import java.util.Set;
 
+import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.PassivationCapable;
 
@@ -66,7 +67,7 @@ public class ExtensionTest extends Abstr
         startContainer(ExternalTestScopedBean.class);
 
         WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        webBeansContext.getContextFactory().initApplicationContext(null);
+        webBeansContext.getContextsService().startContext(ApplicationScoped.class, null);
 
         @SuppressWarnings("unchecked")
         Bean<ExternalTestScopedBean> bean = (Bean<ExternalTestScopedBean>) getBeanManager().getBeans(ExternalTestScopedBean.class,

@@ -82,7 +83,7 @@ public class ExtensionTest extends Abstr
         //Fire shut down
         BeanManagerImpl.class.cast(getBeanManager()).fireEvent(new BeforeShutdownImpl(),
true);
 
-        webBeansContext.getContextFactory().destroyApplicationContext(null);
+        webBeansContext.getContextsService().endContext(ApplicationScoped.class, null);
 
         shutDownContainer();
     }

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=1673741&r1=1673740&r2=1673741&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
Wed Apr 15 12:32:35 2015
@@ -20,6 +20,7 @@ package org.apache.webbeans.jsf;
 
 import javax.enterprise.context.BusyConversationException;
 import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
 import javax.enterprise.context.NonexistentConversationException;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
@@ -28,11 +29,11 @@ import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.ConversationContext;
 import org.apache.webbeans.conversation.ConversationImpl;
 import org.apache.webbeans.conversation.ConversationManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.ContextsService;
 
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -52,6 +53,11 @@ public class WebBeansPhaseListener imple
 
     private Boolean owbApplication = null;
 
+    private WebBeansContext webBeansContext = WebBeansContext.getInstance();
+    private ConversationManager conversationManager = webBeansContext.getConversationManager();
+    private ContextsService contextsService = webBeansContext.getContextsService();
+
+
     /**
      * {@inheritDoc}
      */
@@ -66,7 +72,6 @@ public class WebBeansPhaseListener imple
                 return;
             }
 
-            WebBeansContext webBeansContext = WebBeansContext.getInstance();
             ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
 
@@ -76,8 +81,7 @@ public class WebBeansPhaseListener imple
                 {
                     logger.log(Level.FINE, "Destroying the conversation context with cid
: [{0}]", conversation.getId());
                 }
-                ContextFactory contextFactory = webBeansContext.getContextFactory();
-                contextFactory.destroyConversationContext();
+                contextsService.endContext(ConversationScoped.class, null);
             }
             else
             {
@@ -101,17 +105,14 @@ 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
-            WebBeansContext webBeansContext = WebBeansContext.getInstance();
-            ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
-            ContextFactory contextFactory = webBeansContext.getContextFactory();
 
             String propagation = JSFUtil.getConversationPropagation();
             boolean createNew = "none".equals(propagation);
 
             if (createNew)
             {
-                contextFactory.initConversationContext(getRequest(phaseEvent));
+                contextsService.startContext(ConversationScoped.class, getRequest(phaseEvent));
             }
             else if (conversation.isTransient())
             {
@@ -119,7 +120,7 @@ public class WebBeansPhaseListener imple
                 {
                     logger.log(Level.FINE, "Creating a new transitional conversation with
cid : [{0}]", conversation.getId());
                 }
-                contextFactory.initConversationContext(getRequest(phaseEvent));
+                contextsService.startContext(ConversationScoped.class, getRequest(phaseEvent));
 
                 //Not restore, throw exception
                 String cid = JSFUtil.getConversationId();
@@ -139,7 +140,7 @@ public class WebBeansPhaseListener imple
                 ConversationImpl owbConversation = (ConversationImpl)conversation;
                 if(owbConversation.iUseIt() > 1)
                 {
-                    contextFactory.initConversationContext(getRequest(phaseEvent));
+                    contextsService.startContext(ConversationScoped.class, getRequest(phaseEvent));
                     //Throw Busy exception
                     throw new BusyConversationException(
                             "Propogated conversation with cid=" + JSFUtil.getConversationId()
+ " is used by other request. It creates a new transient conversation");
@@ -147,7 +148,7 @@ public class WebBeansPhaseListener imple
                 else
                 {
                     ConversationContext conversationContext = conversationManager.getConversationContext(conversation);
-                    contextFactory.initConversationContext(conversationContext);
+                    contextsService.startContext(ConversationScoped.class, conversationContext);
                 }
             }
         }

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=1673741&r1=1673740&r2=1673741&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
Wed Apr 15 12:32:35 2015
@@ -20,17 +20,18 @@ package org.apache.webbeans.jsf12;
 
 import javax.enterprise.context.BusyConversationException;
 import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
 import javax.enterprise.context.NonexistentConversationException;
 import javax.faces.event.PhaseEvent;
 import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.ConversationContext;
 import org.apache.webbeans.conversation.ConversationImpl;
 import org.apache.webbeans.conversation.ConversationManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.ContextsService;
 
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -50,6 +51,10 @@ public class WebBeansPhaseListener imple
 
     private Boolean owbApplication = null;
 
+    private WebBeansContext webBeansContext = WebBeansContext.getInstance();
+    private ConversationManager conversationManager = webBeansContext.getConversationManager();
+    private ContextsService contextsService = webBeansContext.getContextsService();
+
     /**
      * {@inheritDoc}
      */
@@ -64,10 +69,7 @@ public class WebBeansPhaseListener imple
         if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE) ||
                 phaseEvent.getFacesContext().getResponseComplete())
         {
-            WebBeansContext webBeansContext = WebBeansContext.getInstance();
-            ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
-            ContextFactory contextFactory = webBeansContext.getContextFactory();
 
             if (conversation.isTransient())
             {
@@ -75,7 +77,7 @@ public class WebBeansPhaseListener imple
                 {
                     logger.log(Level.FINE, "Destroying the conversation context with cid
: [{0}]", conversation.getId());
                 }
-                contextFactory.destroyConversationContext();
+                contextsService.endContext(ConversationScoped.class, null);
             }
             else
             {
@@ -108,7 +110,6 @@ public class WebBeansPhaseListener imple
             ConversationManager conversationManager = webBeansContext.getConversationManager();
             Conversation conversation = conversationManager.getConversationBeanReference();
             String cid = JSFUtil.getConversationId();
-            ContextFactory contextFactory = webBeansContext.getContextFactory();
 
             if (conversation.isTransient())
             {
@@ -116,7 +117,7 @@ public class WebBeansPhaseListener imple
                 {
                     logger.log(Level.FINE, "Creating a new transitional conversation with
cid : [{0}]", conversation.getId());
                 }
-                contextFactory.initConversationContext(null);
+                contextsService.startContext(ConversationScoped.class, null);
 
                 //Not restore, throw exception
                 if(cid != null && !cid.equals(""))
@@ -135,14 +136,14 @@ public class WebBeansPhaseListener imple
                 ConversationImpl owbConversation = (ConversationImpl)conversation;
                 if(owbConversation.iUseIt() > 1)
                 {
-                    contextFactory.initConversationContext(null);
+                    contextsService.startContext(ConversationScoped.class, 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);
+                    contextsService.startContext(ConversationScoped.class, conversationContext);
                 }
             }
         }

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=1673741&r1=1673740&r2=1673741&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
Wed Apr 15 12:32:35 2015
@@ -23,7 +23,6 @@ import javax.enterprise.context.RequestS
 
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.AbstractContext;
-import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.context.RequestContext;
 import org.jboss.cdi.tck.spi.Contexts;
 
@@ -34,16 +33,16 @@ public class ContextsImpl implements Con
     public AbstractContext getRequestContext()
     {
         WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        ContextFactory contextFactory = webBeansContext.getContextFactory();
 
-        RequestContext ctx =  (RequestContext)contextFactory.getStandardContext(RequestScoped.class);
+        RequestContext ctx =  (RequestContext)webBeansContext.getBeanManagerImpl().getContext(RequestScoped.class);
         
         if(ctx == null)
         {
-            contextFactory.initRequestContext(null);
+            webBeansContext.getContextsService().startContext(RequestScoped.class, null);
+            ctx =  (RequestContext)webBeansContext.getBeanManagerImpl().getContext(RequestScoped.class);
         }
         
-        return (AbstractContext) contextFactory.getStandardContext(RequestScoped.class);
+        return ctx;
     }
 
     @Override
@@ -63,9 +62,8 @@ public class ContextsImpl implements Con
     public AbstractContext getDependentContext()
     {
         WebBeansContext webBeansContext = WebBeansContext.getInstance();
-        ContextFactory contextFactory = webBeansContext.getContextFactory();
 
-        return (AbstractContext) contextFactory.getStandardContext(Dependent.class);
+        return (AbstractContext) webBeansContext.getBeanManagerImpl().getContext(Dependent.class);
     }
 
     @Override

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=1673741&r1=1673740&r2=1673741&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
Wed Apr 15 12:32:35 2015
@@ -18,13 +18,17 @@
  */
 package org.apache.webbeans.web.lifecycle.test;
 
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
 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;
 import org.apache.webbeans.lifecycle.StandaloneLifeCycle;
+import org.apache.webbeans.spi.ContextsService;
 
 /**
  * Ease the writing of the tests. Simulates container
@@ -49,11 +53,11 @@ public class EnterpriseTestLifeCycle ext
         this.mockHttpSession = new MockHttpSession();
         this.servletContextEvent = new MockServletContextEvent();
         WebBeansContext webBeansContext = getWebBeansContext();
-        ContextFactory contextFactory = webBeansContext.getContextFactory();
-        contextFactory.initRequestContext(null);
-        contextFactory.initSessionContext(mockHttpSession);
-        contextFactory.initConversationContext(null);
-        contextFactory.initApplicationContext(this.servletContextEvent.getServletContext());
+        ContextsService contextsService = webBeansContext.getContextsService();
+        contextsService.startContext(RequestScoped.class, null);
+        contextsService.startContext(SessionScoped.class, mockHttpSession);
+        contextsService.startContext(ConversationScoped.class, null);
+        contextsService.startContext(ApplicationScoped.class, this.servletContextEvent.getServletContext());
     }
     
     @Override
@@ -66,11 +70,11 @@ public class EnterpriseTestLifeCycle ext
     public void beforeStopApplication(Object endObject)
     {
         WebBeansContext webBeansContext = getWebBeansContext();
-        ContextFactory contextFactory = webBeansContext.getContextFactory();
-        contextFactory.destroyRequestContext(null);
-        contextFactory.destroySessionContext(this.mockHttpSession);
-        contextFactory.destroyConversationContext();
-        contextFactory.destroyApplicationContext(this.servletContextEvent.getServletContext());
+        ContextsService contextsService = webBeansContext.getContextsService();
+        contextsService.endContext(RequestScoped.class, null);
+        contextsService.endContext(SessionScoped.class, this.mockHttpSession);
+        contextsService.endContext(ConversationScoped.class, null);
+        contextsService.endContext(ApplicationScoped.class, this.servletContextEvent.getServletContext());
 
         //Comment out for OWB-502
         //ContextFactory.cleanUpContextFactory();



Mime
View raw message