[weld-commits] Weld SVN: r4217 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 5 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Oct 22 02:05:30 EDT 2009


Author: marius.bogoevici
Date: 2009-10-22 02:05:30 -0400 (Thu, 22 Oct 2009)
New Revision: 4217

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java
Removed:
   core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java
   core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java
   core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
   core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java
   core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
Log:
ContextualStore, SerializableContextual and SerializableContextualInstance are implementations of the SPI-provided interfaces.


Modified: core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -64,8 +64,9 @@
 import org.jboss.weld.bootstrap.api.ServiceRegistry;
 import org.jboss.weld.bootstrap.events.AbstractProcessInjectionTarget;
 import org.jboss.weld.context.CreationalContextImpl;
-import org.jboss.weld.context.SerializableContextual;
 import org.jboss.weld.context.WeldCreationalContext;
+import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
 import org.jboss.weld.ejb.EjbDescriptors;
 import org.jboss.weld.ejb.spi.EjbDescriptor;
 import org.jboss.weld.el.Namespace;

Deleted: core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.inject.spi.PassivationCapable;
-
-import org.jboss.weld.bootstrap.api.Service;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Maps;
-
-/**
- * Application wide contextual identifier service which allows a serializable
- * reference to a contextual to be obtained, and the contextual to be returned
- * for a given id.
- * 
- * If the contextual implements PassivationCapable, the id will be obtained 
- * from it, in which case the Contextual can be activated in any container.
- * If not, the Contextual can only be activated in this container.
- * 
- * Note that this allows a Bean object to be loaded regardless
- * of the bean's accessiblity from the current module, and should not be abused
- * as a way to ignore accessibility rules enforced during resolution.
- * 
- * @author Pete Muir
- * 
- * 
- */
-public class ContextualStore implements Service
-{
-   
-   private static final String GENERATED_ID_PREFIX = ContextualStore.class.getName();
-   
-   // The map containing container-local contextuals
-   private final BiMap<Contextual<?>, String> contextuals;
-   
-   // The map containing passivation capable contextuals
-   private final ConcurrentMap<String, Contextual<?>> passivationCapableContextuals;
-   
-   private final AtomicInteger idGenerator;
-   
-   public ContextualStore()
-   {
-      this.idGenerator = new AtomicInteger(0);
-      BiMap<Contextual<?>, String> map = HashBiMap.create();
-      // TODO Somehow remove this sync if it shows bad in a profiler
-      this.contextuals = Maps.synchronizedBiMap(map);
-      this.passivationCapableContextuals = new ConcurrentHashMap<String, Contextual<?>>();
-   }
-   
-   /**
-    * Given a particular id, return the correct contextual. For contextuals
-    * which aren't passivation capable, the contextual can't be found in another
-    * container, and null will be returned.
-    * 
-    * @param id An identifier for the contextual
-    * @return the contextual
-    */
-   @SuppressWarnings("unchecked")
-   public <C extends Contextual<I>, I> C getContextual(String id)
-   {
-      if (id.startsWith(GENERATED_ID_PREFIX))
-      {
-         return (C) contextuals.inverse().get(id);
-      }
-      else
-      {
-         return (C) passivationCapableContextuals.get(id);
-      }
-   }
-   
-   /**
-    * Add a contextual (if not already present) to the store, and return
-    * it's id. If the contextual is passivation capable, it's id will
-    * be used, otherwise an id will be generated
-    * 
-    * @param contextual the contexutal to add
-    * @return the current id for the contextual
-    */
-   public String putIfAbsent(Contextual<?> contextual)
-   {
-      if (contextual instanceof PassivationCapable)
-      {
-         PassivationCapable passivationCapable = (PassivationCapable) contextual;
-         passivationCapableContextuals.putIfAbsent(passivationCapable.getId(), contextual);
-         return passivationCapable.getId();
-      }
-      else if (contextuals.containsKey(contextual))
-      {
-         return contextuals.get(contextual);
-      }
-      else
-      {
-         String id = new StringBuilder().append(GENERATED_ID_PREFIX).append(idGenerator.incrementAndGet()).toString();
-         contextuals.put(contextual, id);
-         return id;
-      }
-   }
-
-   public void cleanup()
-   {
-      contextuals.clear();
-      passivationCapableContextuals.clear();
-   }
-}

