Author: pete.muir(a)jboss.org
Date: 2009-06-25 16:27:55 -0400 (Thu, 25 Jun 2009)
New Revision: 2892
Added:
ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java
Removed:
ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java
Modified:
ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.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/DisposalMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.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/ejb/SessionBeanInterceptor.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java
ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/named/NamedBeanWithBindingTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerWithBindingTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/proxy/ProxyTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/OldSPIBridge.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/EnterpriseBeanRemoveMethodTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java
Log:
Switch to using release() for dependent object destruction
Deleted: ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java
===================================================================
--- ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java 2009-06-25 15:27:52
UTC (rev 2891)
+++ ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java 2009-06-25 20:27:55
UTC (rev 2892)
@@ -1,85 +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 javax.enterprise.inject.spi;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Set;
-
-import javax.enterprise.context.spi.Contextual;
-
-public interface Bean<T> extends Contextual<T>
-{
-
- /**
- * The client-visible types of a bean
- *
- * @return the bean types
- */
- public Set<Type> getTypes();
-
- /**
- * The bindings of a bean
- *
- * @return the bindings
- */
- public Set<Annotation> getBindings();
-
- /**
- * The scope of a bean
- *
- * @return the scope
- */
- public Class<? extends Annotation> getScopeType();
-
- /**
- * The deployment type of a bean
- *
- * @return the deployment type
- */
- public Class<? extends Annotation> getDeploymentType();
-
- /**
- * The name of a bean
- *
- * @return the name
- */
- public String getName();
-
- /**
- * The serializability of a bean
- *
- * @return true if the bean is serializable
- */
- public boolean isSerializable();
-
- /**
- * The nullability of a bean
- *
- * @return true if the bean is nullable
- */
- public boolean isNullable();
-
- /**
- * The injection points of a bean
- *
- * @return the injection points of a bean
- */
- public Set<InjectionPoint> getInjectionPoints();
-
-}
\ No newline at end of file
Added: ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java
===================================================================
--- ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java
(rev 0)
+++ ri/trunk/api/src/main/java/javax/enterprise/inject/spi/Bean.java 2009-06-25 20:27:55
UTC (rev 2892)
@@ -0,0 +1,85 @@
+/*
+ * 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 javax.enterprise.inject.spi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.spi.Contextual;
+
+public interface Bean<T> extends Contextual<T>
+{
+
+ /**
+ * The client-visible types of a bean
+ *
+ * @return the bean types
+ */
+ public Set<Type> getTypes();
+
+ /**
+ * The bindings of a bean
+ *
+ * @return the bindings
+ */
+ public Set<Annotation> getBindings();
+
+ /**
+ * The scope of a bean
+ *
+ * @return the scope
+ */
+ public Class<? extends Annotation> getScopeType();
+
+ /**
+ * The deployment type of a bean
+ *
+ * @return the deployment type
+ */
+ public Class<? extends Annotation> getDeploymentType();
+
+ /**
+ * The name of a bean
+ *
+ * @return the name
+ */
+ public String getName();
+
+ /**
+ * The serializability of a bean
+ *
+ * @return true if the bean is serializable
+ */
+ public boolean isSerializable();
+
+ /**
+ * The nullability of a bean
+ *
+ * @return true if the bean is nullable
+ */
+ public boolean isNullable();
+
+ /**
+ * The injection points of a bean
+ *
+ * @return the injection points of a bean
+ */
+ public Set<InjectionPoint> getInjectionPoints();
+
+}
\ No newline at end of file
Modified: ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
===================================================================
--- ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -26,6 +26,7 @@
import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.context.ScopeType;
import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AmbiguousResolutionException;
import javax.enterprise.inject.UnsatisfiedResolutionException;
@@ -56,7 +57,7 @@
* @throws IllegalArgumentException
* if the given type is not a bean type of the given bean
*/
- public Object getReference(Bean<?> bean, Type beanType);
+ public Object getReference(Bean<?> bean, Type beanType,
CreationalContext<?> creationalContext);
/**
* Obtains an instance of bean for a given injection point.
@@ -406,10 +407,11 @@
public <T> ManagedBean<T> createManagedBean(AnnotatedType<T> type);
/**
- * Obtain an instance of a {@link CreationalContext}
+ * Obtain an instance of a {@link CreationalContext} for the given contextual
*
+ * @param contextual the contextual to create a creational context for
* @return the {@link CreationalContext} instance
*/
- public CreationalContext<?> createCreationalContext();
+ public <T> CreationalContext<T>
createCreationalContext(Contextual<T> contextual);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -46,6 +46,7 @@
import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.context.ScopeType;
import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AmbiguousResolutionException;
import javax.enterprise.inject.BindingType;
@@ -182,7 +183,7 @@
private transient final ClientProxyProvider clientProxyProvider;
private transient final Map<Class<?>, EnterpriseBean<?>>
newEnterpriseBeans;
private transient final Map<String, RIBean<?>> riBeans;
- private final transient Map<Bean<?>, Bean<?>> specializedBeans;
+ private final transient Map<Contextual<?>, Contextual<?>>
specializedBeans;
private final transient AtomicInteger ids;
/*
@@ -232,7 +233,7 @@
new ClientProxyProvider(),
new ConcurrentListHashMultiMap<Class<? extends Annotation>,
Context>(),
new CopyOnWriteArraySet<CurrentActivity>(),
- new HashMap<Bean<?>, Bean<?>>(),
defaultEnabledDeploymentTypes, defaultEnabledDecoratorClasses,
+ new HashMap<Contextual<?>, Contextual<?>>(),
defaultEnabledDeploymentTypes, defaultEnabledDecoratorClasses,
new AtomicInteger());
}
@@ -272,7 +273,7 @@
*
* @param ejbServices the ejbResolver to use
*/
- private BeanManagerImpl(ServiceRegistry serviceRegistry, List<Bean<?>>
beans, List<DecoratorBean<?>> decorators, ConcurrentSetMultiMap<Type,
EventObserver<?>> registeredObservers, Namespace rootNamespace,
Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans, Map<String,
RIBean<?>> riBeans, ClientProxyProvider clientProxyProvider,
ConcurrentListMultiMap<Class<? extends Annotation>, Context> contexts,
Set<CurrentActivity> currentActivities, Map<Bean<?>, Bean<?>>
specializedBeans, List<Class<? extends Annotation>> enabledDeploymentTypes,
List<Class<?>> enabledDecoratorClasses, AtomicInteger ids)
+ private BeanManagerImpl(ServiceRegistry serviceRegistry, List<Bean<?>>
beans, List<DecoratorBean<?>> decorators, ConcurrentSetMultiMap<Type,
EventObserver<?>> registeredObservers, Namespace rootNamespace,
Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans, Map<String,
RIBean<?>> riBeans, ClientProxyProvider clientProxyProvider,
ConcurrentListMultiMap<Class<? extends Annotation>, Context> contexts,
Set<CurrentActivity> currentActivities, Map<Contextual<?>,
Contextual<?>> specializedBeans, List<Class<? extends Annotation>>
enabledDeploymentTypes, List<Class<?>> enabledDecoratorClasses, AtomicInteger
ids)
{
this.services = serviceRegistry;
this.beans = beans;
@@ -689,6 +690,10 @@
public Object getInjectableReference(Bean<?> bean, CreationalContext<?>
creationalContext)
{
bean = getMostSpecializedBean(bean);
+ if (creationalContext instanceof CreationalContextImpl)
+ {
+ creationalContext = ((CreationalContextImpl<?>)
creationalContext).getCreationalContext(bean);
+ }
if
(getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal())
{
if (creationalContext != null || (creationalContext == null &&
getContext(bean.getScopeType()).get(bean) != null))
@@ -702,7 +707,7 @@
}
else
{
- return getContext(bean.getScopeType()).get((Bean) bean, creationalContext);
+ return getContext(bean.getScopeType()).get((Contextual) bean,
creationalContext);
}
}
@@ -711,9 +716,9 @@
* does not pay attention to what type the resulting instance needs to
* implement
*/
- public Object getReference(Bean<?> bean, Type beanType)
+ public Object getReference(Bean<?> bean, Type beanType,
CreationalContext<?> creationalContext)
{
- return getInjectableReference(bean,
createCreationalContext().getCreationalContext(bean));
+ return getInjectableReference(bean, creationalContext);
}
@SuppressWarnings("unchecked")
@@ -734,14 +739,14 @@
}
if (creationalContext instanceof CreationalContextImpl)
{
- CreationalContextImpl<?> ctx = (CreationalContextImpl<?>)
creationalContext;
- if (ctx.containsIncompleteInstance(resolvedBean))
+ CreationalContextImpl<?> creationalContextImpl =
(CreationalContextImpl<?>) creationalContext;
+ if (creationalContextImpl.containsIncompleteInstance(resolvedBean))
{
- return ctx.getIncompleteInstance(resolvedBean);
+ return creationalContextImpl.getIncompleteInstance(resolvedBean);
}
else
{
- return getInjectableReference(resolvedBean,
ctx.getCreationalContext(resolvedBean));
+ return getInjectableReference(resolvedBean, creationalContextImpl);
}
}
else
@@ -772,7 +777,8 @@
public <T> T getInstanceByType(Class<T> type, Annotation... bindings)
{
WBAnnotated<T, ?> element = ResolvableWBClass.of(type, bindings, this);
- return (T) getReference(getBean(element, bindings), type);
+ Bean<T> bean = getBean(element, bindings);
+ return (T) getReference(bean, type, createCreationalContext(bean));
}
public <T> Bean<T> getBean(WBAnnotated<T, ?> element, Annotation...
bindings)
@@ -822,7 +828,7 @@
return new ArrayList(decoratorResolver.get(ResolvableFactory.of(types,
bindings)));
}
- public List<Decorator<?>> resolveDecorators(Bean<?> bean)
+ public List<Decorator<?>> resolveDecorators(Contextual<?> bean)
{
throw new UnsupportedOperationException();
}
@@ -936,7 +942,7 @@
*
* @return
*/
- public Map<Bean<?>, Bean<?>> getSpecializedBeans()
+ public Map<Contextual<?>, Contextual<?>> getSpecializedBeans()
{
// TODO make this unmodifiable after deploy!
return specializedBeans;
@@ -1054,7 +1060,7 @@
public <X> Bean<? extends X> getMostSpecializedBean(Bean<X> bean)
{
- Bean<?> key = bean;
+ Contextual<?> key = bean;
while (specializedBeans.containsKey(key))
{
if (key == null)
@@ -1148,9 +1154,9 @@
return webbeansELResolver;
}
- public CreationalContextImpl<?> createCreationalContext()
+ public <T> CreationalContextImpl<T>
createCreationalContext(Contextual<T> contextual)
{
- return new CreationalContextImpl<Object>();
+ return new CreationalContextImpl<T>(contextual);
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-06-25 15:27:52
UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-06-25 20:27:55
UTC (rev 2892)
@@ -54,7 +54,7 @@
Bean<T> bean = getManager().getBean(ResolvableWBClass.<T>of(getType(),
annotations, getManager()), annotations);
@SuppressWarnings("unchecked")
- T instance = (T) getManager().getReference(bean, getType());
+ T instance = (T) getManager().getReference(bean, getType(),
getManager().createCreationalContext(bean));
return instance;
}
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-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -37,7 +37,6 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.context.DependentInstancesStore;
import org.jboss.webbeans.conversation.ConversationImpl;
import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBAnnotated;
@@ -68,10 +67,8 @@
@SuppressWarnings("unchecked")
private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new
HashSet<Class<?>>(Arrays.asList(Event.class, BeanManagerImpl.class,
ConversationImpl.class));
- private boolean proxyable;
+ private boolean proxyable;
- protected final DependentInstancesStore dependentInstancesStore;
-
/**
* Helper class for getting deployment type
*
@@ -138,8 +135,7 @@
{
super(manager);
this.manager = manager;
- injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- dependentInstancesStore = new DependentInstancesStore();
+ injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
}
/**
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-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -150,7 +150,7 @@
}
}
- protected T applyDecorators(T instance)
+ protected T applyDecorators(T instance, CreationalContext<T> creationalContext)
{
if (hasDecorators())
{
@@ -165,7 +165,7 @@
if (decorator instanceof DecoratorBean)
{
decoratorStackPosition.set(++i);
- decoratorInstances.add(new
SerializableBeanInstance<DecoratorBean<Object>, Object>((DecoratorBean)
decorator, getManager().getReference(decorator, Object.class)));
+ decoratorInstances.add(new
SerializableBeanInstance<DecoratorBean<Object>, Object>((DecoratorBean)
decorator, getManager().getReference(decorator, Object.class, creationalContext)));
}
else
{
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-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -42,7 +42,6 @@
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentStorageRequest;
import org.jboss.webbeans.introspector.WBMember;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -325,7 +324,7 @@
return creationalContextImpl.getIncompleteInstance(getDeclaringBean());
}
}
- return manager.getReference(getDeclaringBean(), getDeclaringBean().getType());
+ return manager.getReference(getDeclaringBean(), getDeclaringBean().getType(),
creationalContext);
}
}
@@ -336,13 +335,8 @@
*/
public T create(CreationalContext<T> creationalContext)
{
- DependentStorageRequest dependentStorageRequest =
DependentStorageRequest.of(dependentInstancesStore, new Object());
try
{
- if (getDeclaringBean().isDependent())
- {
-
DependentContext.instance().startCollectingDependents(dependentStorageRequest);
- }
DependentContext.instance().setActive(true);
T instance = produceInstance(creationalContext);
checkReturnValue(instance);
@@ -352,8 +346,7 @@
{
if (getDeclaringBean().isDependent())
{
-
DependentContext.instance().stopCollectingDependents(dependentStorageRequest);
-
dependentInstancesStore.destroyDependentInstances(dependentStorageRequest.getKey());
+ creationalContext.release();
}
DependentContext.instance().setActive(false);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -188,7 +188,7 @@
public void invokeDisposeMethod(Object instance, CreationalContext<?>
creationalContext)
{
// TODO WTF - why isn't this using getReceiver!? Why is it assigning the
beanInstance as the beanObject!?!
- Object beanInstance = disposalMethodInjectionPoint.isStatic() ? declaringBean :
getManager().getReference(declaringBean, declaringBean.getType());
+ Object beanInstance = disposalMethodInjectionPoint.isStatic() ? declaringBean :
getManager().getReference(declaringBean, declaringBean.getType(), creationalContext);
disposalMethodInjectionPoint.invokeWithSpecialValue(beanInstance, Disposes.class,
instance, manager, creationalContext, IllegalArgumentException.class);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -40,7 +40,6 @@
import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentStorageRequest;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
@@ -230,9 +229,9 @@
DependentContext.instance().setActive(true);
T instance = proxyClass.newInstance();
creationalContext.push(instance);
- ((ProxyObject) instance).setHandler(new
EnterpriseBeanProxyMethodHandler(this));
+ ((ProxyObject) instance).setHandler(new
EnterpriseBeanProxyMethodHandler<T>(this, creationalContext));
log.trace("Enterprise bean instance created for bean {0}", this);
- return applyDecorators(instance);
+ return applyDecorators(instance, creationalContext);
}
catch (InstantiationException e)
{
@@ -269,7 +268,7 @@
}
else
{
- enterpiseBeanInstance.destroy();
+ enterpiseBeanInstance.destroy(this, creationalContext);
}
}
@@ -310,7 +309,6 @@
public void postConstruct(T instance)
{
- DependentStorageRequest dependentStorageRequest =
DependentStorageRequest.of(dependentInstancesStore, instance);
try
{
CreationalContext<T> creationalContext = new CreationalContext<T>()
@@ -324,22 +322,20 @@
}
};
- DependentContext.instance().startCollectingDependents(dependentStorageRequest);
DependentContext.instance().setActive(true);
injectBoundFields(instance, creationalContext);
callInitializers(instance, creationalContext);
}
finally
{
- DependentContext.instance().stopCollectingDependents(dependentStorageRequest);
DependentContext.instance().setActive(false);
}
}
- public void preDestroy(T instance)
+ public void preDestroy(CreationalContext<T> creationalContext)
{
- dependentInstancesStore.destroyDependentInstances(instance);
+ creationalContext.release();
}
@Override
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -29,7 +29,6 @@
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentStorageRequest;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
@@ -176,13 +175,8 @@
public void destroy(T instance, CreationalContext<T> creationalContext)
{
- DependentStorageRequest dependentStorageRequest =
DependentStorageRequest.of(dependentInstancesStore, new Object());
try
{
- if (getDeclaringBean().isDependent())
- {
-
DependentContext.instance().startCollectingDependents(dependentStorageRequest);
- }
DependentContext.instance().setActive(true);
if (disposalMethodBean != null)
disposalMethodBean.invokeDisposeMethod(instance, creationalContext);
@@ -191,8 +185,7 @@
{
if (getDeclaringBean().isDependent())
{
-
DependentContext.instance().stopCollectingDependents(dependentStorageRequest);
-
dependentInstancesStore.destroyDependentInstances(dependentStorageRequest.getKey());
+ creationalContext.release();
}
DependentContext.instance().setActive(false);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -30,7 +30,6 @@
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentStorageRequest;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
@@ -115,23 +114,13 @@
{
DependentContext.instance().setActive(true);
T instance = null;
- DependentStorageRequest dependentStorageRequest = null;
- try
- {
- instance = constructor.newInstance(manager, creationalContext);
- instance = applyDecorators(instance);
- creationalContext.push(instance);
- dependentStorageRequest = DependentStorageRequest.of(dependentInstancesStore,
instance);
-
DependentContext.instance().startCollectingDependents(dependentStorageRequest);
- injectEjbAndCommonFields(instance);
- injectBoundFields(instance, creationalContext);
- callInitializers(instance, creationalContext);
- callPostConstruct(instance);
- }
- finally
- {
-
DependentContext.instance().stopCollectingDependents(dependentStorageRequest);
- }
+ instance = constructor.newInstance(manager, creationalContext);
+ instance = applyDecorators(instance, creationalContext);
+ creationalContext.push(instance);
+ injectEjbAndCommonFields(instance);
+ injectBoundFields(instance, creationalContext);
+ callInitializers(instance, creationalContext);
+ callPostConstruct(instance);
return instance;
}
finally
@@ -151,7 +140,7 @@
{
DependentContext.instance().setActive(true);
callPreDestroy(instance);
- dependentInstancesStore.destroyDependentInstances(instance);
+ creationalContext.release();
}
catch (Exception e)
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -112,7 +112,7 @@
boolean outer;
if (currentCreationalContext.get() == null)
{
- creationalContext =
manager.createCreationalContext().getCreationalContext(bean);
+ creationalContext = manager.createCreationalContext(bean);
currentCreationalContext.set(creationalContext);
outer = true;
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -16,6 +16,10 @@
*/
package org.jboss.webbeans.bean.proxy;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.webbeans.bean.EnterpriseBean;
+
/**
* Interface implemented by all enterprise bean proxies to query/control the proxy
*
@@ -35,6 +39,6 @@
public void setDestroyed(boolean destroyed);
- public void destroy();
+ public void destroy(EnterpriseBean<?> enterpriseBean, CreationalContext<?>
creationalContext);
}
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-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -22,6 +22,8 @@
import javassist.util.proxy.MethodHandler;
+import javax.enterprise.context.spi.CreationalContext;
+
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.introspector.MethodSignature;
@@ -37,7 +39,7 @@
* @author Pete Muir
*
*/
-public class EnterpriseBeanProxyMethodHandler implements MethodHandler, Serializable
+public class EnterpriseBeanProxyMethodHandler<T> implements MethodHandler,
Serializable
{
private static final long serialVersionUID = 2107723373882153667L;
@@ -47,10 +49,12 @@
private static final ThreadLocal<EnterpriseBean<?>> enterpriseBean;
+ private static final ThreadLocal<CreationalContext<?>>
enterpriseBeanCreationalContext;
+
static
{
enterpriseBean = new ThreadLocal<EnterpriseBean<?>>();
-
+ enterpriseBeanCreationalContext = new
ThreadLocal<CreationalContext<?>>();
}
public static EnterpriseBean<?> getEnterpriseBean()
@@ -58,9 +62,18 @@
return enterpriseBean.get();
}
- private static void setEnterpriseBean(EnterpriseBean<?> bean)
+ /**
+ * @return the enterpriseBeanCreationalContext
+ */
+ public static CreationalContext<?> getEnterpriseBeanCreationalContext()
{
+ return enterpriseBeanCreationalContext.get();
+ }
+
+ private static <T> void setEnterpriseBean(EnterpriseBean<T> bean,
CreationalContext<T> creationalContext)
+ {
enterpriseBean.set(bean);
+ enterpriseBeanCreationalContext.set(creationalContext);
}
private final SessionObjectReference reference;
@@ -77,7 +90,7 @@
*
* @param proxy The generic proxy
*/
- public EnterpriseBeanProxyMethodHandler(EnterpriseBean<?> bean)
+ public EnterpriseBeanProxyMethodHandler(EnterpriseBean<T> bean,
CreationalContext<T> creationalContext)
{
this.destroyed = false;
this.objectInterface = bean.getEjbDescriptor().getObjectInterface();
@@ -85,12 +98,12 @@
this.clientCanCallRemoveMethods = bean.isClientCanCallRemoveMethods();
try
{
- setEnterpriseBean(bean);
+ setEnterpriseBean(bean, creationalContext);
this.reference = bean.createReference();
}
finally
{
- setEnterpriseBean(null);
+ setEnterpriseBean(null, null);
}
log.trace("Created enterprise bean proxy method handler for " + bean);
}
Modified: 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-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -32,6 +32,12 @@
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-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/CreationalContextImpl.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -19,51 +19,60 @@
import java.util.HashMap;
import java.util.Map;
+import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
public class CreationalContextImpl<T> implements CreationalContext<T>
{
- private final Map<Bean<?>, Object> incompleteInstances;
- private final Bean<T> bean;
+ private final Map<Contextual<?>, Object> incompleteInstances;
+ private final Contextual<T> contextual;
- public CreationalContextImpl()
+ private final DependentInstancesStore dependentInstancesStore;
+
+ private final DependentInstancesStore parentDependentInstancesStore;
+
+ public CreationalContextImpl(Contextual<T> contextual)
{
- this.incompleteInstances = new HashMap<Bean<?>, Object>();
- this.bean = null;
+ this(contextual, new HashMap<Contextual<?>, Object>(), new
DependentInstancesStore());
}
- private CreationalContextImpl(Bean<T> bean, Map<Bean<?>, Object>
incompleteInstances)
+ private CreationalContextImpl(Contextual<T> contextual,
Map<Contextual<?>, Object> incompleteInstances, DependentInstancesStore
parentDependentInstancesStore)
{
this.incompleteInstances = incompleteInstances;
- this.bean = bean;
+ this.contextual = contextual;
+ this.dependentInstancesStore = new DependentInstancesStore();
+ this.parentDependentInstancesStore = parentDependentInstancesStore;
}
public void push(T incompleteInstance)
{
- incompleteInstances.put(bean, incompleteInstance);
+ incompleteInstances.put(contextual, incompleteInstance);
}
- public <S> CreationalContextImpl<S> getCreationalContext(Bean<S>
bean)
+ public <S> CreationalContextImpl<S>
getCreationalContext(Contextual<S> Contextual)
{
- return new CreationalContextImpl<S>(bean, new HashMap<Bean<?>,
Object>(incompleteInstances));
+ return new CreationalContextImpl<S>(Contextual, new
HashMap<Contextual<?>, Object>(incompleteInstances),
dependentInstancesStore);
}
- public <S> S getIncompleteInstance(Bean<S> bean)
+ public <S> S getIncompleteInstance(Contextual<S> bean)
{
return (S) incompleteInstances.get(bean);
}
- public boolean containsIncompleteInstance(Bean<?> bean)
+ public boolean containsIncompleteInstance(Contextual<?> bean)
{
return incompleteInstances.containsKey(bean);
}
+
+ public DependentInstancesStore getParentDependentInstancesStore()
+ {
+ return parentDependentInstancesStore;
+ }
public void release()
{
- // TODO Auto-generated method stub
-
+ dependentInstancesStore.destroyDependentInstances();
}
}
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-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -28,7 +28,6 @@
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.bootstrap.api.Service;
@@ -48,8 +47,6 @@
}
private final ThreadLocal<AtomicInteger> reentrantActiveCount;
- // A (possible null) request to store dependents created
- private final ThreadLocal<DependentStorageRequest> dependentStorageRequest;
/**
* Constructor
@@ -66,7 +63,6 @@
return new AtomicInteger(0);
}
};
- this.dependentStorageRequest = new ThreadLocal<DependentStorageRequest>();
}
/**
@@ -84,10 +80,11 @@
if (creationalContext != null)
{
T instance = contextual.create(creationalContext);
- if (dependentStorageRequest.get() != null)
+ if (creationalContext instanceof CreationalContextImpl)
{
+ CreationalContextImpl<T> creationalContextImpl =
(CreationalContextImpl<T>) creationalContext;
BeanInstance<T> beanInstance = new
BeanInstanceImpl<T>(contextual, instance, creationalContext);
-
dependentStorageRequest.get().getDependentInstancesStore().addDependentInstance(dependentStorageRequest.get().getKey(),
beanInstance);
+
creationalContextImpl.getParentDependentInstancesStore().addDependentInstance(beanInstance);
}
return instance;
}
@@ -127,45 +124,14 @@
}
}
}
-
- /**
- * Starts collecting dependent instances created by placing in the dependent
- * instances store specified in the request. The request is only honored if
- * there are no current request present.
- *
- * @param dependentStorageRequest The storage request
- */
- public void startCollectingDependents(DependentStorageRequest
dependentStorageRequest)
- {
- if (this.dependentStorageRequest.get() == null)
- {
- this.dependentStorageRequest.set(dependentStorageRequest);
- }
- }
-
- /**
- * Stops collecting dependent instances created. The request is only honored
- * if the request passed is the same that was used for starting the
- * collection
- *
- * @param dependentStorageRequest The storage request
- */
- public void stopCollectingDependents(DependentStorageRequest dependentStorageRequest)
- {
- // Could also be null if we hit the finally block before the collection
- // has started
- if (this.dependentStorageRequest.get() != null &&
this.dependentStorageRequest.get().equals(dependentStorageRequest))
- {
- this.dependentStorageRequest.set(null);
- }
- }
+ @Deprecated
public <T> void destroyAndRemove(Contextual<T> contextual, T instance)
{
- if (contextual instanceof Bean)
+ if (contextual instanceof Contextual)
{
- CreationalContextImpl<T> creationalContext = new
CreationalContextImpl<T>();
- contextual.destroy(instance,
creationalContext.getCreationalContext((Bean<T>) contextual));
+ CreationalContextImpl<T> creationalContext = new
CreationalContextImpl<T>(contextual);
+ contextual.destroy(instance,
creationalContext.getCreationalContext(contextual));
}
}
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-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -16,13 +16,12 @@
*/
package org.jboss.webbeans.context;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.webbeans.context.api.BeanInstance;
-import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
/**
@@ -32,17 +31,17 @@
*/
public class DependentInstancesStore
{
- private static LogProvider log =
Logging.getLogProvider(DependentInstancesStore.class);
+ private static Log log = Logging.getLog(DependentInstancesStore.class);
// A object -> List of contextual instances mapping
- private Map<Object, List<BeanInstance<?>>> dependentInstances;
+ private List<BeanInstance<?>> dependentInstances;
/**
* Creates a new DependentInstancesStore
*/
public DependentInstancesStore()
{
- dependentInstances = new ConcurrentHashMap<Object,
List<BeanInstance<?>>>();
+ dependentInstances = Collections.synchronizedList(new
ArrayList<BeanInstance<?>>());
}
/**
@@ -51,41 +50,35 @@
* @param key The key to store the instance under
* @param contextualInstance The instance to store
*/
- public <T> void addDependentInstance(Object key, BeanInstance<T>
contextualInstance)
+ public <T> void addDependentInstance(BeanInstance<T> contextualInstance)
{
- List<BeanInstance<?>> instances = dependentInstances.get(key);
- if (instances == null)
- {
- instances = new CopyOnWriteArrayList<BeanInstance<?>>();
- dependentInstances.put(key, instances);
- }
- log.trace("Registered dependent instance " + contextualInstance + "
under key " + key);
- instances.add(contextualInstance);
+ log.trace("Registered dependent instance #0", contextualInstance);
+ dependentInstances.add(contextualInstance);
}
/**
- * Destroys all dependent objects associated with a particular key and remove
- * that key from the store
+ * Destroys all dependent objects
*
* @param key The key to remove
*/
- public void destroyDependentInstances(Object key)
+ public void destroyDependentInstances()
{
- log.trace("Destroying dependent instances under key " + key);
- if (!dependentInstances.containsKey(key))
+ log.trace("Destroying dependent instances");
+ for (BeanInstance<?> injectedInstance : dependentInstances)
{
- return;
- }
- for (BeanInstance<?> injectedInstance : dependentInstances.get(key))
- {
destroy(injectedInstance);
}
- dependentInstances.remove(key);
}
private static <T> void destroy(BeanInstance<T> beanInstance)
{
beanInstance.getContextual().destroy(beanInstance.getInstance(),
beanInstance.getCreationalContext());
}
+
+ @Override
+ public String toString()
+ {
+ return "Dependent Instances: " + dependentInstances;
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -22,6 +22,7 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import javax.enterprise.context.spi.CreationalContext;
import javax.interceptor.InvocationContext;
import org.jboss.webbeans.CurrentManager;
@@ -43,6 +44,8 @@
private transient Log log = Logging.getLog(SessionBeanInterceptor.class);
private transient EnterpriseBean<Object> bean;
+ private transient CreationalContext<Object> creationalContext;
+
private String beanId;
private boolean contextual;
@@ -71,13 +74,10 @@
public void preDestroy(InvocationContext invocationContext) throws Exception
{
Object target = invocationContext.getTarget();
- if (bean == null)
- {
- log.warn("Support for destroying passivated EJBs not yet
implemented");
- }
- bean.preDestroy(target);
+ initBean(target.getClass());
if (contextual)
{
+ bean.preDestroy(creationalContext);
EnterpriseBeanInstance instance = getEnterpriseBeanInstance(bean);
if (instance != null)
{
@@ -100,6 +100,7 @@
{
this.bean = bean;
this.contextual = true;
+ this.creationalContext = (CreationalContext<Object>)
EnterpriseBeanProxyMethodHandler.getEnterpriseBeanCreationalContext();
}
else
{
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -1,62 +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.el;
-
-import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentInstancesStore;
-import org.jboss.webbeans.context.DependentStorageRequest;
-
-abstract class RunInDependentContext
-{
-
- private final DependentStorageRequest dependentStorageRequest;
-
- public RunInDependentContext()
- {
- dependentStorageRequest = DependentStorageRequest.of(new DependentInstancesStore(),
new Object());
- }
-
- private void setup()
- {
- DependentContext.instance().setActive(true);
- DependentContext.instance().startCollectingDependents(dependentStorageRequest);
- }
-
- private void cleanup()
- {
- DependentContext.instance().stopCollectingDependents(dependentStorageRequest);
- // TODO kinky
-
dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
- DependentContext.instance().setActive(false);
- }
-
- protected abstract void execute() throws Exception;
-
- public final void run() throws Exception
- {
- try
- {
- setup();
- execute();
- }
- finally
- {
- cleanup();
- }
- }
-
-}
\ No newline at end of file
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolverImpl.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -21,6 +21,7 @@
import javax.el.ELContext;
import javax.el.ELResolver;
+import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.BeanManagerImpl;
@@ -131,20 +132,14 @@
final ValueHolder<Object> holder = new ValueHolder<Object>();
try
{
- new RunInDependentContext()
+
+ Bean<?> bean =
manager.getHighestPrecedenceBean(manager.getBeans(name));
+ CreationalContext<?> creationalContext =
manager.createCreationalContext(bean);
+ if (bean != null)
{
-
- @Override
- protected void execute() throws Exception
- {
- Bean<?> bean =
manager.getHighestPrecedenceBean(manager.getBeans(name));
- if (bean != null)
- {
- holder.setValue(manager.getReference(bean, Object.class));
- }
- }
-
- }.run();
+ holder.setValue(manager.getInjectableReference(bean, creationalContext));
+ }
+ creationalContext.release();
}
catch (Exception e)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -35,9 +35,6 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentInstancesStore;
-import org.jboss.webbeans.context.DependentStorageRequest;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.introspector.WBParameter;
@@ -171,18 +168,13 @@
protected void sendEvent(final T event)
{
Object instance = null;
- DependentStorageRequest dependentStorageRequest = DependentStorageRequest.of(new
DependentInstancesStore(), new Object());
+ CreationalContext<?> creationalContext = null;
try
{
- if (Dependent.class.equals(observerBean.getScopeType()) && observerBean
instanceof RIBean)
- {
-
DependentContext.instance().startCollectingDependents(dependentStorageRequest);
- }
// Get the most specialized instance of the component
- CreationalContext<?> creationalContext = null;
if (!conditional)
{
- creationalContext =
manager.createCreationalContext().getCreationalContext(observerBean);
+ creationalContext = manager.createCreationalContext(observerBean);
}
instance = manager.getInjectableReference(observerBean, creationalContext);
if (instance == null)
@@ -194,10 +186,9 @@
}
finally
{
- if (Dependent.class.equals(observerBean.getScopeType()))
+ if (creationalContext != null &&
Dependent.class.equals(observerBean.getScopeType()))
{
-
DependentContext.instance().stopCollectingDependents(dependentStorageRequest);
-
dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
+ creationalContext.release();
}
}
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -1,11 +1,11 @@
package org.jboss.webbeans.jsf;
import javax.enterprise.context.Conversation;
-import javax.enterprise.inject.spi.BeanManager;
import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
import javax.faces.context.FacesContext;
+import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.CurrentManager;
/**
@@ -51,9 +51,8 @@
public String getActionURL(FacesContext context, String viewId)
{
String actionUrl = super.getActionURL(context, viewId);
- BeanManager beanManager = CurrentManager.rootManager();
- Conversation conversation = (Conversation) beanManager.getReference(
-
(beanManager.getBeans(Conversation.class).iterator().next()),Conversation.class);
+ BeanManagerImpl beanManager = CurrentManager.rootManager();
+ Conversation conversation = beanManager.getInstanceByType(Conversation.class);
if (conversation.isLongRunning())
{
return new
FacesUrlTransformer(actionUrl).appendConversationIdIfNecessary(conversation.getId()).getUrl();
Modified: ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
===================================================================
---
ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -83,7 +83,7 @@
public <T> T createBeanInstance(Bean<T> bean)
{
- return (T) CurrentManager.rootManager().getCurrent().getReference(bean,
Object.class);
+ return (T) CurrentManager.rootManager().getCurrent().getReference(bean,
Object.class, CurrentManager.rootManager().getCurrent().createCreationalContext(bean));
}
public <T> void destroyAndRemoveBeanInstance(Bean<T> bean, T instance)
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java
===================================================================
---
ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -192,7 +192,8 @@
public Object createContextualInstance(Type beanType, Annotation... bindings)
{
- return getCurrentManager().getReference(getBean(beanType, bindings), beanType);
+ Bean<?> bean = getBean(beanType, bindings);
+ return getCurrentManager().getReference(bean, beanType,
getCurrentManager().createCreationalContext(bean));
}
@SuppressWarnings("unchecked")
Modified:
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -176,7 +176,7 @@
public void testBeanBelongingToParentActivityBelongsToChildActivity()
{
assert getBeans(Cow.class).size() == 1;
- Bean<?> bean = getBeans(Cow.class).iterator().next();
+ Contextual<?> bean = getBeans(Cow.class).iterator().next();
BeanManager childActivity = getCurrentManager().createActivity();
assert childActivity.getBeans(Cow.class).size() == 1;
assert childActivity.getBeans(Cow.class).iterator().next().equals(bean);
@@ -186,7 +186,7 @@
public void testBeanBelongingToParentActivityCanBeInjectedIntoChildActivityBean()
{
assert getBeans(Cow.class).size() == 1;
- Bean<?> bean = getBeans(Cow.class).iterator().next();
+ Contextual<?> bean = getBeans(Cow.class).iterator().next();
BeanManager childActivity = getCurrentManager().createActivity();
Bean<?> dummyBean = createDummyBean(childActivity, Cow.class);
childActivity.addBean(dummyBean);
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/named/NamedBeanWithBindingTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/named/NamedBeanWithBindingTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/named/NamedBeanWithBindingTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.test.unit.implementation.named;
+import javax.enterprise.inject.spi.Bean;
+
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -13,7 +15,8 @@
@Test
public void testGetNamedBeanWithBinding()
{
- NamedBeanWithBinding bean = (NamedBeanWithBinding)
getCurrentManager().getReference(getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("namedBeanWithBinding")),
Object.class);
- assert bean != null;
+ Bean<?> bean =
getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("namedBeanWithBinding"));
+ NamedBeanWithBinding instance = (NamedBeanWithBinding)
getCurrentManager().getReference(bean, Object.class,
getCurrentManager().createCreationalContext(bean));
+ assert instance != null;
}
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.test.unit.implementation.producer.method;
+import javax.enterprise.inject.spi.Bean;
+
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -10,9 +12,11 @@
@Test
public void testNamedProducer()
{
- String[] iemon = (String[])
getCurrentManager().getReference(getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("iemon")),
Object.class);
+ Bean<?> iemonBean =
getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("iemon"));
+ String[] iemon = (String[]) getCurrentManager().getReference(iemonBean,
Object.class, getCurrentManager().createCreationalContext(iemonBean));
assert iemon.length == 3;
- String[] itoen = (String[])
getCurrentManager().getReference(getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("itoen")),
Object.class);
+ Bean<?> itoenBean =
getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("itoen"));
+ String[] itoen = (String[]) getCurrentManager().getReference(itoenBean,
Object.class, getCurrentManager().createCreationalContext(itoenBean));
assert itoen.length == 2;
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerWithBindingTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerWithBindingTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/method/NamedProducerWithBindingTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -4,6 +4,8 @@
import java.util.Date;
+import javax.enterprise.inject.spi.Bean;
+
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -17,7 +19,8 @@
@Test
public void testGetNamedProducerWithBinding()
{
- Date date = (Date)
getCurrentManager().getReference(getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("date")),
Object.class);
+ Bean<?> bean =
getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("date"));
+ Date date = (Date) getCurrentManager().getReference(bean, Object.class,
getCurrentManager().createCreationalContext(bean));
assertNotNull(date);
}
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/proxy/ProxyTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/proxy/ProxyTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/proxy/ProxyTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -1,5 +1,7 @@
package org.jboss.webbeans.test.unit.implementation.proxy;
+import javax.enterprise.inject.spi.Bean;
+
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -11,7 +13,8 @@
@Test(description="WBRI-122")
public void testImplementationClassImplementsSerializable()
{
-
getCurrentManager().getReference(getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("foo")),
Object.class);
+ Bean<?> bean =
getCurrentManager().getHighestPrecedenceBean(getCurrentManager().getBeans("foo"));
+ getCurrentManager().getReference(bean, Object.class,
getCurrentManager().createCreationalContext(bean));
}
}
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-06-25
15:27:52 UTC (rev 2891)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/circular/CircularDependencyTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -12,7 +12,6 @@
@Test
public void testCircularInjectionOnTwoNormalBeans() throws Exception
{
- //deployBeans(Pig.class, Food.class);
getCurrentManager().getInstanceByType(Pig.class).getName();
assert Pig.success;
assert Food.success;
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/OldSPIBridge.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/OldSPIBridge.java 2009-06-25
15:27:52 UTC (rev 2891)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/OldSPIBridge.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -22,14 +22,15 @@
@Deprecated
public static <T> T getInstanceByType(BeanManager manager, Class<T>
beanType, Annotation... bindings)
{
- return (T)manager.getReference(ensureUniqueBean(beanType,
manager.getBeans(beanType, bindings)),beanType);
+ Bean<T> bean = (Bean<T>) ensureUniqueBean(beanType,
manager.getBeans(beanType, bindings));
+ return (T)manager.getReference(bean ,beanType,
manager.createCreationalContext(bean));
}
@Deprecated
public static <T> T getInstanceByType(BeanManager manager, TypeLiteral<T>
beanType, Annotation... bindings)
{
-
- return (T) manager.getReference(ensureUniqueBean(beanType.getType(),
manager.getBeans(beanType.getType(), bindings)),beanType.getType());
+ Bean<T> bean = (Bean<T>) ensureUniqueBean(beanType.getType(),
manager.getBeans(beanType.getType(), bindings));
+ return (T) manager.getReference(bean,beanType.getType(),
manager.createCreationalContext(bean));
}
public static Bean<?> ensureUniqueBean(Type type, Set<Bean<?>>
beans)
@@ -61,7 +62,7 @@
else
{
Bean<?> bean = beans.iterator().next();
- return manager.getReference(bean, bean.getTypes().iterator().next());
+ return manager.getReference(bean, bean.getTypes().iterator().next(),
manager.createCreationalContext(bean));
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -6,6 +6,7 @@
import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AnnotationLiteral;
import javax.enterprise.inject.spi.Bean;
@@ -278,11 +279,12 @@
{
assert getBeans(Farm.class).size() == 1;
Bean<Farm> farmBean = getBeans(Farm.class).iterator().next();
- Farm farm = createBeanInstance(farmBean);
+ CreationalContext<Farm> creationalContext =
getCurrentManager().createCreationalContext(farmBean);
+ Farm farm = farmBean.create(creationalContext);
farm.open();
Stable.destroyed = false;
Horse.destroyed = false;
- destroyAndRemoveBeanInstance(farmBean, farm);
+ farmBean.destroy(farm, creationalContext);
assert Stable.destroyed;
assert Horse.destroyed;
}
@@ -309,9 +311,10 @@
assert getCurrentManager().getBeans(FoxRun.class).size() == 1;
Bean<FoxRun> bean = getBeans(FoxRun.class).iterator().next();
- FoxRun instance = createBeanInstance(bean);
+ CreationalContext<FoxRun> creationalContext =
getCurrentManager().createCreationalContext(bean);
+ FoxRun instance = bean.create(creationalContext);
assert instance.fox != instance.anotherFox;
- destroyAndRemoveBeanInstance(bean, instance);
+ bean.destroy(instance, creationalContext);
assert Fox.isDestroyed();
assert Fox.getDestroyCount() == 2;
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/EnterpriseBeanRemoveMethodTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/EnterpriseBeanRemoveMethodTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/remove/EnterpriseBeanRemoveMethodTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -2,6 +2,8 @@
import static org.jboss.testharness.impl.packaging.PackagingType.EAR;
+import javax.enterprise.inject.spi.Bean;
+
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
@@ -34,8 +36,9 @@
{
DependentSessionInterface sessionBean =
getInstanceByType(DependentSessionInterface.class);
sessionBean.remove();
+ Bean<?> bean =
getCurrentManager().getBeans(StateKeeper.class).iterator().next();
StateKeeper stateKeeper = (StateKeeper)
-
getCurrentManager().getReference(getCurrentManager().getBeans(StateKeeper.class).iterator().next(),StateKeeper.class);
+ getCurrentManager().getReference(bean,StateKeeper.class,
getCurrentManager().createCreationalContext(bean));
assert stateKeeper.isRemoveCalled();
}
}.run();
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -166,14 +166,13 @@
public void testContextualDestroyDisposesWhenNecessary() throws Exception
{
final Bean<Goose> gooseBean = getBeans(Goose.class).iterator().next();
- final Goose goose = getInstanceByType(Goose.class);
+ CreationalContext<Goose> creationalContext =
getCurrentManager().createCreationalContext(gooseBean);
+ final Goose goose = gooseBean.create(creationalContext);
assert !EggProducer.isEggDisposed();
assert !Egg.isEggDestroyed();
- destroyAndRemoveBeanInstance(gooseBean, goose);
+ gooseBean.destroy(goose, creationalContext);
assert EggProducer.isEggDisposed();
- //TODO Apparently Dependent scoped injected objects do not have their PreDestroy
method called
- //assert Egg.isEggDestroyed();
}
@Test(groups = "beanLifecycle")
@@ -195,8 +194,9 @@
public void testDependentsDestroyedAfterPreDestroy()
{
Bean<FishPond> pondBean = getBeans(FishPond.class).iterator().next();
- FishPond fishPond = getInstanceByType(FishPond.class);
- destroyAndRemoveBeanInstance(pondBean, fishPond);
+ CreationalContext<FishPond> creationalContext =
getCurrentManager().createCreationalContext(pondBean);
+ FishPond fishPond = pondBean.create(creationalContext);
+ pondBean.destroy(fishPond, creationalContext);
assert Salmon.isBeanDestroyed();
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -37,7 +37,7 @@
protected void execute() throws Exception
{
Bean<Fox> foxBean = getBeans(Fox.class).iterator().next();
- Fox fox = (Fox) getCurrentManager().getReference(foxBean,Fox.class);
+ Fox fox = (Fox) getCurrentManager().getReference(foxBean,Fox.class,
getCurrentManager().createCreationalContext(foxBean));
assert !getCurrentConfiguration().getBeans().isProxy(fox);
}
@@ -62,7 +62,7 @@
public void testClientProxyInvocation()
{
Bean<TunedTuna> tunaBean = getBeans(TunedTuna.class).iterator().next();
- TunedTuna tuna = (TunedTuna) getCurrentManager().getReference(tunaBean,
TunedTuna.class);
+ TunedTuna tuna = (TunedTuna) getCurrentManager().getReference(tunaBean,
TunedTuna.class, getCurrentManager().createCreationalContext(tunaBean));
assert getCurrentConfiguration().getBeans().isProxy(tuna);
assert tuna.getState().equals("tuned");
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -31,7 +31,7 @@
getBeans(ObtainsInjectionPointBean.class).iterator().next();
ObtainsInjectionPointBean injectionPoint = (ObtainsInjectionPointBean)
-
getCurrentManager().getReference(injectionPointBean,ObtainsInjectionPointBean.class);
+
getCurrentManager().getReference(injectionPointBean,ObtainsInjectionPointBean.class,
getCurrentManager().createCreationalContext(injectionPointBean));
assert injectionPoint.getPaymentProcessor() instanceof Instance;
}
@@ -47,7 +47,7 @@
getBeans(ObtainsInjectionPointBean.class).iterator().next();
ObtainsInjectionPointBean injectionPoint = (ObtainsInjectionPointBean)
- getCurrentManager().getReference( injectionPointBean,
ObtainsInjectionPointBean.class);
+ getCurrentManager().getReference( injectionPointBean,
ObtainsInjectionPointBean.class,
getCurrentManager().createCreationalContext(injectionPointBean));
assert injectionPoint.getPaymentProcessor().get() instanceof
ChequePaymentProcessor;
}
@@ -59,7 +59,7 @@
getBeans(ObtainsInjectionPointBean.class).iterator().next();
ObtainsInjectionPointBean injectionPoint = (ObtainsInjectionPointBean)
-
getCurrentManager().getReference(injectionPointBean,ObtainsInjectionPointBean.class);
+
getCurrentManager().getReference(injectionPointBean,ObtainsInjectionPointBean.class,
getCurrentManager().createCreationalContext(injectionPointBean));
injectionPoint.getPaymentProcessor().get(new PayByBinding() { public PaymentMethod
value() { return CHEQUE; }});
}
@@ -71,7 +71,7 @@
getBeans(ObtainsInjectionPointBean.class).iterator().next();
ObtainsInjectionPointBean injectionPoint = (ObtainsInjectionPointBean)
-
getCurrentManager().getReference(injectionPointBean,ObtainsInjectionPointBean.class);
+
getCurrentManager().getReference(injectionPointBean,ObtainsInjectionPointBean.class,
getCurrentManager().createCreationalContext(injectionPointBean));
injectionPoint.getPaymentProcessor().get(new NonBinding() );
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java 2009-06-25
15:27:52 UTC (rev 2891)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/ManagerTest.java 2009-06-25
20:27:55 UTC (rev 2892)
@@ -77,6 +77,6 @@
public void testGetReferenceReturnsContextualInstance()
{
Bean<FishFarmOffice> bean =
getBeans(FishFarmOffice.class).iterator().next();
- assert getCurrentManager().getReference(bean,FishFarmOffice.class) instanceof
FishFarmOffice;
+ assert getCurrentManager().getReference(bean,FishFarmOffice.class,
getCurrentManager().createCreationalContext(bean)) instanceof FishFarmOffice;
}
}