Author: pete.muir(a)jboss.org
Date: 2009-09-29 15:33:18 -0400 (Tue, 29 Sep 2009)
New Revision: 3812
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ForwardingContextual.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextual.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextualInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/NamingScheme.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/AbstractClusterTest.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableMockEELifecycle.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableSingletonProvider.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Fodder.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Horse.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Stable.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/BeanStoreNamingScheme.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/PrefixBeanStoreNamingScheme.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/Container.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/AbstractBuiltInBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorFactoryBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ExtensionBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/InjectionPointBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ManagerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/PrincipalBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/AbstractFacadeBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/EventBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/InstanceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationBeanStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpRequestSessionBeanStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/SingletonProvider.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockDeployment.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockBeanDeploymentArchive.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/DefangedTarantula.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/Tarantula.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java
ri/trunk/tests/unit-tests.xml
Log:
WBRI-366, support for clustering, WBRI-398
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -55,10 +55,10 @@
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.PassivationCapable;
import javax.inject.Qualifier;
import org.jboss.webbeans.bean.DecoratorImpl;
-import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SessionBean;
import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
@@ -180,11 +180,8 @@
// Client proxies can be used application wide
private transient final ClientProxyProvider clientProxyProvider;
- // We want to generate unique id's across the whole deployment
- private transient final AtomicInteger ids;
-
// TODO review this structure
- private transient final Map<String, RIBean<?>> riBeans;
+ private transient final Map<String, Bean<?>> passivationCapableBeans;
// TODO review this structure
private transient final Map<EjbDescriptor<?>, SessionBean<?>>
enterpriseBeans;
@@ -249,7 +246,8 @@
*/
private transient final Set<BeanManagerImpl> childActivities;
- private final Integer id;
+ private final AtomicInteger childIds;
+ private final String id;
/*
* Runtime data transfer
@@ -263,7 +261,7 @@
* @param serviceRegistry
* @return
*/
- public static BeanManagerImpl newRootManager(ServiceRegistry serviceRegistry)
+ public static BeanManagerImpl newRootManager(String id, ServiceRegistry
serviceRegistry)
{
ListMultimap<Class<? extends Annotation>, Context> contexts =
Multimaps.newListMultimap(new ConcurrentHashMap<Class<? extends Annotation>,
Collection<Context>>(), new Supplier<List<Context>>()
{
@@ -282,7 +280,7 @@
new CopyOnWriteArrayList<ObserverMethod<?,?>>(),
new CopyOnWriteArrayList<String>(),
new ConcurrentHashMap<EjbDescriptor<?>, SessionBean<?>>(),
- new ConcurrentHashMap<String, RIBean<?>>(),
+ new ConcurrentHashMap<String, Bean<?>>(),
new ClientProxyProvider(),
contexts,
new CopyOnWriteArraySet<CurrentActivity>(),
@@ -290,6 +288,7 @@
new ArrayList<Class<?>>(),
new ArrayList<Class<? extends Annotation>>(),
new ArrayList<Class<?>>(),
+ id,
new AtomicInteger());
}
@@ -299,7 +298,7 @@
* @param serviceRegistry
* @return
*/
- public static BeanManagerImpl newManager(BeanManagerImpl rootManager, ServiceRegistry
services)
+ public static BeanManagerImpl newManager(BeanManagerImpl rootManager, String id,
ServiceRegistry services)
{
return new BeanManagerImpl(
services,
@@ -308,7 +307,7 @@
new CopyOnWriteArrayList<ObserverMethod<?,?>>(),
new CopyOnWriteArrayList<String>(),
rootManager.getEnterpriseBeans(),
- new ConcurrentHashMap<String, RIBean<?>>(),
+ new ConcurrentHashMap<String, Bean<?>>(),
rootManager.getClientProxyProvider(),
rootManager.getContexts(),
new CopyOnWriteArraySet<CurrentActivity>(),
@@ -316,7 +315,8 @@
new ArrayList<Class<?>>(),
new ArrayList<Class<? extends Annotation>>(),
new ArrayList<Class<?>>(),
- rootManager.getIds());
+ id,
+ new AtomicInteger());
}
/**
@@ -342,15 +342,16 @@
registeredObservers,
namespaces,
parentManager.getEnterpriseBeans(),
- parentManager.getRiBeans(),
+ parentManager.getPassivationCapableBeans(),
parentManager.getClientProxyProvider(),
parentManager.getContexts(),
parentManager.getCurrentActivities(),
parentManager.getSpecializedBeans(),
parentManager.getEnabledPolicyClasses(),
parentManager.getEnabledPolicyStereotypes(),
- parentManager.getEnabledDecoratorClasses(),
- parentManager.getIds());
+ parentManager.getEnabledDecoratorClasses(),
+ new
StringBuilder().append(parentManager.getChildIds().incrementAndGet()).toString(),
+ parentManager.getChildIds());
}
/**
@@ -366,7 +367,7 @@
List<ObserverMethod<?,?>> observers,
List<String> namespaces,
Map<EjbDescriptor<?>, SessionBean<?>> enterpriseBeans,
- Map<String, RIBean<?>> riBeans,
+ Map<String, Bean<?>> riBeans,
ClientProxyProvider clientProxyProvider,
ListMultimap<Class<? extends Annotation>, Context> contexts,
Set<CurrentActivity> currentActivities,
@@ -374,13 +375,14 @@
Collection<Class<?>> enabledPolicyClasses,
Collection<Class<? extends Annotation>> enabledPolicyStereotypes,
List<Class<?>> enabledDecoratorClasses,
- AtomicInteger ids)
+ String id,
+ AtomicInteger childIds)
{
this.services = serviceRegistry;
this.beans = beans;
this.decorators = decorators;
this.enterpriseBeans = enterpriseBeans;
- this.riBeans = riBeans;
+ this.passivationCapableBeans = riBeans;
this.clientProxyProvider = clientProxyProvider;
this.contexts = contexts;
this.currentActivities = currentActivities;
@@ -390,8 +392,8 @@
this.enabledPolicyStereotypes = enabledPolicyStereotypes;
setEnabledDecoratorClasses(enabledDecoratorClasses);
this.namespaces = namespaces;
- this.ids = ids;
- this.id = ids.incrementAndGet();
+ this.id = id;
+ this.childIds = new AtomicInteger();
// Set up the structure to store accessible managers in
this.accessibleManagers = new HashSet<BeanManagerImpl>();
@@ -531,10 +533,9 @@
SessionBean<?> enterpriseBean = (SessionBean<?>) bean;
enterpriseBeans.put(enterpriseBean.getEjbDescriptor(), enterpriseBean);
}
- if (bean instanceof RIBean<?>)
+ if (bean instanceof PassivationCapable)
{
- RIBean<?> riBean = (RIBean<?>) bean;
- riBeans.put(riBean.getId(), riBean);
+ passivationCapableBeans.put(((PassivationCapable) bean).getId(), bean);
}
registerBeanNamespace(bean);
for (BeanManagerImpl childActivity : childActivities)
@@ -548,7 +549,7 @@
public void addDecorator(DecoratorImpl<?> bean)
{
decorators.add(bean);
- riBeans.put(bean.getId(), bean);
+ passivationCapableBeans.put(bean.getId(), bean);
decoratorResolver.clear();
}
@@ -788,9 +789,9 @@
*
* @return
*/
- public Map<String, RIBean<?>> getRiBeans()
+ public Map<String, Bean<?>> getPassivationCapableBeans()
{
- return Collections.unmodifiableMap(riBeans);
+ return Collections.unmodifiableMap(passivationCapableBeans);
}
public void addContext(Context context)
@@ -1201,21 +1202,21 @@
return createDynamicAccessibleIterable(Transform.NAMESPACE);
}
- protected AtomicInteger getIds()
- {
- return ids;
- }
-
private Set<CurrentActivity> getCurrentActivities()
{
return currentActivities;
}
- public Integer getId()
+ public String getId()
{
return id;
}
+ public AtomicInteger getChildIds()
+ {
+ return childIds;
+ }
+
public List<ObserverMethod<?,?>> getObservers()
{
return observers;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/Container.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/Container.java 2009-09-29 19:11:54 UTC
(rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/Container.java 2009-09-29 19:33:18 UTC
(rev 3812)
@@ -68,8 +68,8 @@
// The deployment bean manager
private final BeanManagerImpl deploymentManager;
- // A map of managers keyed by ID, used for activities
- private final Map<Integer, BeanManagerImpl> activities;
+ // A map of managers keyed by ID, used for activities and serialization
+ private final Map<String, BeanManagerImpl> managers;
// A map of BDA -> bean managers
private final Map<BeanDeploymentArchive, BeanManagerImpl>
beanDeploymentArchives;
@@ -81,8 +81,8 @@
public Container(BeanManagerImpl deploymentManager, ServiceRegistry
deploymentServices)
{
this.deploymentManager = deploymentManager;
- this.activities = new ConcurrentHashMap<Integer, BeanManagerImpl>();
- this.activities.put(deploymentManager.getId(), deploymentManager);
+ this.managers = new ConcurrentHashMap<String, BeanManagerImpl>();
+ this.managers.put(deploymentManager.getId(), deploymentManager);
this.beanDeploymentArchives = new ConcurrentHashMap<BeanDeploymentArchive,
BeanManagerImpl>();
this.deploymentServices = deploymentServices;
}
@@ -94,7 +94,7 @@
public void cleanup()
{
// TODO We should probably cleanup the bean managers for activities?
- activities.clear();
+ managers.clear();
for (BeanManagerImpl beanManager : beanDeploymentArchives.values())
{
@@ -125,9 +125,9 @@
* @param key
* @return
*/
- public BeanManagerImpl activityManager(Integer key)
+ public BeanManagerImpl activityManager(String key)
{
- return activities.get(key);
+ return managers.get(key);
}
/**
@@ -136,10 +136,10 @@
* @param manager
* @return
*/
- public Integer addActivity(BeanManagerImpl manager)
+ public String addActivity(BeanManagerImpl manager)
{
- Integer id = manager.getId();
- activities.put(id, manager);
+ String id = manager.getId();
+ managers.put(id, manager);
return id;
}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.enterprise.context.spi.Contextual;
-
-import org.jboss.webbeans.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. 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 ContextualIdStore implements Service
-{
-
- private final BiMap<Contextual<?>, Integer> contextuals;
- private final AtomicInteger idGenerator;
-
- public ContextualIdStore()
- {
- this.idGenerator = new AtomicInteger(0);
- BiMap<Contextual<?>, Integer> map = HashBiMap.create();
- // TODO Somehow remove this sync if it shows bad in a profiler
- this.contextuals = Maps.synchronizedBiMap(map);
- }
-
- @SuppressWarnings("unchecked")
- public <T> Contextual<T> getContextual(Integer id)
- {
- return (Contextual<T>) contextuals.inverse().get(id);
- }
-
- public Integer getId(Contextual<?> contextual)
- {
- if (contextuals.containsKey(contextual))
- {
- return contextuals.get(contextual);
- }
- else
- {
- Integer id = idGenerator.incrementAndGet();
- contextuals.put(contextual, id);
- return id;
- }
- }
-
- public void cleanup()
- {
- contextuals.clear();
- }
-}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualStore.java (from rev
3781, ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualStore.java
(rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans;
+
+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.webbeans.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();
+ }
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/ContextualStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -101,9 +101,9 @@
*
* @param manager The Web Beans manager
*/
- public AbstractBean(BeanManagerImpl manager)
+ public AbstractBean(String idSuffix, BeanManagerImpl manager)
{
- super(manager);
+ super(idSuffix, manager);
this.manager = manager;
this.injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
this.delegateInjectionPoints = new HashSet<WBInjectionPoint<?,?>>();
@@ -456,18 +456,7 @@
_serializable = Reflections.isSerializable(type);
}
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
@Override
- public String toString()
- {
- return "AbstractBean " + getName();
- }
-
- @Override
public boolean isProxyable()
{
return proxyable;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -40,6 +40,7 @@
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bean.proxy.DecoratorProxyMethodHandler;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.context.SerializableContextualInstance;
import org.jboss.webbeans.injection.FieldInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
@@ -72,7 +73,6 @@
private List<Decorator<?>> decorators;
- private final String id;
private Class<T> proxyClassForDecorators;
private final ThreadLocal<Integer> decoratorStackPosition;
@@ -85,11 +85,10 @@
* @param type The type
* @param manager The Web Beans manager
*/
- protected AbstractClassBean(WBClass<T> type, BeanManagerImpl manager)
+ protected AbstractClassBean(WBClass<T> type, String idSuffix, BeanManagerImpl
manager)
{
- super(manager);
+ super(idSuffix, manager);
this.annotatedItem = type;
- this.id = createId(getClass().getSimpleName() + "-" + type.getName());
this.decoratorStackPosition = new ThreadLocal<Integer>()
{
@@ -150,7 +149,7 @@
protected T applyDecorators(T instance, CreationalContext<T> creationalContext,
InjectionPoint originalInjectionPoint)
{
- List<SerializableBeanInstance<DecoratorImpl<Object>, Object>>
decoratorInstances = new
ArrayList<SerializableBeanInstance<DecoratorImpl<Object>,Object>>();
+ List<SerializableContextualInstance<DecoratorImpl<Object>,
Object>> decoratorInstances = new
ArrayList<SerializableContextualInstance<DecoratorImpl<Object>,Object>>();
InjectionPoint ip = originalInjectionPoint;
boolean outside = decoratorStackPosition.get().intValue() == 0;
try
@@ -167,7 +166,7 @@
DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>)
decorator;
Object decoratorInstance = getManager().getReference(ip, decorator,
creationalContext);
- decoratorInstances.add(new
SerializableBeanInstance<DecoratorImpl<Object>, Object>(decoratorBean,
decoratorInstance));
+ decoratorInstances.add(new
SerializableContextualInstance<DecoratorImpl<Object>, Object>(decoratorBean,
decoratorInstance, null));
ip = decoratorBean.getDelegateInjectionPoint();
}
else
@@ -340,23 +339,6 @@
return dependencies;
}
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return "AbstractClassBean " + getName();
- }
-
- @Override
- public String getId()
- {
- return id;
- }
-
public void postConstruct(T instance)
{
WBMethod<?, ?> postConstruct = getPostConstruct();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -63,13 +63,12 @@
/**
* Constructor
- *
* @param declaringBean The declaring bean
* @param manager The Web Beans manager
*/
- public AbstractProducerBean(AbstractClassBean<?> declaringBean, BeanManagerImpl
manager)
+ public AbstractProducerBean(String idSuffix, AbstractClassBean<?> declaringBean,
BeanManagerImpl manager)
{
- super(declaringBean, manager);
+ super(idSuffix, declaringBean, manager);
}
@Override
@@ -294,7 +293,7 @@
* @return The string representation
*/
@Override
- public String toString()
+ public String getDescription()
{
StringBuilder buffer = new StringBuilder();
buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -24,6 +24,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.WBCreationalContext;
+import org.jboss.webbeans.introspector.WBMember;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -39,9 +40,9 @@
private AbstractClassBean<?> declaringBean;
private boolean policy;
- public AbstractReceiverBean(AbstractClassBean<?> declaringBean, BeanManagerImpl
manager)
+ public AbstractReceiverBean(String idSuffix, AbstractClassBean<?> declaringBean,
BeanManagerImpl manager)
{
- super(manager);
+ super(idSuffix, manager);
this.declaringBean = declaringBean;
}
@@ -116,5 +117,8 @@
this.policy = true;
}
}
+
+ @Override
+ protected abstract WBMember<T, ?, S> getAnnotatedItem();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -84,7 +84,7 @@
protected DecoratorImpl(WBClass<T> type, BeanManagerImpl manager)
{
- super(type, manager);
+ super(type, new
StringBuilder().append(Decorator.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(type.getName()).toString(),
manager);
}
@Override
@@ -215,14 +215,11 @@
// No-op, decorators can't have decorators
}
- /* (non-Javadoc)
- * @see org.jboss.webbeans.bean.SimpleBean#toString()
- */
@Override
- public String toString()
+ public String getDescription()
{
// TODO Auto-generated method stub
- return super.toString("decorator");
+ return super.getDescription("decorator");
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -39,13 +39,11 @@
{
protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
- private final String id;
protected DisposalMethod(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod,
AbstractClassBean<?> declaringBean)
{
- super(declaringBean, manager);
+ super(new
StringBuilder().append(DisposalMethod.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(declaringBean.getAnnotatedItem().getName()).append(disposalMethod.getSignature().toString()).toString(),
declaringBean, manager);
this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
- this.id = createId("DisposalMethod-" + declaringBean.getName() +
"-" + disposalMethod.getSignature().toString());
initBindings();
initType();
initTypes();
@@ -119,7 +117,7 @@
}
@Override
- public String toString()
+ public String getDescription()
{
return disposalMethodInjectionPoint.toString();
}
@@ -232,12 +230,6 @@
}
@Override
- public String getId()
- {
- return id;
- }
-
- @Override
public AbstractBean<?, ?> getSpecializedBean()
{
// Doesn't support specialization
@@ -250,6 +242,7 @@
// Disposal methods aren't scoped
}
+ @Override
public Set<Class<? extends Annotation>> getStereotypes()
{
return Collections.emptySet();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -74,7 +74,7 @@
*/
public static <T> ManagedBean<T> of(WBClass<T> clazz,
BeanManagerImpl manager)
{
- return new ManagedBean<T>(clazz, manager);
+ return new ManagedBean<T>(clazz, new
StringBuilder().append(ManagedBean.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(clazz.getName()).toString(),
manager);
}
/**
@@ -83,9 +83,9 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected ManagedBean(WBClass<T> type, BeanManagerImpl manager)
+ protected ManagedBean(WBClass<T> type, String idSuffix, BeanManagerImpl
manager)
{
- super(type, manager);
+ super(type, idSuffix, manager);
initType();
initTypes();
initBindings();
@@ -202,6 +202,7 @@
/**
* Validates the type
*/
+ @Override
protected void checkType()
{
if (getAnnotatedItem().isNonStaticMemberClass())
@@ -328,12 +329,12 @@
* @return The string representation
*/
@Override
- public String toString()
+ public String getDescription()
{
- return toString("simple bean");
+ return getDescription("simple bean");
}
- protected String toString(String beanType)
+ protected String getDescription(String beanType)
{
StringBuilder buffer = new StringBuilder();
buffer.append(Names.scopeTypeToString(getScope()));
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -43,7 +43,7 @@
*/
public static <T> NewManagedBean<T> of(WBClass<T> clazz,
BeanManagerImpl manager)
{
- return new NewManagedBean<T>(clazz, manager);
+ return new NewManagedBean<T>(clazz, new
StringBuilder().append(NewManagedBean.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(clazz.getName()).toString(),
manager);
}
private Set<Annotation> bindings;
@@ -54,13 +54,14 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewManagedBean(final WBClass<T> type, BeanManagerImpl manager)
+ protected NewManagedBean(final WBClass<T> type, String idSuffix, BeanManagerImpl
manager)
{
- super(type, manager);
+ super(type, idSuffix, manager);
this.bindings = new HashSet<Annotation>();
this.bindings.add(new NewLiteral()
{
+ @Override
public Class<?> value()
{
return type.getJavaClass();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -46,7 +46,7 @@
public static <T> NewSessionBean<T> of(InternalEjbDescriptor<T>
ejbDescriptor, BeanManagerImpl manager)
{
WBClass<T> type =
manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
- return new NewSessionBean<T>(type, ejbDescriptor, manager);
+ return new NewSessionBean<T>(type, ejbDescriptor, new
StringBuilder().append(NewSessionBean.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(ejbDescriptor.getEjbName()).toString(),
manager);
}
private Set<Annotation> bindings;
@@ -57,13 +57,14 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewSessionBean(final WBClass<T> type, InternalEjbDescriptor<T>
ejbDescriptor, BeanManagerImpl manager)
+ protected NewSessionBean(final WBClass<T> type, InternalEjbDescriptor<T>
ejbDescriptor, String idSuffix, BeanManagerImpl manager)
{
- super(type, ejbDescriptor, manager);
+ super(type, ejbDescriptor, idSuffix, manager);
this.bindings = new HashSet<Annotation>();
this.bindings.add(new NewLiteral()
{
+ @Override
public Class<?> value()
{
return type.getJavaClass();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -63,12 +63,12 @@
*/
protected ProducerField(WBField<T, ?> field, AbstractClassBean<?>
declaringBean, BeanManagerImpl manager)
{
- super(declaringBean, manager);
+ super(new
StringBuilder().append(ProducerField.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(declaringBean.getAnnotatedItem().getName()).append(field.getName()).toString(),
declaringBean, manager);
this.field = field;
initType();
initTypes();
initBindings();
- this.id = createId("ProducerField-" + declaringBean.getType().getName() +
"-"+ field.getName());
+ this.id = new
StringBuilder().append(BEAN_ID_PREFIX).append(getClass().getSimpleName()).append(BEAN_ID_SEPARATOR).append(declaringBean.getAnnotatedItem().getName()).append(getAnnotatedItem().getName()).toString();
initStereotypes();
initPolicy();
}
@@ -126,7 +126,7 @@
* @return The string representation
*/
@Override
- public String toString()
+ public String getDescription()
{
StringBuilder buffer = new StringBuilder();
buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
@@ -160,6 +160,7 @@
return id;
}
+ @Override
public Set<Class<? extends Annotation>> getStereotypes()
{
return Collections.emptySet();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -69,12 +69,12 @@
protected ProducerMethod(WBMethod<T, ?> method, AbstractClassBean<?>
declaringBean, BeanManagerImpl manager)
{
- super(declaringBean, manager);
+ super(new
StringBuilder().append(ProducerMethod.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(declaringBean.getAnnotatedItem().getName()).append(method.getSignature().toString()).toString(),
declaringBean, manager);
this.method = MethodInjectionPoint.of(this, method);
initType();
initTypes();
initBindings();
- this.id = createId("ProducerMethod-" + declaringBean.getType().getName()
+ "-" + method.getSignature().toString());
+ this.id = new
StringBuilder().append(BEAN_ID_PREFIX).append(getClass().getSimpleName()).append(BEAN_ID_SEPARATOR).append(declaringBean.getAnnotatedItem().getName()).append(getAnnotatedItem().getSignature().toString()).toString();
initStereotypes();
initPolicy();
}
@@ -237,7 +237,7 @@
* @return The string representation
*/
@Override
- public String toString()
+ public String getDescription()
{
StringBuilder buffer = new StringBuilder();
buffer.append(Names.scopeTypeToString(getScope()));
@@ -285,6 +285,7 @@
return id;
}
+ @Override
public Set<Class<? extends Annotation>> getStereotypes()
{
return Collections.emptySet();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-09-29 19:11:54
UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-09-29 19:33:18
UTC (rev 3812)
@@ -17,13 +17,11 @@
package org.jboss.webbeans.bean;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
@@ -34,25 +32,22 @@
*
* @author Pete Muir
*/
-public abstract class RIBean<T> implements Bean<T>
+public abstract class RIBean<T> implements Bean<T>, PassivationCapable
{
- private static final ConcurrentMap<String, AtomicInteger> ids = new
ConcurrentHashMap<String, AtomicInteger>();
+ public static final String BEAN_ID_PREFIX = RIBean.class.getPackage().getName();
+ public static final String BEAN_ID_SEPARATOR = "-";
+
private final BeanManagerImpl manager;
+
+ private final String id;
- protected RIBean(BeanManagerImpl manager)
+ protected RIBean(String idSuffix, BeanManagerImpl manager)
{
this.manager = manager;
- // TODO better ID strategy (human readable)
+ this.id = new
StringBuilder().append(BEAN_ID_PREFIX).append(BEAN_ID_SEPARATOR).append(manager.getId()).append(BEAN_ID_SEPARATOR).append(idSuffix).toString();
}
-
- protected static String createId(String prefix)
- {
- ids.putIfAbsent(prefix, new AtomicInteger());
- int i = ids.get(prefix).getAndIncrement();
- return prefix + "-" + i;
- }
protected BeanManagerImpl getManager()
{
@@ -88,12 +83,10 @@
public abstract RIBean<?> getSpecializedBean();
- public abstract String getId();
-
@Override
public boolean equals(Object obj)
{
- if (obj instanceof RIBean)
+ if (obj instanceof RIBean<?>)
{
RIBean<?> that = (RIBean<?>) obj;
return this.getId().equals(that.getId());
@@ -109,5 +102,19 @@
{
return getId().hashCode();
}
+
+ public String getId()
+ {
+ return id;
+ }
+
+ @Override
+ public String toString()
+ {
+ return id;
+ }
+
+ public abstract String getDescription();
+
}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.bean;
-
-import java.io.Serializable;
-
-import org.jboss.webbeans.BeanManagerImpl;
-
-public class SerializableBeanInstance<T extends RIBean<I>, I> implements
Serializable
-{
-
- private static final long serialVersionUID = 7341389081613003687L;
-
- private final BeanManagerImpl manager;
- private final String beanId;
- private final I instance;
-
- public SerializableBeanInstance(T bean, I instance)
- {
- this.manager = bean.getManager();
- this.beanId = bean.getId();
- this.instance = instance;
- }
-
- @SuppressWarnings("unchecked")
- public T getBean()
- {
- return (T) manager.getRiBeans().get(beanId);
- }
-
- protected BeanManagerImpl getManager()
- {
- return manager;
- }
-
- protected String getBeanId()
- {
- return beanId;
- }
-
- public I getInstance()
- {
- return instance;
- }
-
-}
\ No newline at end of file
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -84,7 +84,7 @@
public static <T> SessionBean<T> of(InternalEjbDescriptor<T>
ejbDescriptor, BeanManagerImpl manager)
{
WBClass<T> type =
manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
- return new SessionBean<T>(type, ejbDescriptor, manager);
+ return new SessionBean<T>(type, ejbDescriptor, new
StringBuilder().append(SessionBean.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(ejbDescriptor.getEjbName()).toString(),
manager);
}
/**
@@ -93,9 +93,9 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected SessionBean(WBClass<T> type, InternalEjbDescriptor<T>
ejbDescriptor, BeanManagerImpl manager)
+ protected SessionBean(WBClass<T> type, InternalEjbDescriptor<T>
ejbDescriptor, String idSuffix, BeanManagerImpl manager)
{
- super(type, manager);
+ super(type, idSuffix, manager);
initType();
this.ejbDescriptor = ejbDescriptor;
initTypes();
@@ -294,7 +294,7 @@
* @return The string representation
*/
@Override
- public String toString()
+ public String getDescription()
{
StringBuilder buffer = new StringBuilder();
// buffer.append("Annotated " + Names.scopeTypeToString(getScopeType())
+
@@ -393,6 +393,7 @@
return
manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
}
+ @Override
public Set<Class<? extends Annotation>> getStereotypes()
{
return Collections.emptySet();
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/AbstractBuiltInBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/AbstractBuiltInBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/AbstractBuiltInBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -34,15 +34,14 @@
public abstract class AbstractBuiltInBean<T> extends RIBean<T>
{
+ private static final String ID_PREFIX = "Built-in";
+
private static final Annotation[] DEFAULT_BINDING_ARRAY = { new DefaultLiteral(), new
AnyLiteral() };
private static final Set<Annotation> DEFAULT_BINDING = new
HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
- private final String id;
-
- protected AbstractBuiltInBean(BeanManagerImpl manager)
+ protected AbstractBuiltInBean(String idSuffix, BeanManagerImpl manager)
{
- super(manager);
- this.id = createId(getClass().getSimpleName());
+ super(new
StringBuilder().append(ID_PREFIX).append(BEAN_ID_SEPARATOR).append(idSuffix).toString(),
manager);
}
@Override
@@ -113,9 +112,9 @@
}
@Override
- public String getId()
+ public String getDescription()
{
- return id;
+ return "Built-in bean " + getClass().getSimpleName();
}
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -37,7 +37,7 @@
public DefaultValidatorBean(BeanManagerImpl manager)
{
- super(manager);
+ super(Validator.class.getSimpleName(), manager);
}
@Override
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorFactoryBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorFactoryBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/DefaultValidatorFactoryBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -37,7 +37,7 @@
public DefaultValidatorFactoryBean(BeanManagerImpl manager)
{
- super(manager);
+ super(ValidatorFactory.class.getSimpleName(), manager);
}
@Override
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ExtensionBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ExtensionBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ExtensionBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -34,12 +34,14 @@
public class ExtensionBean extends AbstractBuiltInBean<Extension>
{
+ private static final String ID_PREFIX = "Extension";
+
private final WBClass<Extension> clazz;
private final Extension instance;
public ExtensionBean(BeanManagerImpl manager, WBClass<Extension> clazz,
Extension instance)
{
- super(manager);
+ super(new
StringBuilder().append(ID_PREFIX).append(BEAN_ID_SEPARATOR).append(clazz.getName()).toString(),
manager);
this.clazz = clazz;
this.instance = instance;
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/InjectionPointBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/InjectionPointBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/InjectionPointBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -47,7 +47,7 @@
*/
public InjectionPointBean(BeanManagerImpl manager)
{
- super(manager);
+ super(InjectionPoint.class.getSimpleName(), manager);
}
public InjectionPoint create(CreationalContext<InjectionPoint>
creationalContext)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ManagerBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ManagerBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/ManagerBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -32,7 +32,7 @@
public ManagerBean(BeanManagerImpl manager)
{
- super(manager);
+ super(BeanManager.class.getSimpleName(), manager);
}
public BeanManagerImpl create(CreationalContext<BeanManagerImpl>
creationalContext)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/PrincipalBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/PrincipalBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/PrincipalBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -37,7 +37,7 @@
public PrincipalBean(BeanManagerImpl manager)
{
- super(manager);
+ super(Principal.class.getSimpleName(), manager);
}
@Override
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/UserTransactionBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -37,7 +37,7 @@
public UserTransactionBean(BeanManagerImpl manager)
{
- super(manager);
+ super(UserTransaction.class.getSimpleName(), manager);
}
@Override
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/AbstractFacadeBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/AbstractFacadeBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/AbstractFacadeBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -34,9 +34,9 @@
private static final Log log = Logging.getLog(AbstractFacadeBean.class);
- protected AbstractFacadeBean(BeanManagerImpl manager)
+ protected AbstractFacadeBean(String idSuffix, BeanManagerImpl manager)
{
- super(manager);
+ super(idSuffix, manager);
}
public T create(CreationalContext<T> creationalContext)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/EventBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/EventBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/EventBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -42,7 +42,7 @@
public EventBean(BeanManagerImpl manager)
{
- super(manager);
+ super(Event.class.getSimpleName(), manager);
}
@Override
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/InstanceBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/InstanceBean.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/builtin/facade/InstanceBean.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -42,7 +42,7 @@
public InstanceBean(BeanManagerImpl manager)
{
- super(manager);
+ super(Instance.class.getSimpleName(), manager);
}
@Override
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -25,7 +25,7 @@
import javassist.util.proxy.MethodHandler;
import org.jboss.webbeans.bean.DecoratorImpl;
-import org.jboss.webbeans.bean.SerializableBeanInstance;
+import org.jboss.webbeans.context.SerializableContextualInstance;
import org.jboss.webbeans.introspector.MethodSignature;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.introspector.jlr.MethodSignatureImpl;
@@ -40,7 +40,7 @@
{
private static final long serialVersionUID = 4577632640130385060L;
- private final List<SerializableBeanInstance<DecoratorImpl<Object>,
Object>> decoratorInstances;
+ private final List<SerializableContextualInstance<DecoratorImpl<Object>,
Object>> decoratorInstances;
private final Object instance;
@@ -51,7 +51,7 @@
*
* @param proxy The generic proxy
*/
- public
DecoratorProxyMethodHandler(List<SerializableBeanInstance<DecoratorImpl<Object>,
Object>> decoratorInstances, Object instance)
+ public
DecoratorProxyMethodHandler(List<SerializableContextualInstance<DecoratorImpl<Object>,
Object>> decoratorInstances, Object instance)
{
this.decoratorInstances = decoratorInstances;
this.instance = instance;
@@ -77,9 +77,9 @@
public Object invoke(Object self, Method method, Method proceed, Object[] args) throws
Throwable
{
MethodSignature methodSignature = new MethodSignatureImpl(method);
- for (SerializableBeanInstance<DecoratorImpl<Object>, Object>
beanInstance : decoratorInstances)
+ for (SerializableContextualInstance<DecoratorImpl<Object>, Object>
beanInstance : decoratorInstances)
{
- WBMethod<?, ?> decoratorMethod =
beanInstance.getBean().getAnnotatedItem().getWBMethod(methodSignature);
+ WBMethod<?, ?> decoratorMethod =
beanInstance.getContextual().get().getAnnotatedItem().getWBMethod(methodSignature);
if (decoratorMethod != null)
{
return decoratorMethod.invokeOnInstance(beanInstance.getInstance(), args);
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -51,6 +51,7 @@
private final Class<?> objectInterface;
private final Collection<MethodSignature> removeMethodSignatures;
private final boolean clientCanCallRemoveMethods;
+ private final boolean stateful;
/**
* Constructor
@@ -65,6 +66,7 @@
this.removeMethodSignatures = bean.getEjbDescriptor().getRemoveMethodSignatures();
this.clientCanCallRemoveMethods = bean.isClientCanCallRemoveMethods();
this.reference = bean.createReference();
+ this.stateful = bean.getEjbDescriptor().isStateful();
log.trace("Created enterprise bean proxy method handler for " + bean);
}
@@ -93,7 +95,10 @@
}
if ("destroy".equals(method.getName()) && Marker.isMarker(0,
method, args))
{
- reference.remove();
+ if (stateful)
+ {
+ reference.remove();
+ }
return null;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -66,7 +66,7 @@
ServiceRegistry services = new SimpleServiceRegistry();
services.addAll(deploymentServices.entrySet());
services.addAll(beanDeploymentArchive.getServices().entrySet());
- this.beanManager = BeanManagerImpl.newManager(deploymentManager, services);
+ this.beanManager = BeanManagerImpl.newManager(deploymentManager,
beanDeploymentArchive.getId(), services);
if (beanManager.getServices().contains(EjbServices.class))
{
// Must populate EJB cache first, as we need it to detect whether a
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -28,7 +28,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.Container;
-import org.jboss.webbeans.ContextualIdStore;
+import org.jboss.webbeans.ContextualStore;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.DeploymentException;
import org.jboss.webbeans.Validator;
@@ -191,7 +191,7 @@
deploymentServices.add(TypeStore.class,
implementationServices.get(TypeStore.class));
this.environment = environment;
- this.deploymentManager = BeanManagerImpl.newRootManager(deploymentServices);
+ this.deploymentManager = BeanManagerImpl.newRootManager("deployment",
deploymentServices);
Container.initialize(deploymentManager,
ServiceRegistries.unmodifiableServiceRegistry(deployment.getServices()));
@@ -221,7 +221,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(ContextualIdStore.class, new ContextualIdStore());
+ services.add(ContextualStore.class, new ContextualStore());
return services;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -23,6 +23,8 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
+import org.jboss.webbeans.Container;
+import org.jboss.webbeans.ContextualStore;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.log.LogProvider;
@@ -74,8 +76,13 @@
if (getBeanStore() == null)
{
throw new IllegalStateException("No bean store available for " +
toString());
+ }
+ if (contextual == null)
+ {
+ throw new IllegalArgumentException("Must provide a contextual to
get");
}
- ContextualInstance<T> beanInstance = getBeanStore().get(contextual);
+ String id = getId(contextual);
+ ContextualInstance<T> beanInstance = getBeanStore().get(id);
if (beanInstance != null)
{
return beanInstance.getInstance();
@@ -88,7 +95,7 @@
if(needCreationLock)
{
creationLock.lock();
- beanInstance = getBeanStore().get(contextual);
+ beanInstance = getBeanStore().get(id);
if (beanInstance != null)
{
return beanInstance.getInstance();
@@ -97,8 +104,8 @@
T instance = contextual.create(creationalContext);
if (instance != null)
{
- beanInstance = new BeanInstanceImpl<T>(contextual, instance,
creationalContext);
- getBeanStore().put(beanInstance);
+ beanInstance = new SerializableContextualInstance<Contextual<T>,
T>(contextual, instance, creationalContext);
+ getBeanStore().put(id, beanInstance);
}
return instance;
}
@@ -121,15 +128,15 @@
return get(contextual, null);
}
- private <T> void destroy(Contextual<T> contextual)
+ private <T> void destroy(String id)
{
- log.trace("Destroying " + contextual);
+ log.trace("Destroying " + id);
if (getBeanStore() == null)
{
throw new IllegalStateException("No bean store available for " +
toString());
- }
- ContextualInstance<T> beanInstance = getBeanStore().get(contextual);
- contextual.destroy(beanInstance.getInstance(),
beanInstance.getCreationalContext());
+ }
+ ContextualInstance<T> beanInstance = getBeanStore().get(id);
+ beanInstance.getContextual().destroy(beanInstance.getInstance(),
beanInstance.getCreationalContext());
}
@@ -143,9 +150,9 @@
{
throw new IllegalStateException("No bean store available for " +
toString());
}
- for (Contextual<? extends Object> bean : getBeanStore().getContextuals())
+ for (String id : getBeanStore().getContextualIds())
{
- destroy(bean);
+ destroy(id);
}
getBeanStore().clear();
}
@@ -173,4 +180,14 @@
}
}
+ protected static <T> Contextual<T> getContextual(String id)
+ {
+ return
Container.instance().deploymentServices().get(ContextualStore.class).<Contextual<T>,
T>getContextual(id);
+ }
+
+ protected static String getId(Contextual<?> contextual)
+ {
+ return
Container.instance().deploymentServices().get(ContextualStore.class).putIfAbsent(contextual);
+ }
+
}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.context;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-
-import org.jboss.webbeans.context.api.ContextualInstance;
-
-public class BeanInstanceImpl<T> implements ContextualInstance<T>
-{
-
- private final Contextual<T> contextual;
- private final T instance;
- private final CreationalContext<T> creationalContext;
-
- public BeanInstanceImpl(Contextual<T> contextual, T instance,
CreationalContext<T> creationalContext)
- {
- this.contextual = contextual;
- this.instance = instance;
- this.creationalContext = creationalContext;
- }
-
- public Contextual<T> getContextual()
- {
- return contextual;
- }
-
- public T getInstance()
- {
- return instance;
- }
-
- public CreationalContext<T> getCreationalContext()
- {
- return creationalContext;
- }
-
- @Override
- public String toString()
- {
- return "Bean: " + contextual + "; Instance: " + instance +
"; CreationalContext: " + creationalContext;
- }
-
-}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -16,18 +16,22 @@
*/
package org.jboss.webbeans.context;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-public class CreationalContextImpl<T> implements CreationalContext<T>,
WBCreationalContext<T>
+public class CreationalContextImpl<T> implements CreationalContext<T>,
WBCreationalContext<T>, Serializable
{
- private final Map<Contextual<?>, Object> incompleteInstances;
- private final Contextual<T> contextual;
+ private static final long serialVersionUID = 7375854583908262422L;
+ // Only needed for creation, by the time it's serialized we don't need it
+ private final transient Map<Contextual<?>, Object> incompleteInstances;
+ private final transient Contextual<T> contextual;
+
private final DependentInstancesStore dependentInstancesStore;
private final DependentInstancesStore parentDependentInstancesStore;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -62,8 +62,8 @@
T instance = contextual.create(creationalContext);
if (creationalContext instanceof WBCreationalContext<?>)
{
- WBCreationalContext<T> creationalContextImpl =
(WBCreationalContext<T>) creationalContext;
- ContextualInstance<T> beanInstance = new
BeanInstanceImpl<T>(contextual, instance, creationalContext);
+ WBCreationalContext<T> creationalContextImpl =
(WBCreationalContext<T>) creationalContext;
+ ContextualInstance<T> beanInstance = new
SerializableContextualInstance<Contextual<T>, T>(contextual, instance,
creationalContext);
creationalContextImpl.getParentDependentInstancesStore().addDependentInstance(beanInstance);
}
return instance;
@@ -91,6 +91,7 @@
return true;
}
+ @Override
public void cleanup() {}
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.context;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -29,8 +30,10 @@
*
* @author Nicklas Karlsson
*/
-public class DependentInstancesStore
+public class DependentInstancesStore implements Serializable
{
+ private static final long serialVersionUID = -2349574791148336833L;
+
private static Log log = Logging.getLog(DependentInstancesStore.class);
// A object -> List of contextual instances mapping
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ForwardingContextual.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ForwardingContextual.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ForwardingContextual.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,40 @@
+package org.jboss.webbeans.context;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+public abstract class ForwardingContextual<T> implements Contextual<T>
+{
+
+ protected abstract Contextual<T> delegate();
+
+ public T create(CreationalContext<T> creationalContext)
+ {
+ return delegate().create(creationalContext);
+ }
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ delegate().destroy(instance, creationalContext);
+ }
+
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return this == obj || delegate().equals(obj);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate().toString();
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ForwardingContextual.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextual.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextual.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextual.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,94 @@
+package org.jboss.webbeans.context;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.spi.Contextual;
+
+import org.jboss.webbeans.Container;
+import org.jboss.webbeans.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
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextual.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextualInstance.java
(from rev 3781,
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java)
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextualInstance.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextualInstance.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.context;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.webbeans.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 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:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/SerializableContextualInstance.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -21,10 +21,6 @@
import java.util.Enumeration;
import java.util.List;
-import javax.enterprise.context.spi.Contextual;
-
-import org.jboss.webbeans.Container;
-import org.jboss.webbeans.ContextualIdStore;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.log.LogProvider;
@@ -50,32 +46,15 @@
* @return The instance
*/
@SuppressWarnings("unchecked")
- public <T> ContextualInstance<T> get(Contextual<? extends T>
contextual)
+ public <T> ContextualInstance<T> get(String id)
{
- Integer contextualId =
Container.instance().deploymentServices().get(ContextualIdStore.class).getId(contextual);
- String key = getNamingScheme().getKeyFromId(contextualId);
+ String key = getNamingScheme().getKey(id);
ContextualInstance<T> instance = (ContextualInstance<T>)
getAttribute(key);
log.trace("Looked for " + key + " and got " + instance);
return instance;
}
/**
- * Removes an instance from the store
- *
- * @param contextual The bean of the instance to remove
- * @return The removed instance
- */
- public <T> T remove(Contextual<? extends T> contextual)
- {
- Integer contextualId =
Container.instance().deploymentServices().get(ContextualIdStore.class).getId(contextual);
- T instance = get(contextual).getInstance();
- String key = getNamingScheme().getKeyFromId(contextualId);
- removeAttribute(key);
- log.trace("Removed bean under key " + key);
- return instance;
- }
-
- /**
* Clears the bean store
*/
public void clear()
@@ -92,15 +71,14 @@
*
* @return The beans
*/
- public Collection<Contextual<? extends Object>> getContextuals()
+ public Collection<String> getContextualIds()
{
- List<Contextual<?>> contextuals = new
ArrayList<Contextual<?>>();
- BeanStoreNamingScheme namingScheme = getNamingScheme();
+ List<String> contextuals = new ArrayList<String>();
+ NamingScheme namingScheme = getNamingScheme();
for (String attributeName : getFilteredAttributeNames())
{
- Integer id = namingScheme.getIdFromKey(attributeName);
- Contextual<?> contextual =
Container.instance().deploymentServices().get(ContextualIdStore.class).getContextual(id);
- contextuals.add(contextual);
+ String id = namingScheme.getId(attributeName);
+ contextuals.add(id);
}
return contextuals;
}
@@ -113,7 +91,7 @@
private List<String> getFilteredAttributeNames()
{
List<String> attributeNames = new ArrayList<String>();
- BeanStoreNamingScheme namingScheme = getNamingScheme();
+ NamingScheme namingScheme = getNamingScheme();
for (String attributeName : new
EnumerationList<String>(getAttributeNames()))
{
if (namingScheme.acceptKey(attributeName))
@@ -131,10 +109,9 @@
* @param instance The instance
* @return The instance added
*/
- public <T> void put(ContextualInstance<T> beanInstance)
+ public <T> void put(String id, ContextualInstance<T> beanInstance)
{
- Integer contextualId =
Container.instance().deploymentServices().get(ContextualIdStore.class).getId(beanInstance.getContextual());
- String key = getNamingScheme().getKeyFromId(contextualId);
+ String key = getNamingScheme().getKey(id);
setAttribute(key, beanInstance);
log.trace("Added Contextual type " + beanInstance.getContextual() +
" under key " + key);
}
@@ -175,12 +152,12 @@
*
* @return The naming scheme
*/
- protected abstract BeanStoreNamingScheme getNamingScheme();
+ protected abstract NamingScheme getNamingScheme();
@Override
public String toString()
{
- return "holding " + Names.count(getContextuals()) + "
instances";
+ return "holding " + Names.count(getContextualIds()) + "
instances";
}
}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/BeanStoreNamingScheme.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/BeanStoreNamingScheme.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/BeanStoreNamingScheme.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.context.beanstore;
-
-
-/**
- * Interface against a BeanStore to handle different naming schemes
- *
- * @author Nicklas Karlsson
- *
- */
-public interface BeanStoreNamingScheme
-{
- /**
- * Checks if a key is handled by the bean store
- *
- * @param key The key to match
- * @return True if match, false otherwise
- */
- public abstract boolean acceptKey(String key);
-
- /**
- * Gets a bean store key for a contextual
- *
- * @param contextual The contextual to make the key for
- * @return A map key
- */
- public abstract String getKeyFromId(Integer id);
-
- /**
- * Gets a contextual id from a key
- *
- * @param key The key to parse
- * @return The contextual id
- */
- public abstract Integer getIdFromKey(String key);
-}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -20,10 +20,10 @@
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
-
+
import javax.enterprise.context.spi.Contextual;
-import org.jboss.webbeans.context.api.ContextualInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
import org.jboss.webbeans.context.api.helpers.AbstractMapBackedBeanStore;
/**
@@ -36,15 +36,15 @@
private static final long serialVersionUID = 4770689245633688471L;
- // The backing map
- protected Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate;
+ // The backing map
+ protected Map<String, ContextualInstance<? extends Object>> delegate;
/**
* Constructor
*/
public HashMapBeanStore()
- {
- delegate = new HashMap<Contextual<? extends Object>,
ContextualInstance<? extends Object>>();
+ {
+ delegate = new HashMap<String, ContextualInstance<? extends
Object>>();
}
/**
@@ -52,8 +52,8 @@
*
* @return The delegate
*/
- @Override
- public Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate()
+ @Override
+ public Map<String, ContextualInstance<? extends Object>> delegate()
{
return delegate;
}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/NamingScheme.java
(from rev 3781,
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/PrefixBeanStoreNamingScheme.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/NamingScheme.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/NamingScheme.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.context.beanstore;
+
+
+
+/**
+ * Simple prefix-based implementation of a BeanStore naming scheme
+ *
+ * @author Nicklas Karlsson
+ */
+public class NamingScheme
+{
+ public String prefix;
+ public String delimeter;
+
+ public NamingScheme(String prefix, String delimeter)
+ {
+ if (prefix.indexOf(delimeter) >= 0)
+ {
+ throw new IllegalArgumentException("The delimiter '" + delimeter +
"' shouldn't be in the prefix '" + prefix + "'");
+ }
+ this.prefix = prefix;
+ this.delimeter = delimeter;
+ }
+
+ public boolean acceptKey(String key)
+ {
+ return key.startsWith(prefix);
+ }
+
+ public String getId(String key)
+ {
+ return new StringBuilder().append(key.substring(prefix.length() +
delimeter.length())).toString();
+ }
+
+ public String getKey(String id)
+ {
+ return new StringBuilder().append(prefix).append(delimeter).append(id).toString();
+ }
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/NamingScheme.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/PrefixBeanStoreNamingScheme.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/PrefixBeanStoreNamingScheme.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/PrefixBeanStoreNamingScheme.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans.context.beanstore;
-
-
-/**
- * Simple prefix-based implementation of a BeanStore naming scheme
- *
- * @author Nicklas Karlsson
- */
-public class PrefixBeanStoreNamingScheme implements BeanStoreNamingScheme
-{
- public String prefix;
- public String delimeter;
-
- public PrefixBeanStoreNamingScheme(String prefix, String delimeter)
- {
- if (prefix.indexOf(delimeter) >= 0)
- {
- throw new IllegalArgumentException("The prefix '" + prefix +
"' shouldn't be in the prefix '" + prefix + "'");
- }
- this.prefix = prefix;
- this.delimeter = delimeter;
- }
-
- public boolean acceptKey(String key)
- {
- return key.startsWith(prefix);
- }
-
- public Integer getIdFromKey(String key)
- {
- return Integer.parseInt(key.substring(prefix.length() + delimeter.length()));
- }
-
- public String getKeyFromId(Integer id)
- {
- return prefix + delimeter + id;
- }
-}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -16,14 +16,14 @@
*/
package org.jboss.webbeans.servlet;
+import java.util.Collection;
import java.util.Enumeration;
import javax.servlet.ServletContext;
import org.jboss.webbeans.context.ApplicationContext;
import org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore;
-import org.jboss.webbeans.context.beanstore.BeanStoreNamingScheme;
-import org.jboss.webbeans.context.beanstore.PrefixBeanStoreNamingScheme;
+import org.jboss.webbeans.context.beanstore.NamingScheme;
/**
* A BeanStore that uses a servlet context as backing storage
@@ -34,6 +34,9 @@
*/
public class ApplicationBeanStore extends AbstractAttributeBackedBeanStore
{
+
+ private static final NamingScheme NAMING_SCHEME = new
NamingScheme(ApplicationContext.class.getName(), "#");
+
// The servlet context to use as backing map
private ServletContext context;
@@ -86,9 +89,20 @@
}
@Override
- protected BeanStoreNamingScheme getNamingScheme()
+ protected NamingScheme getNamingScheme()
{
- return new PrefixBeanStoreNamingScheme(ApplicationContext.class.getName(),
"#");
+ return NAMING_SCHEME;
}
+ @Override
+ public Collection<String> getContextualIds()
+ {
+ return null;
+ }
+
+ @Override
+ public void clear()
+ {
+ }
+
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationBeanStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -19,8 +19,7 @@
import javax.servlet.http.HttpSession;
import org.jboss.webbeans.context.ConversationContext;
-import org.jboss.webbeans.context.beanstore.BeanStoreNamingScheme;
-import org.jboss.webbeans.context.beanstore.PrefixBeanStoreNamingScheme;
+import org.jboss.webbeans.context.beanstore.NamingScheme;
/**
* A HTTP session backed bean store for the conversational scope
@@ -29,18 +28,21 @@
*/
public class ConversationBeanStore extends HttpSessionBeanStore
{
- private String cid;
+
+ private final String cid;
+ private final NamingScheme namingScheme;
public ConversationBeanStore(HttpSession session, String cid)
{
super(session);
this.cid = cid;
+ this.namingScheme = new NamingScheme(ConversationContext.class.getName() +
"[" + cid + "]", "#");
}
@Override
- protected BeanStoreNamingScheme getNamingScheme()
+ protected NamingScheme getNamingScheme()
{
- return new PrefixBeanStoreNamingScheme(ConversationContext.class.getName() +
"[" + cid + "]", "#");
+ return namingScheme;
}
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpRequestSessionBeanStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpRequestSessionBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpRequestSessionBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -14,8 +14,7 @@
import org.jboss.webbeans.context.SessionContext;
import org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore;
-import org.jboss.webbeans.context.beanstore.BeanStoreNamingScheme;
-import org.jboss.webbeans.context.beanstore.PrefixBeanStoreNamingScheme;
+import org.jboss.webbeans.context.beanstore.NamingScheme;
/**
* Abstracts the servlet API specific session context
@@ -27,6 +26,7 @@
{
// The HTTP session context to use as backing map
private final HttpServletRequest request;
+ private static final NamingScheme NAMING_SCHEME = new
NamingScheme(SessionContext.class.getName(), "#");
/**
* Constructor
@@ -91,9 +91,9 @@
}
@Override
- protected BeanStoreNamingScheme getNamingScheme()
+ protected NamingScheme getNamingScheme()
{
- return new PrefixBeanStoreNamingScheme(SessionContext.class.getName(),
"#");
+ return NAMING_SCHEME;
}
}
\ No newline at end of file
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -22,8 +22,7 @@
import org.jboss.webbeans.context.SessionContext;
import org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore;
-import org.jboss.webbeans.context.beanstore.BeanStoreNamingScheme;
-import org.jboss.webbeans.context.beanstore.PrefixBeanStoreNamingScheme;
+import org.jboss.webbeans.context.beanstore.NamingScheme;
/**
* A BeanStore that uses a HTTP session as backing storage
@@ -34,8 +33,11 @@
*/
public class HttpSessionBeanStore extends AbstractAttributeBackedBeanStore
{
+
+ private static final NamingScheme NAMING_SCHEME = new
NamingScheme(SessionContext.class.getName(), "#");
+
// The HTTP session context to use as backing map
- private HttpSession session;
+ private final HttpSession session;
/**
* Constructor
@@ -86,9 +88,9 @@
}
@Override
- protected BeanStoreNamingScheme getNamingScheme()
+ protected NamingScheme getNamingScheme()
{
- return new PrefixBeanStoreNamingScheme(SessionContext.class.getName(),
"#");
+ return NAMING_SCHEME;
}
}
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/SingletonProvider.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/SingletonProvider.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/SingletonProvider.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -114,5 +114,10 @@
}
}
}
+
+ public static void reset()
+ {
+ INSTANCE = null;
+ }
}
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -95,5 +95,14 @@
* @return
*/
public ServiceRegistry getServices();
+
+ /**
+ * Get a string which uniquely identifies the {@link BeanDeploymentArchive} within
+ * the {@link Deployment}. The identifier must be consistent between multiple
+ * occurrences of this deployment.
+ *
+ * @return
+ */
+ public String getId();
}
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -19,9 +19,7 @@
import java.util.Collection;
-import javax.enterprise.context.spi.Contextual;
-
/**
* Interface for different implementations of Contextual instance storage.
*
@@ -33,10 +31,10 @@
/**
* Gets an instance of a contextual from the store
*
- * @param contextual The contextual whose instance is to be return
+ * @param contextual The id of the contextual to return
* @return The instance. Null if not found
- */
- public abstract <T> ContextualInstance<T> get(Contextual<? extends
T> contextual);
+ */
+ public abstract <T> ContextualInstance<T> get(String id);
/**
* Clears the store of contextual instances
@@ -48,13 +46,13 @@
*
* @return the instances
*/
- public abstract Collection<Contextual<?>> getContextuals();
+ public abstract Collection<String> getContextualIds();
/**
* Adds a bean instance to the storage
*
* @param contextualInstance the contextual instance
- * @return The instance added
- */
- public abstract <T> void put(ContextualInstance<T> contextualInstance);
+ * @return the id for the instance
+ */
+ public abstract <T> void put(String id, ContextualInstance<T>
contextualInstance);
}
\ No newline at end of file
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -5,8 +5,8 @@
import javax.enterprise.context.spi.Contextual;
+import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.ContextualInstance;
-import org.jboss.webbeans.context.api.BeanStore;
public abstract class AbstractMapBackedBeanStore implements BeanStore
{
@@ -16,7 +16,7 @@
super();
}
- public abstract Map<Contextual<? extends Object>, ContextualInstance<?
extends Object>> delegate();
+ protected abstract Map<String, ContextualInstance<? extends Object>>
delegate();
/**
* Gets an instance from the store
@@ -26,10 +26,10 @@
*
* @see org.jboss.webbeans.context.api.BeanStore#get(BaseBean)
*/
- public <T extends Object> ContextualInstance<T> get(Contextual<?
extends T> bean)
+ public <T extends Object> ContextualInstance<T> get(String id)
{
@SuppressWarnings("unchecked")
- ContextualInstance<T> instance = (ContextualInstance<T>)
delegate().get(bean);
+ ContextualInstance<T> instance = (ContextualInstance<T>)
delegate().get(id);
return instance;
}
@@ -50,7 +50,7 @@
*
* @see org.jboss.webbeans.context.api.BeanStore#getContextuals()
*/
- public Set<Contextual<? extends Object>> getContextuals()
+ public Set<String> getContextualIds()
{
return delegate().keySet();
}
@@ -63,9 +63,9 @@
*
* @see org.jboss.webbeans.context.api.BeanStore#put(Contextual, Object)
*/
- public <T> void put(ContextualInstance<T> beanInstance)
+ public <T> void put(String id, ContextualInstance<T> beanInstance)
{
- delegate().put(beanInstance.getContextual(), beanInstance);
+ delegate().put(id, beanInstance);
}
@Override
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -20,10 +20,10 @@
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
+
import javax.enterprise.context.spi.Contextual;
-import org.jboss.webbeans.context.api.ContextualInstance;
+import org.jboss.webbeans.context.api.ContextualInstance;
/**
* A BeanStore that uses a HashMap as backing storage
@@ -35,15 +35,14 @@
private static final long serialVersionUID = 4770689245633688471L;
- // The backing map
- protected Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate;
-
+ // The backing map
+ protected Map<String, ContextualInstance<? extends Object>> delegate;
/**
* Constructor
*/
public ConcurrentHashMapBeanStore()
- {
- delegate = new ConcurrentHashMap<Contextual<? extends Object>,
ContextualInstance<? extends Object>>();
+ {
+ delegate = new ConcurrentHashMap<String, ContextualInstance<? extends
Object>>();
}
/**
@@ -51,8 +50,8 @@
*
* @return The delegate
*/
- @Override
- public Map<Contextual<? extends Object>, ContextualInstance<? extends
Object>> delegate()
+ @Override
+ public Map<String, ContextualInstance<? extends Object>> delegate()
{
return delegate;
}
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -2,8 +2,6 @@
import java.util.Collection;
-import javax.enterprise.context.spi.Contextual;
-
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.ContextualInstance;
@@ -17,19 +15,19 @@
delegate().clear();
}
- public <T> ContextualInstance<T> get(Contextual<? extends T> bean)
+ public <T> ContextualInstance<T> get(String id)
{
- return delegate().get(bean);
+ return delegate().get(id);
}
- public Collection<Contextual<? extends Object>> getContextuals()
+ public Collection<String> getContextualIds()
{
- return delegate().getContextuals();
+ return delegate().getContextualIds();
}
- public <T> void put(ContextualInstance<T> beanInstance)
+ public <T> void put(String id, ContextualInstance<T> beanInstance)
{
- delegate().put(beanInstance);
+ delegate().put(id, beanInstance);
}
@Override
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockDeployment.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockDeployment.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockDeployment.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -68,6 +68,11 @@
return services;
}
+ public String getId()
+ {
+ return "test";
+ }
+
}
private final ServiceRegistry services;
Modified:
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockBeanDeploymentArchive.java
===================================================================
---
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockBeanDeploymentArchive.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockBeanDeploymentArchive.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -114,5 +114,10 @@
{
return services;
}
+
+ public String getId()
+ {
+ return "test";
+ }
}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java
===================================================================
---
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -17,9 +17,9 @@
private final WebBeansBootstrap bootstrap;
private final MockDeployment deployment;
- private final BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
- private final BeanStore sessionBeanStore = new ConcurrentHashMapBeanStore();
- private final BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
+ private final BeanStore applicationBeanStore;
+ private final BeanStore sessionBeanStore;
+ private final BeanStore requestBeanStore;
private Lifecycle lifecycle;
@@ -30,11 +30,29 @@
{
throw new IllegalStateException("No WebBeanDiscovery is available");
}
- bootstrap = new WebBeansBootstrap();
- deployment.getServices().add(ResourceLoader.class, MOCK_RESOURCE_LOADER);
- deployment.getServices().add(ServletServices.class, new
MockServletServices(deployment.getArchive()));
+ this.bootstrap = new WebBeansBootstrap();
+ this.deployment.getServices().add(ResourceLoader.class, MOCK_RESOURCE_LOADER);
+ this.deployment.getServices().add(ServletServices.class, new
MockServletServices(deployment.getArchive()));
+ this.applicationBeanStore = new ConcurrentHashMapBeanStore();
+ this.sessionBeanStore = new ConcurrentHashMapBeanStore();
+ this.requestBeanStore = new ConcurrentHashMapBeanStore();
}
+ protected BeanStore getSessionBeanStore()
+ {
+ return sessionBeanStore;
+ }
+
+ protected BeanStore getRequestBeanStore()
+ {
+ return requestBeanStore;
+ }
+
+ protected BeanStore getApplicationBeanStore()
+ {
+ return applicationBeanStore;
+ }
+
/* (non-Javadoc)
* @see org.jboss.webbeans.mock.MockLifecycle#initialize()
*/
@@ -83,11 +101,6 @@
bootstrap.shutdown();
}
- public BeanStore getApplicationBeanStore()
- {
- return applicationBeanStore;
- }
-
/* (non-Javadoc)
* @see org.jboss.webbeans.mock.MockLifecycle#resetContexts()
*/
@@ -101,7 +114,7 @@
*/
public void beginRequest()
{
- super.beginRequest("Mock", requestBeanStore);
+ super.beginRequest("Mock", getRequestBeanStore());
}
/* (non-Javadoc)
@@ -109,7 +122,7 @@
*/
public void endRequest()
{
- super.endRequest("Mock", requestBeanStore);
+ super.endRequest("Mock", getRequestBeanStore());
}
/* (non-Javadoc)
@@ -117,7 +130,7 @@
*/
public void beginSession()
{
- super.restoreSession("Mock", sessionBeanStore);
+ super.restoreSession("Mock", getSessionBeanStore());
}
/* (non-Javadoc)
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java 2009-09-29
19:11:54 UTC (rev 3811)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/TestContainer.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -10,7 +10,7 @@
* @author pmuir
*
*/
-public class TestContainer
+public class TestContainer<L extends MockServletLifecycle>
{
public static class Status
@@ -35,7 +35,7 @@
}
- private final MockServletLifecycle lifecycle;
+ private final L lifecycle;
private final Iterable<Class<?>> classes;
private final Iterable<URL> beansXml;
@@ -46,7 +46,7 @@
* @param classes
* @param beansXml
*/
- public TestContainer(MockServletLifecycle lifecycle, Iterable<Class<?>>
classes, Iterable<URL> beansXml)
+ public TestContainer(L lifecycle, Iterable<Class<?>> classes,
Iterable<URL> beansXml)
{
this.lifecycle = lifecycle;
this.classes = classes;
@@ -88,7 +88,7 @@
*
* @return
*/
- public MockLifecycle getLifecycle()
+ public L getLifecycle()
{
return lifecycle;
}
Added:
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/AbstractClusterTest.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/AbstractClusterTest.java
(rev 0)
+++
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/AbstractClusterTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,76 @@
+package org.jboss.webbeans.mock.cluster;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bootstrap.api.SingletonProvider;
+import org.jboss.webbeans.context.ContextLifecycle;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.mock.TestContainer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+
+public class AbstractClusterTest
+{
+
+ @BeforeClass
+ public void beforeClass()
+ {
+ SingletonProvider.reset();
+ SingletonProvider.initialize(new SwitchableSingletonProvider());
+ }
+
+ @AfterClass
+ public void afterClass()
+ {
+ SingletonProvider.reset();
+ }
+
+ protected TestContainer<MockEELifecycle> bootstrapContainer(int id,
Iterable<Class<?>> classes)
+ {
+ // Bootstrap container
+ SwitchableSingletonProvider.use(id);
+
+ TestContainer<MockEELifecycle> container = new
TestContainer<MockEELifecycle>(new MockEELifecycle(), classes, null);
+ container.startContainer();
+ container.ensureRequestActive();
+
+ return container;
+ }
+
+ protected void use(int id)
+ {
+ SwitchableSingletonProvider.use(id);
+ }
+
+ protected void replicateSession(int fromId, BeanManagerImpl fromBeanManager, int toId,
BeanManagerImpl toBeanManager) throws Exception
+ {
+ // Mimic replicating the session
+ BeanStore sessionBeanStore =
fromBeanManager.getServices().get(ContextLifecycle.class).getSessionContext().getBeanStore();
+ byte[] bytes = serialize(sessionBeanStore);
+ use(toId);
+ BeanStore replicatedSessionBeanStore = (BeanStore) deserialize(bytes);
+
toBeanManager.getServices().get(ContextLifecycle.class).getSessionContext().setBeanStore(replicatedSessionBeanStore);
+ use(fromId);
+ }
+
+ protected byte[] serialize(Object instance) throws IOException
+ {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(bytes);
+ out.writeObject(instance);
+ return bytes.toByteArray();
+ }
+
+ protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
+ {
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
+ return in.readObject();
+ }
+
+}
\ No newline at end of file
Property changes on:
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/AbstractClusterTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableMockEELifecycle.java
===================================================================
---
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableMockEELifecycle.java
(rev 0)
+++
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableMockEELifecycle.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,48 @@
+package org.jboss.webbeans.mock.cluster;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.mock.MockEELifecycle;
+
+public class SwitchableMockEELifecycle extends MockEELifecycle
+{
+
+ private final Map<Integer, BeanStore> requestBeanStores;
+ private final Map<Integer, BeanStore> sessionBeanStores;
+ private final Map<Integer, BeanStore> applicationBeanStores;
+
+ private int id = 1;
+
+ public SwitchableMockEELifecycle()
+ {
+ this.requestBeanStores = new HashMap<Integer, BeanStore>();
+ this.sessionBeanStores = new HashMap<Integer, BeanStore>();
+ this.applicationBeanStores = new HashMap<Integer, BeanStore>();
+ }
+
+ @Override
+ protected BeanStore getRequestBeanStore()
+ {
+ return requestBeanStores.get(id);
+ }
+
+ @Override
+ protected BeanStore getSessionBeanStore()
+ {
+ return sessionBeanStores.get(id);
+ }
+
+ @Override
+ protected BeanStore getApplicationBeanStore()
+ {
+ return applicationBeanStores.get(id);
+ }
+
+ public void use(int id)
+ {
+ this.id = id;
+ }
+
+}
Property changes on:
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableMockEELifecycle.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableSingletonProvider.java
===================================================================
---
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableSingletonProvider.java
(rev 0)
+++
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableSingletonProvider.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,61 @@
+package org.jboss.webbeans.mock.cluster;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.jboss.webbeans.bootstrap.api.Singleton;
+import org.jboss.webbeans.bootstrap.api.SingletonProvider;
+
+public class SwitchableSingletonProvider extends SingletonProvider
+{
+
+ public static void use(Integer id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ SwitchableSingleton.id = id;
+ }
+
+ private static class SwitchableSingleton<T> implements Singleton<T>
+ {
+
+ private static Integer id = 0;
+
+ private final Map<Integer, T> store;
+
+ public SwitchableSingleton()
+ {
+ this.store = new Hashtable<Integer, T>();
+ }
+
+ public void clear()
+ {
+ store.remove(id);
+ }
+
+ public T get()
+ {
+ return store.get(id);
+ }
+
+ public boolean isSet()
+ {
+ return store.containsKey(id);
+ }
+
+ public void set(T object)
+ {
+ store.put(id, object);
+ }
+
+ }
+
+ @Override
+ public <T> Singleton<T> create(Class<? extends T> expectedType)
+ {
+ return new SwitchableSingleton<T>();
+ }
+
+}
Property changes on:
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/cluster/SwitchableSingletonProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -9,9 +9,9 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.Packaging;
import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.bean.ProducerMethod;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -28,7 +28,7 @@
Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>,
Bean<?>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof RIBean)
+ if (bean instanceof RIBean<?>)
{
classes.put(((RIBean<?>) bean).getType(), bean);
}
@@ -36,8 +36,8 @@
assert classes.containsKey(TarantulaProducer.class);
assert classes.containsKey(Tarantula.class);
- assert classes.get(TarantulaProducer.class) instanceof ManagedBean;
- assert classes.get(Tarantula.class) instanceof ProducerMethod;
+ assert classes.get(TarantulaProducer.class) instanceof ManagedBean<?>;
+ assert classes.get(Tarantula.class) instanceof ProducerMethod<?>;
}
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/DefangedTarantula.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/DefangedTarantula.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/DefangedTarantula.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -2,5 +2,10 @@
class DefangedTarantula extends Tarantula
{
+
+ public DefangedTarantula()
+ {
+ super("defanged");
+ }
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/Tarantula.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/Tarantula.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/Tarantula.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,6 +1,13 @@
package org.jboss.webbeans.test.unit.bootstrap.singleProducerMethod;
+
+
class Tarantula extends Spider implements DeadlySpider
{
+
+ public Tarantula(String foo)
+ {
+ // TODO Auto-generated constructor stub
+ }
}
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Fodder.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Fodder.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Fodder.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.test.unit.cluster;
+
+import java.io.Serializable;
+
+public class Fodder implements Serializable
+{
+
+ private static final long serialVersionUID = 7526196594918652669L;
+
+ private int amount;
+
+ public int getAmount()
+ {
+ return amount;
+ }
+
+ public void setAmount(int amount)
+ {
+ this.amount = amount;
+ }
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Fodder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Horse.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Horse.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Horse.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.test.unit.cluster;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+public class Horse implements Serializable
+{
+
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Horse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/NaiveClusterTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,82 +1,110 @@
package org.jboss.webbeans.test.unit.cluster;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.util.Arrays;
import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
-import org.jboss.webbeans.context.ContextLifecycle;
-import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.mock.MockEELifecycle;
import org.jboss.webbeans.mock.TestContainer;
+import org.jboss.webbeans.mock.cluster.AbstractClusterTest;
import org.testng.annotations.Test;
-public class NaiveClusterTest
+public class NaiveClusterTest extends AbstractClusterTest
{
-
- @Test
- public void testSessionReplication() throws Exception
+
+ @Test(description="A simple test to check session replication, doesn't
carefully check if a bean ids are correct")
+ public void testSimpleSessionReplication() throws Exception
{
- SingletonProvider.initialize(new SwitchableSingletonProvider());
- // Bootstrap container 1
- SwitchableSingletonProvider.use(1);
-
- TestContainer container1 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
- container1.startContainer();
- container1.ensureRequestActive();
-
+ TestContainer<MockEELifecycle> container1 = bootstrapContainer(1,
Arrays.<Class<?>>asList(Foo.class));
BeanManagerImpl beanManager1 = container1.getBeanManager();
Bean<?> fooBean1 = beanManager1.resolve(beanManager1.getBeans(Foo.class));
- // Bootstrap container 2
- SwitchableSingletonProvider.use(2);
-
- TestContainer container2 = new TestContainer(new MockEELifecycle(),
Arrays.<Class<?>>asList(Foo.class), null);
- container2.startContainer();
- container2.ensureRequestActive();
-
+ TestContainer<MockEELifecycle> container2 = bootstrapContainer(2,
Arrays.<Class<?>>asList(Foo.class));
BeanManagerImpl beanManager2 = container2.getBeanManager();
Bean<?> fooBean2 = beanManager2.resolve(beanManager2.getBeans(Foo.class));
- SwitchableSingletonProvider.use(1);
+ use(1);
// Set a value into Foo1
Foo foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class,
beanManager1.createCreationalContext(fooBean1));
foo1.setName("container 1");
- replicateSession(beanManager1, beanManager2);
+ replicateSession(1, beanManager1, 2, beanManager2);
- SwitchableSingletonProvider.use(2);
+ use(2);
Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
assert foo2.getName().equals("container 1");
}
- private void replicateSession(BeanManagerImpl beanManager1, BeanManagerImpl
beanManager2) throws Exception
+ @Test
+ public void testMultipleDependentObjectsSessionReplication() throws Exception
{
- // Mimic replicating the session
- BeanStore sessionBeanStore =
beanManager1.getServices().get(ContextLifecycle.class).getSessionContext().getBeanStore();
- BeanStore replicatedSessionBeanStore = (BeanStore)
deserialize(serialize(sessionBeanStore));
-
beanManager2.getServices().get(ContextLifecycle.class).getSessionContext().setBeanStore(replicatedSessionBeanStore);
+ Iterable<Class<?>> classes =
Arrays.<Class<?>>asList(Stable.class, Horse.class, Fodder.class);
+ TestContainer<MockEELifecycle> container1 = bootstrapContainer(1, classes);
+ BeanManagerImpl beanManager1 = container1.getBeanManager();
+ Bean<?> stableBean1 =
beanManager1.resolve(beanManager1.getBeans(Stable.class));
+
+ TestContainer<MockEELifecycle> container2 = bootstrapContainer(2, classes);
+ BeanManagerImpl beanManager2 = container2.getBeanManager();
+ Bean<?> stableBean2 =
beanManager2.resolve(beanManager2.getBeans(Stable.class));
+
+ use(1);
+ // Set a value into Foo1
+ Stable stable1 = (Stable) beanManager1.getReference(stableBean1, Foo.class,
beanManager1.createCreationalContext(stableBean1));
+ stable1.getFodder().setAmount(10);
+ stable1.getHorse().setName("George");
+
+ replicateSession(1, beanManager1, 2, beanManager2);
+
+ use(2);
+
+ Stable stable2 = (Stable) beanManager2.getReference(stableBean2, Stable.class,
beanManager2.createCreationalContext(stableBean2));
+ assert stable2.getFodder().getAmount() == stable1.getFodder().getAmount();
+ assert stable2.getHorse().getName() == null;
+
+ use(1);
+ assert stable1.getFodder().getAmount() == 10;
+ assert stable1.getHorse().getName().equals("George");
+
+ use(2);
+
+ stable2.getFodder().setAmount(11);
+
+ replicateSession(2, beanManager2, 1, beanManager1);
+
+ use(1);
+
+ assert stable1.getFodder().getAmount() == 11;
}
- protected byte[] serialize(Object instance) throws IOException
+ @Test
+ public void testVariableBeanDeploymentStructure() throws Exception
{
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(bytes);
- out.writeObject(instance);
- return bytes.toByteArray();
+ // NB This is not a valid deployment scenario for a cluster, but it does allow us
to test bean ids neatly!
+ Iterable<Class<?>> classes1 =
Arrays.<Class<?>>asList(Stable.class, Horse.class, Fodder.class);
+ Iterable<Class<?>> classes2 =
Arrays.<Class<?>>asList(Stable.class, Horse.class, Fodder.class, Foo.class);
+ TestContainer<MockEELifecycle> container1 = bootstrapContainer(1, classes1);
+ BeanManagerImpl beanManager1 = container1.getBeanManager();
+ Bean<?> stableBean1 =
beanManager1.resolve(beanManager1.getBeans(Stable.class));
+
+ TestContainer<MockEELifecycle> container2 = bootstrapContainer(2, classes2);
+ BeanManagerImpl beanManager2 = container2.getBeanManager();
+ Bean<?> stableBean2 =
beanManager2.resolve(beanManager2.getBeans(Stable.class));
+
+ use(1);
+ // Set a value into Foo1
+ Stable stable1 = (Stable) beanManager1.getReference(stableBean1, Foo.class,
beanManager1.createCreationalContext(stableBean1));
+ stable1.getFodder().setAmount(10);
+ stable1.getHorse().setName("George");
+
+ replicateSession(1, beanManager1, 2, beanManager2);
+
+ use(2);
+
+ Stable stable2 = (Stable) beanManager2.getReference(stableBean2, Stable.class,
beanManager2.createCreationalContext(stableBean2));
+ assert stable2.getFodder().getAmount() == stable1.getFodder().getAmount();
+ assert stable2.getHorse().getName() == null;
}
-
- protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
- {
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
- return in.readObject();
- }
}
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Stable.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Stable.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Stable.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -0,0 +1,33 @@
+package org.jboss.webbeans.test.unit.cluster;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+
+@SessionScoped
+public class Stable implements Serializable
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4007799511309218679L;
+
+ @Inject
+ private Horse horse;
+
+ @Inject
+ private Fodder fodder;
+
+ public Horse getHorse()
+ {
+ return horse;
+ }
+
+ public Fodder getFodder()
+ {
+ return fodder;
+ }
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/Stable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableContainerTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -8,6 +8,7 @@
import org.jboss.webbeans.bootstrap.api.SingletonProvider;
import org.jboss.webbeans.mock.MockEELifecycle;
import org.jboss.webbeans.mock.TestContainer;
+import org.jboss.webbeans.mock.cluster.SwitchableSingletonProvider;
import org.testng.annotations.Test;
public class SwitchableContainerTest
@@ -16,6 +17,7 @@
@Test
public void test()
{
+ SingletonProvider.reset();
SingletonProvider.initialize(new SwitchableSingletonProvider());
// Bootstrap container 1
@@ -51,6 +53,7 @@
SwitchableSingletonProvider.use(2);
foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class,
beanManager2.createCreationalContext(fooBean2));
assert foo2.getName().equals("container 2");
+ SingletonProvider.reset();
}
}
Deleted:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/cluster/SwitchableSingletonProvider.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -1,61 +0,0 @@
-package org.jboss.webbeans.test.unit.cluster;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.jboss.webbeans.bootstrap.api.Singleton;
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
-
-public class SwitchableSingletonProvider extends SingletonProvider
-{
-
- public static void use(Integer id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- SwitchableSingleton.id = id;
- }
-
- private static class SwitchableSingleton<T> implements Singleton<T>
- {
-
- private static Integer id = 0;
-
- private final Map<Integer, T> store;
-
- public SwitchableSingleton()
- {
- this.store = new Hashtable<Integer, T>();
- }
-
- public void clear()
- {
- store.remove(id);
- }
-
- public T get()
- {
- return store.get(id);
- }
-
- public boolean isSet()
- {
- return store.containsKey(id);
- }
-
- public void set(T object)
- {
- store.put(id, object);
- }
-
- }
-
- @Override
- public <T> Singleton<T> create(Class<? extends T> expectedType)
- {
- return new SwitchableSingleton<T>();
- }
-
-}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -5,9 +5,9 @@
import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.ContextualIdStore;
+import org.jboss.webbeans.ContextualStore;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -32,7 +32,7 @@
this.classTransformer = new ClassTransformer(new TypeStore());
this.services = new SimpleServiceRegistry();
this.services.add(MetaAnnotationStore.class, new
MetaAnnotationStore(classTransformer));
- this.services.add(ContextualIdStore.class, new ContextualIdStore());
+ this.services.add(ContextualStore.class, new ContextualStore());
}
private void addBean(BeanManagerImpl manager, Class<?> c)
@@ -47,8 +47,8 @@
@Test
public void testAccessibleDynamicallySingleLevel()
{
- BeanManagerImpl root = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl child = BeanManagerImpl.newRootManager(services);
+ BeanManagerImpl root = BeanManagerImpl.newRootManager("root", services);
+ BeanManagerImpl child = BeanManagerImpl.newRootManager("child",
services);
addBean(root, Cow.class);
assert root.getBeans(Cow.class).size() == 1;
assert child.getBeans(Cow.class).size() == 0;
@@ -63,11 +63,11 @@
@Test
public void testAccessibleThreeLevelsWithMultiple()
{
- BeanManagerImpl root = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl child = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl child1 = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl grandchild = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl greatGrandchild = BeanManagerImpl.newRootManager(services);
+ BeanManagerImpl root = BeanManagerImpl.newRootManager("root", services);
+ BeanManagerImpl child = BeanManagerImpl.newRootManager("child",
services);
+ BeanManagerImpl child1 = BeanManagerImpl.newRootManager("child1",
services);
+ BeanManagerImpl grandchild = BeanManagerImpl.newRootManager("grandchild",
services);
+ BeanManagerImpl greatGrandchild =
BeanManagerImpl.newRootManager("greatGrandchild", services);
child.addAccessibleBeanManager(root);
grandchild.addAccessibleBeanManager(child1);
grandchild.addAccessibleBeanManager(child);
@@ -104,9 +104,9 @@
@Test
public void testSameManagerAddedTwice()
{
- BeanManagerImpl root = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl child = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl grandchild = BeanManagerImpl.newRootManager(services);
+ BeanManagerImpl root = BeanManagerImpl.newRootManager("root", services);
+ BeanManagerImpl child = BeanManagerImpl.newRootManager("child",
services);
+ BeanManagerImpl grandchild = BeanManagerImpl.newRootManager("grandchild",
services);
grandchild.addAccessibleBeanManager(child);
child.addAccessibleBeanManager(root);
grandchild.addAccessibleBeanManager(root);
@@ -127,9 +127,9 @@
@Test
public void testCircular()
{
- BeanManagerImpl root = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl child = BeanManagerImpl.newRootManager(services);
- BeanManagerImpl grandchild = BeanManagerImpl.newRootManager(services);
+ BeanManagerImpl root = BeanManagerImpl.newRootManager("root", services);
+ BeanManagerImpl child = BeanManagerImpl.newRootManager("child",
services);
+ BeanManagerImpl grandchild = BeanManagerImpl.newRootManager("grandchild",
services);
grandchild.addAccessibleBeanManager(child);
child.addAccessibleBeanManager(root);
grandchild.addAccessibleBeanManager(root);
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -87,5 +87,15 @@
assert kassel == null : "SFSB bean should not exist after being
destroyed";
//frankfurt.dispose();
}
+
+ @Test
+ public void testDestroyDoesntTryToRemoveSLSB()
+ {
+ Bean<BeanLocal> bean = getBean(BeanLocal.class);
+ assert bean != null : "Expected a bean for stateless session bean
BeanLocal";
+ CreationalContext<BeanLocal> creationalContext =
getCurrentManager().createCreationalContext(bean);
+ BeanLocal instance = bean.create(creationalContext);
+ bean.destroy(instance, creationalContext);
+ }
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -22,7 +22,7 @@
getCurrentManager().getInstanceByType(DependentSelfConsumingDependentProducer.class).ping();
}
- @Test(groups="broken", timeOut=1000)
+ @Test
public void testDependentSelfConsumingProducer() throws Exception
{
getCurrentManager().getInstanceByType(Violation.class).ping();
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java 2009-09-29
19:11:54 UTC (rev 3811)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java 2009-09-29
19:33:18 UTC (rev 3812)
@@ -103,7 +103,7 @@
@Test
public void testRootManagerSerializability() throws Exception
{
- Integer rootManagerId = getCurrentManager().getId();
+ String rootManagerId = getCurrentManager().getId();
BeanManagerImpl deserializedRootManager = (BeanManagerImpl)
deserialize(serialize(getCurrentManager()));
assert deserializedRootManager.getId().equals(rootManagerId);
assert getCurrentManager().getBeans(Foo.class).size() == 1;
@@ -117,7 +117,7 @@
BeanManagerImpl childManager = getCurrentManager().createActivity();
Bean<?> dummyBean = new DummyBean();
childManager.addBean(dummyBean);
- Integer childManagerId = childManager.getId();
+ String childManagerId = childManager.getId();
BeanManagerImpl deserializedChildManager = (BeanManagerImpl)
deserialize(serialize(childManager));
assert deserializedChildManager.getId().equals(childManagerId);
assert childManager.getBeans(Dummy.class).size() == 1;
Modified: ri/trunk/tests/unit-tests.xml
===================================================================
--- ri/trunk/tests/unit-tests.xml 2009-09-29 19:11:54 UTC (rev 3811)
+++ ri/trunk/tests/unit-tests.xml 2009-09-29 19:33:18 UTC (rev 3812)
@@ -1,6 +1,6 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-<suite name="Web Beans RI" verbose="1" >
+<suite name="Web Beans RI" verbose="3" >
<test name="Web Beans RI">
<method-selectors>
@@ -27,16 +27,18 @@
<package name="org.jboss.webbeans.test.unit.annotated.decoration"
/>
<package name="org.jboss.webbeans.test.unit.bootstrap" />
<package name="org.jboss.webbeans.test.unit.bootstrap.environments"
/>
- <package
name="org.jboss.webbeans.test.unit.bootstrap.environments.multipleEnterprise"
/>
- <package
name="org.jboss.webbeans.test.unit.bootstrap.environments.multipleEnterpriseAndSimple"
/>
- <package
name="org.jboss.webbeans.test.unit.bootstrap.environments.multipleSimple" />
- <package
name="org.jboss.webbeans.test.unit.bootstrap.environments.singleEnterprise"
/>
- <package
name="org.jboss.webbeans.test.unit.bootstrap.environments.singleProducerMethod"
/>
- <package
name="org.jboss.webbeans.test.unit.bootstrap.environments.singleSimple" />
+ <package
name="org.jboss.webbeans.test.unit.bootstrap.multipleEnterprise" />
+ <package
name="org.jboss.webbeans.test.unit.bootstrap.multipleEnterpriseAndSimple" />
+ <package
name="org.jboss.webbeans.test.unit.bootstrap.multipleSimple" />
+ <package
name="org.jboss.webbeans.test.unit.bootstrap.singleEnterprise" />
+ <package
name="org.jboss.webbeans.test.unit.bootstrap.singleProducerMethod" />
+ <package name="org.jboss.webbeans.test.unit.bootstrap.singleSimple"
/>
+ <package name="org.jboss.webbeans.test.unit.cluster" />
<package name="org.jboss.webbeans.test.unit.context" />
+ <package name="org.jboss.webbeans.test.unit.decorator.simple"
/>
<package name="org.jboss.webbeans.test.unit.definition" />
<package name="org.jboss.webbeans.test.unit.deployment.structure"
/>
- <package name="org.jboss.webbeans.test.unit.event" />
+ <package name="org.jboss.webbeans.test.unit.evironments.servlet"
/>
<package name="org.jboss.webbeans.test.unit.implementation" />
<package
name="org.jboss.webbeans.test.unit.implementation.annotatedItem" />
<package
name="org.jboss.webbeans.test.unit.implementation.enterpise" />
@@ -53,10 +55,10 @@
<package name="org.jboss.webbeans.test.unit.lookup" />
<package name="org.jboss.webbeans.test.unit.lookup.circular" />
<package name="org.jboss.webbeans.test.unit.lookup.wbri279" />
+ <package name="org.jboss.webbeans.test.unit.lookup.wbri293" />
<package name="org.jboss.webbeans.test.unit.manager" />
<package name="org.jboss.webbeans.test.unit.noncontextual" />
<package name="org.jboss.webbeans.test.unit.security" />
- <package name="org.jboss.webbeans.test.unit.decorator.simple"
/>
</packages>
</test>