Copied: core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java (from rev 4215, core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.PassivationCapable;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Maps;
+
+import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+import org.jboss.weld.context.SerializableContextualImpl;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
+
+/**
+ * Implementation of {@link org.jboss.weld.serialization.spi.ContextualStore}
+ *
+ * @author Pete Muir
+ *
+ */
+public class ContextualStoreImpl implements ContextualStore
+{
+   
+   private static final String GENERATED_ID_PREFIX = ContextualStoreImpl.class.getName();
+   
+   // The map containing container-local contextuals
+   private final BiMap<Contextual<?>, String> contextuals;
+   
+   // The map containing passivation capable contextuals
+   private final ConcurrentMap<String, Contextual<?>> passivationCapableContextuals;
+   
+   private final AtomicInteger idGenerator;
+   
+   public ContextualStoreImpl()
+   {
+      this.idGenerator = new AtomicInteger(0);
+      BiMap<Contextual<?>, String> map = HashBiMap.create();
+      // TODO Somehow remove this sync if it shows bad in a profiler
+      this.contextuals = Maps.synchronizedBiMap(map);
+      this.passivationCapableContextuals = new ConcurrentHashMap<String, Contextual<?>>();
+   }
+
+   /**
+    * Given a particular id, return the correct contextual. For contextuals
+    * which aren't passivation capable, the contextual can't be found in another
+    * container, and null will be returned.
+    * 
+    * @param id An identifier for the contextual
+    * @return the contextual
+    */
+   @SuppressWarnings("unchecked")
+   public <C extends Contextual<I>, I> C getContextual(String id)
+   {
+      if (id.startsWith(GENERATED_ID_PREFIX))
+      {
+         return (C) contextuals.inverse().get(id);
+      }
+      else
+      {
+         return (C) passivationCapableContextuals.get(id);
+      }
+   }
+   
+   /**
+    * Add a contextual (if not already present) to the store, and return
+    * it's id. If the contextual is passivation capable, it's id will
+    * be used, otherwise an id will be generated
+    * 
+    * @param contextual the contexutal to add
+    * @return the current id for the contextual
+    */
+   public String putIfAbsent(Contextual<?> contextual)
+   {
+      if (contextual instanceof PassivationCapable)
+      {
+         PassivationCapable passivationCapable = (PassivationCapable) contextual;
+         passivationCapableContextuals.putIfAbsent(passivationCapable.getId(), contextual);
+         return passivationCapable.getId();
+      }
+      else if (contextuals.containsKey(contextual))
+      {
+         return contextuals.get(contextual);
+      }
+      else
+      {
+         String id = new StringBuilder().append(GENERATED_ID_PREFIX).append(idGenerator.incrementAndGet()).toString();
+         contextuals.put(contextual, id);
+         return id;
+      }
+   }
+
+   public <C extends Contextual<I>, I> SerializableContextual<C, I> getSerializableContextual(Contextual<I> contextual)
+   {
+      return new SerializableContextualImpl(contextual);
+   }
+
+   public <C extends Contextual<I>, I> SerializableContextualInstance<C, I> getSerializableContextualInstance(Contextual<I> contextual, I instance, CreationalContext<I> creationalContext)
+   {
+      return new SerializableContextualInstanceImpl(contextual, instance, creationalContext);
+   }
+
+   public void cleanup()
+   {
+      contextuals.clear();
+      passivationCapableContextuals.clear();
+   }
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/Validator.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/Validator.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -46,13 +46,12 @@
 import org.jboss.weld.bean.AbstractProducerBean;
 import org.jboss.weld.bean.DecoratorImpl;
 import org.jboss.weld.bean.DisposalMethod;
-import org.jboss.weld.bean.ManagedBean;
 import org.jboss.weld.bean.NewManagedBean;
 import org.jboss.weld.bean.NewSessionBean;
 import org.jboss.weld.bean.RIBean;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.bootstrap.api.Service;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
 import org.jboss.weld.introspector.WeldAnnotated;
 import org.jboss.weld.metadata.cache.MetaAnnotationStore;
 import org.jboss.weld.resolution.ResolvableWeldClass;
@@ -135,7 +134,7 @@
       InterceptionModel<Class<?>, Class<?>> ejbInterceptorModel = beanManager.getClassDeclaredInterceptorsRegistry().getInterceptionModel(((AbstractClassBean<?>) classBean).getType());
       if (ejbInterceptorModel != null)
       {
-         Class<?>[] classDeclaredInterceptors = ejbInterceptorModel.getAllInterceptors().toArray(new Class<?>[0]);
+         Class<?>[] classDeclaredInterceptors = ejbInterceptorModel.getAllInterceptors().toArray(new Class<?>[ejbInterceptorModel.getAllInterceptors().size()]);
          if (classDeclaredInterceptors != null)
          {
             for (Class<?> interceptorClass: classDeclaredInterceptors)

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -46,11 +46,13 @@
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.DefinitionException;
 import org.jboss.weld.DeploymentException;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
+import org.jboss.weld.context.SerializableContextualImpl;
 import org.jboss.weld.ejb.EJBApiAbstraction;
 import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
-import org.jboss.weld.context.SerializableContextual;
-import org.jboss.weld.context.SerializableContextualInstance;
 import org.jboss.weld.injection.FieldInjectionPoint;
 import org.jboss.weld.injection.MethodInjectionPoint;
 import org.jboss.weld.introspector.WeldClass;
@@ -184,7 +186,7 @@
                DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>) decorator;
                
                Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
-               decoratorInstances.add(new SerializableContextualInstance<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance, null));
+               decoratorInstances.add(new SerializableContextualInstanceImpl<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance, null));
                ip = decoratorBean.getDelegateInjectionPoint();
             }
             else
