openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1063529 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/m...
Date Tue, 25 Jan 2011 23:53:05 GMT
Author: dblevins
Date: Tue Jan 25 23:53:04 2011
New Revision: 1063529

URL: http://svn.apache.org/viewvc?rev=1063529&view=rev
Log:
OWB-503: A WebBeansContext.currentInstance() method for serialization and truly static usage

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.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/InjectableBeanManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ResourceProxyHandler.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=1063529&r1=1063528&r2=1063529&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
Tue Jan 25 23:53:04 2011
@@ -679,7 +679,7 @@ public class OpenWebBeansEjbInterceptor 
         s.defaultReadObject();
 
         /* restore transient BeanManager */
-        this.webBeansContext = WebBeansContext.getInstance();
+        this.webBeansContext = WebBeansContext.currentInstance();
 
         if (logger.wblWillLogDebug())
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
Tue Jan 25 23:53:04 2011
@@ -302,7 +302,7 @@ public abstract class BuildInOwbBean<T> 
             if(s.readLong() == serialVersionUID) 
             {
                 String id = (String)s.readObject();
-                WebBeansContext webBeansContext = WebBeansContext.getInstance();
+                WebBeansContext webBeansContext = WebBeansContext.currentInstance();
                 bean = (BuildInOwbBean<T>)webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
                 // create new real instance after deserialized.
                 actualObject = bean.createActualInstance(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=1063529&r1=1063528&r2=1063529&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
Tue Jan 25 23:53:04 2011
@@ -123,6 +123,22 @@ public class WebBeansContext
         return webBeansContext;
     }
 
+    /**
+     * Method to be used when static use is truely unavoidable, such as serialization
+     *
+     * Ideally this method would never lazily create a WebBeansContext and as we don't
+     * want to do any deployment of new apps during deserialization, we want to rehydrate
+     * objects from an existing WebBeansContext which should be the active context.
+     *
+     * This method could throw a runtime exception if no instance currently exists. 
+     *
+     * @return
+     */
+    public static WebBeansContext currentInstance()
+    {
+        return getInstance();
+    }
+
     public <T> T getService(Class<T> clazz)
     {
         T t = clazz.cast(serviceMap.get(clazz));

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectableBeanManager.java
Tue Jan 25 23:53:04 2011
@@ -234,7 +234,7 @@ public class InjectableBeanManager imple
             ClassNotFoundException 
     {
         //static lookup required for bean manager
-        this.bm = WebBeansContext.getInstance().getBeanManagerImpl();
+        this.bm = WebBeansContext.currentInstance().getBeanManagerImpl();
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/SerializableBean.java
Tue Jan 25 23:53:04 2011
@@ -159,7 +159,7 @@ public final class SerializableBean<T> i
     throws IOException, ClassNotFoundException
     {
         String id = (String) s.readObject();
-        Bean<T> b = (Bean<T>) WebBeansContext.getInstance().getBeanManagerImpl().getPassivationCapableBean(id);
+        Bean<T> b = (Bean<T>) WebBeansContext.currentInstance().getBeanManagerImpl().getPassivationCapableBean(id);
         if (b == null)
         {
             throw new DeploymentException("cannot deserialize Bean with PassivationCapable
id=" + id);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ConversationContext.java
Tue Jan 25 23:53:04 2011
@@ -68,7 +68,7 @@ public class ConversationContext extends
             String id = (String)it.next();
             if (id != null)
             {
-                contextual = (Contextual<?>) org.apache.webbeans.config.WebBeansContext.getInstance().getBeanManagerImpl().getPassivationCapableBean(id);
+                contextual = (Contextual<?>) org.apache.webbeans.config.WebBeansContext.currentInstance().getBeanManagerImpl().getPassivationCapableBean(id);
             }
             if (contextual != null) 
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/SessionContext.java
Tue Jan 25 23:53:04 2011
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentHa
 
 import javax.enterprise.context.spi.Contextual;
 
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.BeanInstanceBag;
 import org.apache.webbeans.context.type.ContextTypes;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -57,6 +58,8 @@ public class SessionContext extends Abst
     public void readExternal(ObjectInput in) throws IOException,
             ClassNotFoundException 
     {
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+
         this.type = (ContextTypes) in.readObject();
         this.scopeType = (Class<? extends Annotation>) in.readObject();
         Map<String, BeanInstanceBag<?>> map = (Map<String, BeanInstanceBag<?>>)in.readObject();
@@ -68,7 +71,7 @@ public class SessionContext extends Abst
             String id = (String)it.next();
             if (id != null)
             {
-                contextual = (Contextual<?>) org.apache.webbeans.config.WebBeansContext.getInstance().getBeanManagerImpl().getPassivationCapableBean(id);
+                contextual = (Contextual<?>) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
             }
             if (contextual != null) 
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/DependentCreationalContext.java
Tue Jan 25 23:53:04 2011
@@ -142,7 +142,8 @@ public class DependentCreationalContext<
         String id = (String) s.readObject();
         if (id != null)
         {
-            contextual = (Contextual<S>) WebBeansContext.getInstance().getBeanManagerImpl().getPassivationCapableBean(id);
+            WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+            contextual = (Contextual<S>) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
         }
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DelegateHandler.java
Tue Jan 25 23:53:04 2011
@@ -230,7 +230,7 @@ public class DelegateHandler implements 
         {
             return;
         }
-        bean = (OwbBean<?>) WebBeansContext.getInstance().getBeanManagerImpl().getPassivationCapableBean(id);
+        bean = (OwbBean<?>) WebBeansContext.currentInstance().getBeanManagerImpl().getPassivationCapableBean(id);
         actualBean = in.readObject();
         decorators = (List<Object>) in.readObject();
     }    

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
Tue Jan 25 23:53:04 2011
@@ -208,7 +208,7 @@ class InjectionPointImpl implements Inje
 
         Class<?> beanClass = (Class<?>)in.readObject();
         Set<Annotation> anns = new HashSet<Annotation>();
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
         AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
 
         while(!in.readObject().equals(new Character('~')))   // read throw-away '-' or '~'
terminal delimiter.

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Tue Jan 25 23:53:04 2011
@@ -365,7 +365,7 @@ public abstract class InterceptorHandler
     {
         if(s.readLong() == serialVersionUID)
         {
-            this.webBeansContext = WebBeansContext.getInstance();
+            this.webBeansContext = WebBeansContext.currentInstance();
             String passivationId = (String) s.readObject();
             if (passivationId != null)
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ResourceProxyHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ResourceProxyHandler.java?rev=1063529&r1=1063528&r2=1063529&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ResourceProxyHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ResourceProxyHandler.java
Tue Jan 25 23:53:04 2011
@@ -94,7 +94,7 @@ public class ResourceProxyHandler implem
             ClassNotFoundException 
     {
         String id = (String)in.readObject();
-        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
         bean = (ResourceBean) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
         ResourceInjectionService resourceInjectionService = webBeansContext.getService(ResourceInjectionService.class);
         actualResource = resourceInjectionService.readExternal(bean, in);



Mime
View raw message