@@ -442,7 +444,7 @@
             {
                if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
                   throw new DeploymentException("Conflicting interceptor bindings found on " + getType() + "." + method.getName() + "()");
-               
+
                if (method.isAnnotationPresent(manager.getServices().get(EJBApiAbstraction.class).TIMEOUT_ANNOTATION_CLASS))
                {
                   List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_TIMEOUT, methodBindingAnnotations.toArray(new Annotation[]{}));
@@ -518,7 +520,7 @@
       List<SerializableContextual> serializableContextuals = new ArrayList<SerializableContextual>();
       for (Interceptor<?> interceptor: interceptors)
       {
-         serializableContextuals.add(new SerializableContextual(interceptor));
+         serializableContextuals.add(new SerializableContextualImpl(interceptor));
       }
       return serializableContextuals.toArray(new SerializableContextual[]{});
    }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -49,7 +49,7 @@
 import org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler;
 import org.jboss.weld.bean.proxy.Marker;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
 import org.jboss.weld.ejb.InternalEjbDescriptor;
 import org.jboss.weld.ejb.api.SessionObjectReference;
 import org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor;

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -5,7 +5,7 @@
 import javax.enterprise.inject.spi.Interceptor;
 
 import org.jboss.interceptor.proxy.AbstractClassInterceptionHandler;
-import org.jboss.weld.context.SerializableContextualInstance;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
 
 /**
  * @author Marius Bogoevici

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -23,8 +23,8 @@
 import org.jboss.interceptor.proxy.InterceptionHandler;
 import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
 import org.jboss.weld.BeanManagerImpl;
-import org.jboss.weld.context.SerializableContextualInstance;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
 
 /**
  * @author Marius Bogoevici
@@ -45,10 +45,11 @@
       return manager;
    }
 
+   @SuppressWarnings("unchecked")
    public InterceptionHandler createFor(final SerializableContextual<Interceptor<Object>, Object> serializableContextual)
    {
       Object instance = getManager().getReference(serializableContextual.get(), creationalContext);
-      return new CdiInterceptorHandler(new SerializableContextualInstance<Interceptor<Object>, Object>(serializableContextual, instance, creationalContext),
+      return new CdiInterceptorHandler(new SerializableContextualInstanceImpl<Interceptor<Object>, Object>(serializableContextual, instance, creationalContext),
             serializableContextual.get().getBeanClass());
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -19,10 +19,6 @@
 
 import java.util.Collection;
 import java.util.List;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import java.util.Arrays;
 import java.util.ArrayList;
 import java.lang.reflect.Method;
 
@@ -30,7 +26,7 @@
 import javax.enterprise.inject.spi.InterceptionType;
 
 import org.jboss.weld.ejb.spi.InterceptorBindings;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
 import org.jboss.interceptor.model.InterceptionModel;
 
 /**

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -25,7 +25,7 @@
 import javassist.util.proxy.MethodHandler;
 
 import org.jboss.weld.bean.DecoratorImpl;
-import org.jboss.weld.context.SerializableContextualInstance;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
 import org.jboss.weld.introspector.MethodSignature;
 import org.jboss.weld.introspector.WeldMethod;
 import org.jboss.weld.introspector.jlr.MethodSignatureImpl;

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -26,7 +26,7 @@
 
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.Container;
-import org.jboss.weld.ContextualStore;
+import org.jboss.weld.ContextualStoreImpl;
 import org.jboss.weld.Validator;
 import org.jboss.weld.bean.builtin.ManagerBean;
 import org.jboss.weld.bootstrap.api.Bootstrap;
@@ -51,6 +51,7 @@
 import org.jboss.weld.context.SessionContext;
 import org.jboss.weld.context.SingletonContext;
 import org.jboss.weld.context.api.BeanStore;
+import org.jboss.weld.serialization.spi.ContextualStore;
 import org.jboss.weld.ejb.EJBApiAbstraction;
 import org.jboss.weld.ejb.EjbDescriptors;
 import org.jboss.weld.jsf.JsfApiAbstraction;
@@ -236,7 +237,7 @@
       services.add(TypeStore.class, new TypeStore());
       services.add(ClassTransformer.class, new ClassTransformer(services.get(TypeStore.class)));
       services.add(MetaAnnotationStore.class, new MetaAnnotationStore(services.get(ClassTransformer.class)));
-      services.add(ContextualStore.class, new ContextualStore());
+      services.add(ContextualStore.class, new ContextualStoreImpl());
       return services;
    }
    

Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -24,7 +24,7 @@
 import javax.enterprise.context.spi.CreationalContext;
 
 import org.jboss.weld.Container;
-import org.jboss.weld.ContextualStore;
+import org.jboss.weld.serialization.spi.ContextualStore;
 import org.jboss.weld.context.api.BeanStore;
 import org.jboss.weld.context.api.ContextualInstance;
 import org.jboss.weld.log.LogProvider;
@@ -76,13 +76,13 @@
       if (getBeanStore() == null)
       {
          return null;
-      }
+      }
       if (contextual == null)
       {
          throw new IllegalArgumentException("Must provide a contextual to get");
       }
       String id = getId(contextual);
-      ContextualInstance<T> beanInstance = getBeanStore().get(id);
+      ContextualInstance<T> beanInstance = getBeanStore().get(id);
       if (beanInstance != null)
       {
          return beanInstance.getInstance();
@@ -104,7 +104,7 @@
             T instance = contextual.create(creationalContext);
             if (instance != null)
             {
-               beanInstance = new SerializableContextualInstance<Contextual<T>, T>(contextual, instance, creationalContext);
+               beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext);
                getBeanStore().put(id, beanInstance);
             }
             return instance;
@@ -134,9 +134,9 @@
       if (getBeanStore() == null)
       {
          throw new IllegalStateException("No bean store available for " + toString());
-      }
+      }
       ContextualInstance<T> beanInstance = getBeanStore().get(id);
-      beanInstance.getContextual().destroy(beanInstance.getInstance(), beanInstance.getCreationalContext());
+      beanInstance.getContextual().destroy(beanInstance.getInstance(), beanInstance.getCreationalContext());
    }
    
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -62,8 +62,8 @@
          T instance = contextual.create(creationalContext);
          if (creationalContext instanceof WeldCreationalContext<?>)
          {
-            WeldCreationalContext<T> creationalContextImpl = (WeldCreationalContext<T>) creationalContext;
-            ContextualInstance<T> beanInstance = new SerializableContextualInstance<Contextual<T>, T>(contextual, instance, creationalContext);
+            WeldCreationalContext<T> creationalContextImpl = (WeldCreationalContext<T>) creationalContext;
+            ContextualInstance<T> beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext);
             creationalContextImpl.getParentDependentInstancesStore().addDependentInstance(beanInstance);
          }
          return instance;

Deleted: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -1,94 +0,0 @@
-package org.jboss.weld.context;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.spi.Contextual;
-
-import org.jboss.weld.Container;
-import org.jboss.weld.ContextualStore;
-
-/**
- * A serializable version of contextual that knows how to restore the
- * original bean if necessary
- * 
- * @author pmuir
- * 
- */
-public class SerializableContextual<C extends Contextual<I>, I> extends ForwardingContextual<I> implements Serializable
-{
-   
-   @Override
-   protected Contextual<I> delegate()
-   {
-      return get();
-   }
-
-   private static final long serialVersionUID = 9161034819867283482L;
-
-   // A directly serializable contextual
-   private C serialiazable;
-   
-   // A cached, transient version of the contextual
-   private transient C cached;
-   
-   // the id of a non-serializable, passivation capable contextual
-   private String id;
-   
-   public SerializableContextual(C contextual)
-   {
-      if (contextual instanceof Serializable)
-      {
-         // the contextual is serializable, so we can just use it
-         this.serialiazable = contextual;
-      }
-      else
-      {
-         // otherwise, generate an id (may not be portable between container instances
-         this.id = Container.instance().deploymentServices().get(ContextualStore.class).putIfAbsent(contextual);
-      }
-      // cache the contextual
-      this.cached = contextual;
-   }
-   
-   public C get()
-   {
-      if (cached == null)
-      {
-         loadContextual();
-      }
-      return cached;
-   }
-   
-   private void loadContextual()
-   {
-      if (serialiazable != null)
-      {
-         this.cached = serialiazable;
-      }
-      else if (id != null)
-      {
-         this.cached = Container.instance().deploymentServices().get(ContextualStore.class).<C, I>getContextual(id);
-      }
-   }
-   
-   @Override
-   public boolean equals(Object obj)
-   {
-      // if the arriving object is also a SerializableContextual, then unwrap it
-      if (obj instanceof SerializableContextual<?, ?>)
-      {
-         return delegate().equals(((SerializableContextual<?, ?>) obj).get());
-      }
-      else
-      {
-         return delegate().equals(obj);
-      }
-   }
-   
-   @Override
-   public int hashCode()
-   {
-      return delegate().hashCode();
-   }
-   
-}
\ No newline at end of file

Copied: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java (from rev 4215, core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -0,0 +1,95 @@
+package org.jboss.weld.context;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.spi.Contextual;
+
+import org.jboss.weld.Container;
+import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+
+/**
+ * A serializable version of contextual that knows how to restore the
+ * original bean if necessary
+ * 
+ * @author pmuir
+ * 
+ */
+public class SerializableContextualImpl<C extends Contextual<I>, I> extends ForwardingContextual<I> implements SerializableContextual<C, I>
+{
+
+   @Override
+   protected Contextual<I> delegate()
+   {
+      return get();
+   }
+
+   private static final long serialVersionUID = 9161034819867283482L;
+
+   // A directly serializable contextual
+   private C serialiazable;
+   
+   // A cached, transient version of the contextual
+   private transient C cached;
+   
+   // the id of a non-serializable, passivation capable contextual
+   private String id;
+   
+   public SerializableContextualImpl(C contextual)
+   {
+      if (contextual instanceof Serializable)
+      {
+         // the contextual is serializable, so we can just use it
+         this.serialiazable = contextual;
+      }
+      else
+      {
+         // otherwise, generate an id (may not be portable between container instances)
+         this.id = Container.instance().deploymentServices().get(ContextualStore.class).putIfAbsent(contextual);
+      }
+      // cache the contextual
+      this.cached = contextual;
+   }
+   
+   public C get()
+   {
+      if (cached == null)
+      {
+         loadContextual();
+      }
+      return cached;
+   }
+   
+   private void loadContextual()
+   {
+      if (serialiazable != null)
+      {
+         this.cached = serialiazable;
+      }
+      else if (id != null)
+      {
+         this.cached = Container.instance().deploymentServices().get(ContextualStore.class).<C, I>getContextual(id);
+      }
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      // if the arriving object is also a SerializableContextual, then unwrap it
+      if (obj instanceof SerializableContextualImpl<?, ?>)
+      {
+         return delegate().equals(((SerializableContextualImpl<?, ?>) obj).get());
+      }
+      else
+      {
+         return delegate().equals(obj);
+      }
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      return delegate().hashCode();
+   }
+   
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Deleted: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,  
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld.context;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-
-import org.jboss.weld.context.api.ContextualInstance;
-
-public class SerializableContextualInstance<C extends Contextual<I>, I> implements ContextualInstance<I>, Serializable
-{
-
-   private static final long serialVersionUID = -6366271037267396256L;
-
-   private final SerializableContextual<C, I> contextual;
-   private final I instance;
-   private final CreationalContext<I> creationalContext;
-
-   public SerializableContextualInstance(C contextual, I instance, CreationalContext<I> creationalContext)
-   {
-      this.contextual = new SerializableContextual<C, I>(contextual);
-      this.instance = instance;
-      this.creationalContext = creationalContext;
-   }
-
-   public SerializableContextualInstance(SerializableContextual<C, I> contextual, I instance, CreationalContext<I> creationalContext)
-   {
-      this.contextual = contextual;
-      this.instance = instance;
-      this.creationalContext = creationalContext;
-   }
-
-   public SerializableContextual<C, I> getContextual()
-   {
-      return contextual;
-   }
-
-   public I getInstance()
-   {
-      return instance;
-   }
-
-   public CreationalContext<I> getCreationalContext()
-   {
-      return creationalContext;
-   }
-
-   @Override
-   public String toString()
-   {
-      return "Bean: " + contextual + "; Instance: " + instance + "; CreationalContext: " + creationalContext;
-   }
-
-}

Copied: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java (from rev 4215, core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.context;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+
+public class SerializableContextualInstanceImpl<C extends Contextual<I>, I> implements SerializableContextualInstance<C,I>
+{
+
+   private static final long serialVersionUID = -6366271037267396256L;
+
+   private final SerializableContextual<C, I> contextual;
+   private final I instance;
+   private final CreationalContext<I> creationalContext;
+
+   public SerializableContextualInstanceImpl(C contextual, I instance, CreationalContext<I> creationalContext)
+   {
+      this.contextual = new SerializableContextualImpl<C, I>(contextual);
+      this.instance = instance;
+      this.creationalContext = creationalContext;
+   }
+
+   public SerializableContextualInstanceImpl(SerializableContextual<C, I> contextual, I instance, CreationalContext<I> creationalContext)
+   {
+      this.contextual = contextual;
+      this.instance = instance;
+      this.creationalContext = creationalContext;
+   }
+
+   public SerializableContextual<C, I> getContextual()
+   {
+      return contextual;
+   }
+
+   public I getInstance()
+   {
+      return instance;
+   }
+
+   public CreationalContext<I> getCreationalContext()
+   {
+      return creationalContext;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "Bean: " + contextual + "; Instance: " + instance + "; CreationalContext: " + creationalContext;
+   }
+
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java	2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java	2009-10-22 06:05:30 UTC (rev 4217)
@@ -5,7 +5,9 @@
 import javax.enterprise.inject.spi.Bean;
 
 import org.jboss.weld.BeanManagerImpl;
-import org.jboss.weld.ContextualStore;
+
+import org.jboss.weld.ContextualStoreImpl;
+import org.jboss.weld.serialization.spi.ContextualStore;
 import org.jboss.weld.bean.ManagedBean;
 import org.jboss.weld.bean.RIBean;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
@@ -32,7 +34,7 @@
       this.classTransformer = new ClassTransformer(new TypeStore());
       this.services = new SimpleServiceRegistry();
       this.services.add(MetaAnnotationStore.class, new MetaAnnotationStore(classTransformer));
-      this.services.add(ContextualStore.class, new ContextualStore());
+      this.services.add(ContextualStore.class, new ContextualStoreImpl());
    }
    
    private void addBean(BeanManagerImpl manager, Class<?> c)



More information about the weld-commits mailing list