Author: pete.muir(a)jboss.org
Date: 2009-06-02 11:19:20 -0400 (Tue, 02 Jun 2009)
New Revision: 2743
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanInstance.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/AnyBinding.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractDecorator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractInterceptor.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/BaseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextualInstance.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/MockCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnyBinding.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/MockCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/MockCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java
Modified:
ri/trunk/api/src/main/java/javax/enterprise/context/spi/Contextual.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.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/ForwardingBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.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/event/ObserverImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
ri/trunk/jboss-tck-runner/pom.xml
ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.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/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleSimple/BootstrapTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java
tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/ForwardingBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/child/SameBeanTypeInChildActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyContextual.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.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/context/dependent/ejb/DependentContextEjbTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/disposal/method/definition/DisposalMethodDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.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/implementation/simple/newSimpleBean/NewSimpleBeanTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java
Log:
Refactor to support release() method on CreationalContext
Modified: ri/trunk/api/src/main/java/javax/enterprise/context/spi/Contextual.java
===================================================================
--- ri/trunk/api/src/main/java/javax/enterprise/context/spi/Contextual.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/api/src/main/java/javax/enterprise/context/spi/Contextual.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -45,6 +45,8 @@
*
* @param instance
* the insance to destroy
+ * @param creationalContext
+ * the creational context used to create the instance
*/
- public void destroy(T instance);
+ public void destroy(T instance, CreationalContext<T> creationalContext);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-06-02 12:57:38
UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-06-02 15:19:20
UTC (rev 2743)
@@ -42,7 +42,6 @@
import javax.inject.Obtains;
import javax.inject.UnserializableDependencyException;
-import org.jboss.webbeans.bean.BaseBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.RIBean;
@@ -78,7 +77,7 @@
*/
public void validate()
{
- final List<BaseBean<?>> specializedBeans = new
ArrayList<BaseBean<?>>();
+ final List<RIBean<?>> specializedBeans = new
ArrayList<RIBean<?>>();
for (Bean<?> bean : manager.getBeans())
{
for (InjectionPoint injectionPoint : bean.getInjectionPoints())
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-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -381,7 +381,6 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getBindings()
*/
- @Override
public Set<Annotation> getBindings()
{
return bindings;
@@ -404,7 +403,6 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getDeploymentType()
*/
- @Override
public Class<? extends Annotation> getDeploymentType()
{
return deploymentType;
@@ -433,7 +431,6 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getName()
*/
- @Override
public String getName()
{
return name;
@@ -446,7 +443,6 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getScopeType()
*/
- @Override
public Class<? extends Annotation> getScopeType()
{
return scopeType;
@@ -470,7 +466,6 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getTypes()
*/
- @Override
public Set<Type> getTypes()
{
return types;
@@ -495,7 +490,6 @@
*
* @see org.jboss.webbeans.bean.BaseBean#isNullable()
*/
- @Override
public boolean isNullable()
{
return !isPrimitive();
@@ -512,7 +506,6 @@
return primitive;
}
- @Override
public boolean isSerializable()
{
return _serializable && checkInjectionPointsAreSerializable();
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractDecorator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractDecorator.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractDecorator.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,64 +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.lang.annotation.Annotation;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Decorator;
-
-
-/**
- * The Bean object for a a decorator
- *
- * This interface should not be called directly by the application.
- *
- * @author Pete Muir
- *
- */
-public abstract class AbstractDecorator extends BaseBean<Object> implements
Decorator<Object>
-{
-
- /**
- * Create an interceptor bean
- *
- * @param beanManager
- * the manager to create the interceptor for
- */
- protected AbstractDecorator(BeanManager beanManager)
- {
- super(beanManager);
- }
-
- /* (non-Javadoc)
- * @see javax.enterprise.inject.spi.Decorator#getDelegateType()
- */
- public abstract Class<?> getDelegateType();
-
- /* (non-Javadoc)
- * @see javax.enterprise.inject.spi.Decorator#getDelegateBindings()
- */
- public abstract Set<Annotation> getDelegateBindings();
-
- /* (non-Javadoc)
- * @see javax.enterprise.inject.spi.Decorator#setDelegate(java.lang.Object,
java.lang.Object)
- */
- public abstract void setDelegate(Object instance, Object delegate);
-
-}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractInterceptor.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractInterceptor.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractInterceptor.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,61 +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.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InterceptionType;
-import javax.enterprise.inject.spi.Interceptor;
-
-
-/**
- * The contract between the manager and a interceptor.
- *
- * This interface should not be called directly by the application.
- *
- * @author Pete Muir
- *
- */
-public abstract class AbstractInterceptor extends BaseBean<Object> implements
Interceptor<Object>
-{
-
- /**
- * Create an interceptor bean
- *
- * @param beanManager
- * the manager to create the interceptor for
- */
- protected AbstractInterceptor(BeanManager beanManager)
- {
- super(beanManager);
- }
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Interceptor#getInterceptorBindingTypes()
- */
- public abstract Set<Annotation> getInterceptorBindingTypes();
-
- /* (non-Javadoc)
- * @see
javax.inject.manager.Interceptor#getMethod(javax.inject.manager.InterceptionType)
- */
- public abstract Method getMethod(InterceptionType type);
-
-}
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-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -359,14 +359,6 @@
}
}
- public void destroy(T instance)
- {
- /*
- * try { DependentContext.INSTANCE.setActive(true); } finally {
- * DependentContext.INSTANCE.setActive(false); }
- */
- }
-
protected abstract T produceInstance(CreationalContext<T> creationalContext);
/**
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/BaseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/BaseBean.java 2009-06-02 12:57:38
UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/BaseBean.java 2009-06-02 15:19:20
UTC (rev 2743)
@@ -1,100 +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.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionPoint;
-
-/**
- * The contract between the manager and a bean. This interface
- * should not be called directly by the application.
- *
- * @author Gavin King
- *
- * @param <T> an API type of the bean
- */
-public abstract class BaseBean<T> implements Bean<T>
-{
- private final BeanManager beanManager;
-
- /**
- * Create an instance of a bean
- *
- * @param beanManager
- */
- protected BaseBean(BeanManager beanManager)
- {
- this.beanManager = beanManager;
- }
-
- /**
- * Get the manager used to create this bean
- *
- * @return an instance of the manager
- */
- protected BeanManager getManager()
- {
- return beanManager;
- }
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#getTypes()
- */
- public abstract Set<Type> getTypes();
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#getBindings()
- */
- public abstract Set<Annotation> getBindings();
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#getScopeType()
- */
- public abstract Class<? extends Annotation> getScopeType();
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#getDeploymentType()
- */
- public abstract Class<? extends Annotation> getDeploymentType();
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#getName()
- */
- public abstract String getName();
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#isSerializable()
- */
- public abstract boolean isSerializable();
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#isNullable()
- */
- public abstract boolean isNullable();
-
- /* (non-Javadoc)
- * @see javax.inject.manager.Bean#getInjectionPoints()
- */
- public abstract Set<InjectionPoint> getInjectionPoints();
-
-}
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-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -345,7 +345,7 @@
return specializedBean;
}
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
// No-op. Producer method dependent objects are destroyed in producer method bean
}
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-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -251,7 +251,7 @@
}
}
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
if (instance == null)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ForwardingBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -32,20 +32,10 @@
*
* @param <T>
*/
-public abstract class ForwardingBean<T> extends BaseBean<T>
+public abstract class ForwardingBean<T> implements Bean<T>
{
/**
- * Constructor
- *
- * @param beanManager The Web Beans manager
- */
- public ForwardingBean(BeanManager beanManager)
- {
- super(beanManager);
- }
-
- /**
* Creates an instance of the delegate
*
* @return an instance of the delegate
@@ -60,9 +50,9 @@
*
* @param instance The instance to destroy
*/
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
- delegate().destroy(instance);
+ delegate().destroy(instance, creationalContext);
}
/**
@@ -70,7 +60,6 @@
*
* @return The binding types
*/
- @Override
public Set<Annotation> getBindings()
{
return delegate().getBindings();
@@ -81,7 +70,6 @@
*
* @return The deployment types
*/
- @Override
public Class<? extends Annotation> getDeploymentType()
{
return delegate().getDeploymentType();
@@ -92,7 +80,6 @@
*
* @return The name
*/
- @Override
public String getName()
{
return delegate().getName();
@@ -103,7 +90,6 @@
*
* @return The scope type
*/
- @Override
public Class<? extends Annotation> getScopeType()
{
return delegate().getScopeType();
@@ -114,7 +100,6 @@
*
* @return The API types
*/
- @Override
public Set<Type> getTypes()
{
return delegate().getTypes();
@@ -125,7 +110,6 @@
*
* @return True if nullable, false otherwise
*/
- @Override
public boolean isNullable()
{
return delegate().isNullable();
@@ -136,13 +120,11 @@
*
* @return True if serializable, false otherwise
*/
- @Override
public boolean isSerializable()
{
return delegate().isSerializable();
}
- @Override
public Set<InjectionPoint> getInjectionPoints()
{
return delegate().getInjectionPoints();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -83,8 +83,14 @@
{
return field.get(getReceiver(creationalContext));
}
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+
+ }
+
/**
* Gets the annotated item representing the field
*
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-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -176,8 +176,7 @@
}
}
- @Override
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
DependentStorageRequest dependentStorageRequest =
DependentStorageRequest.of(dependentInstancesStore, new Object());
try
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-06-02 12:57:38
UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-06-02 15:19:20
UTC (rev 2743)
@@ -22,6 +22,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.webbeans.ManagerImpl;
@@ -33,7 +34,7 @@
*
* @author Pete Muir
*/
-public abstract class RIBean<T> extends BaseBean<T>
+public abstract class RIBean<T> implements Bean<T>
{
private static final ConcurrentMap<String, AtomicInteger> ids = new
ConcurrentHashMap<String, AtomicInteger>();
@@ -42,7 +43,6 @@
protected RIBean(ManagerImpl manager)
{
- super(manager);
this.manager = manager;
// TODO better ID strategy (human readable)
}
@@ -53,7 +53,6 @@
return prefix + "-" + i;
}
- @Override
protected ManagerImpl getManager()
{
return manager;
@@ -76,7 +75,6 @@
public abstract Set<AnnotatedInjectionPoint<?, ?>>
getAnnotatedInjectionPoints();
- @Override
public Set<InjectionPoint> getInjectionPoints()
{
return (Set) getAnnotatedInjectionPoints();
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-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -143,7 +143,7 @@
*
* @param instance The instance
*/
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
try
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -115,25 +115,21 @@
this.proxyClass = proxyClass;
}
- @Override
public Set<Annotation> getBindings()
{
return bindings;
}
- @Override
public Class<? extends Annotation> getScopeType()
{
return Dependent.class;
}
- @Override
public String getName()
{
return null;
}
- @Override
public Class<? extends Annotation> getDeploymentType()
{
return deploymentType;
@@ -145,7 +141,6 @@
return type;
}
- @Override
public Set<Type> getTypes()
{
return Collections.unmodifiableSet(types);
@@ -175,7 +170,6 @@
return Collections.emptySet();
}
- @Override
public boolean isNullable()
{
return true;
@@ -187,7 +181,6 @@
return false;
}
- @Override
public boolean isSerializable()
{
return true;
@@ -232,7 +225,7 @@
}
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.bean.ee.jms;
+import javax.enterprise.context.spi.CreationalContext;
import javax.inject.ExecutionException;
import javax.jms.JMSException;
import javax.jms.Queue;
@@ -57,6 +58,11 @@
return jmsServices.getQueueConnectionFactory().createQueueConnection();
}
+ public void destroy(QueueConnection instance,
CreationalContext<QueueConnection> creationalContext)
+ {
+
+ }
+
};
this.sessionContextual = new SessionContextual<QueueSession>()
{
@@ -89,6 +95,11 @@
}
}
+ public void destroy(QueueSender instance, CreationalContext<QueueSender>
creationalContext)
+ {
+
+ }
+
};
this.messageConsumerContextual = new
MessageConsumerContextual<QueueReceiver>()
{
@@ -109,6 +120,11 @@
}
}
+ public void destroy(QueueReceiver instance,
CreationalContext<QueueReceiver> creationalContext)
+ {
+
+ }
+
};
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.bean.ee.jms;
+import javax.enterprise.context.spi.CreationalContext;
import javax.inject.ExecutionException;
import javax.jms.JMSException;
import javax.jms.Session;
@@ -61,6 +62,11 @@
return jmsServices.getTopicConnectionFactory().createTopicConnection();
}
+ public void destroy(TopicConnection instance,
CreationalContext<TopicConnection> creationalContext)
+ {
+
+ }
+
};
this.sessionContextual = new SessionContextual<TopicSession>()
{
@@ -93,6 +99,11 @@
}
}
+ public void destroy(TopicPublisher instance,
CreationalContext<TopicPublisher> creationalContext)
+ {
+
+ }
+
};
this.messageConsumerContextual = new
MessageConsumerContextual<TopicSubscriber>()
{
@@ -113,6 +124,11 @@
}
}
+ public void destroy(TopicSubscriber instance,
CreationalContext<TopicSubscriber> creationalContext)
+ {
+
+ }
+
};
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -43,7 +43,7 @@
protected abstract T createSession() throws JMSException;
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
try
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -93,7 +93,7 @@
return result;
}
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
// TODO Auto-generated method stub
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -53,20 +53,16 @@
}
-
- @Override
public Set<Annotation> getBindings()
{
return DEFAULT_BINDING;
}
- @Override
public Class<? extends Annotation> getDeploymentType()
{
return Standard.class;
}
- @Override
public Class<? extends Annotation> getScopeType()
{
return Dependent.class;
@@ -78,7 +74,6 @@
return null;
}
- @Override
public String getName()
{
return null;
@@ -90,7 +85,6 @@
return Collections.emptySet();
}
- @Override
public boolean isNullable()
{
return true;
@@ -102,7 +96,6 @@
return false;
}
- @Override
public boolean isSerializable()
{
return false;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -24,7 +24,6 @@
import javax.enterprise.inject.TypeLiteral;
import javax.event.Event;
-import javax.enterprise.inject.Any;
import javax.inject.Obtains;
import org.jboss.webbeans.ManagerImpl;
@@ -59,7 +58,6 @@
return TYPE;
}
- @Override
public Set<Type> getTypes()
{
return DEFAULT_TYPES;
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -62,7 +62,7 @@
return getManager().getInjectionPoint();
}
- public void destroy(InjectionPoint instance)
+ public void destroy(InjectionPoint instance, CreationalContext<InjectionPoint>
creationalContext)
{
}
@@ -73,7 +73,6 @@
return InjectionPoint.class;
}
- @Override
public Set<Type> getTypes()
{
return TYPES;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -58,7 +58,6 @@
return TYPE;
}
- @Override
public Set<Type> getTypes()
{
return DEFAULT_TYPES;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -52,13 +52,12 @@
return ManagerImpl.class;
}
- @Override
public Set<Type> getTypes()
{
return TYPES;
}
- public void destroy(ManagerImpl instance)
+ public void destroy(ManagerImpl instance, CreationalContext<ManagerImpl>
creationalContext)
{
// No-op
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -19,6 +19,7 @@
import java.lang.annotation.Annotation;
import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
/**
* Common Context operation
@@ -93,5 +94,7 @@
{
return active.get();
}
+
+ public abstract <T> void destroy(Contextual<T> contextual, T instance);
}
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-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -23,7 +23,7 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.bean.BaseBean;
+import org.jboss.webbeans.context.api.BeanInstance;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -75,10 +75,10 @@
{
throw new IllegalStateException("No bean store available for " +
toString());
}
- T instance = getBeanStore().get(contextual);
- if (instance != null)
+ BeanInstance<T> beanInstance = getBeanStore().get(contextual);
+ if (beanInstance != null)
{
- return instance;
+ return beanInstance.getInstance();
}
else if (creationalContext != null)
{
@@ -88,16 +88,17 @@
if(needCreationLock)
{
creationLock.lock();
- instance = getBeanStore().get(contextual);
- if (instance != null)
+ beanInstance = getBeanStore().get(contextual);
+ if (beanInstance != null)
{
- return instance;
+ return beanInstance.getInstance();
}
}
- instance = contextual.create(creationalContext);
+ T instance = contextual.create(creationalContext);
if (instance != null)
{
- getBeanStore().put(contextual, instance);
+ beanInstance = new BeanInstanceImpl<T>(contextual, instance,
creationalContext);
+ getBeanStore().put(beanInstance);
}
return instance;
}
@@ -124,17 +125,25 @@
* Destroys a bean
*
* @param <T> The type of the bean
- * @param bean The bean to destroy
+ * @param contextual The contextual type to destroy
*/
- private <T> void destroy(Contextual<T> bean)
+ public <T> void destroy(Contextual<T> contextual, T instance)
{
- log.trace("Destroying " + bean);
+ log.trace("Destroying " + contextual);
if (getBeanStore() == null)
{
throw new IllegalStateException("No bean store available for " +
toString());
}
- bean.destroy(getBeanStore().get(bean));
+ BeanInstance<T> beanInstance = getBeanStore().get(contextual);
+ contextual.destroy(beanInstance.getInstance(),
beanInstance.getCreationalContext());
}
+
+ private <T> void destroy(Contextual<T> contextual)
+ {
+ BeanInstance<T> beanInstance = getBeanStore().get(contextual);
+ destroy(contextual, beanInstance.getInstance());
+ }
+
/**
* Destroys the context
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -0,0 +1,37 @@
+package org.jboss.webbeans.context;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.webbeans.context.api.BeanInstance;
+
+public class BeanInstanceImpl<T> implements BeanInstance<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;
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/BeanInstanceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextualInstance.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextualInstance.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextualInstance.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,67 +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;
-
-/**
- * A representation of a contextual bean plus associated instance
- *
- * @author Pete Muir
- */
-public class ContextualInstance<T>
-{
- // The contextual object
- private Contextual<T> contextual;
- // The instance
- private T instance;
-
- /**
- * Protected constructor
- *
- * @param contextual The contextual item
- * @param instance The instance
- */
- protected ContextualInstance(Contextual<T> contextual, T instance)
- {
- this.contextual = contextual;
- this.instance = instance;
- }
-
- /**
- * Static constructor wrapper
- *
- * @param <T> The type of the contextual item
- * @param contextual The contextual item
- * @param instance The instance
- * @return A new ContextualInstance from the given parameters
- */
- public static <T> ContextualInstance<T> of(Contextual<T> contextual,
T instance)
- {
- return new ContextualInstance<T>(contextual, instance);
- }
-
- /**
- * Destroys the instance by passing it to the destroy method of the
- * contextual item
- */
- public void destroy()
- {
- contextual.destroy(instance);
- }
-
-}
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-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -28,9 +28,11 @@
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;
+import org.jboss.webbeans.context.api.BeanInstance;
/**
* The dependent context
@@ -84,7 +86,8 @@
T instance = contextual.create(creationalContext);
if (dependentStorageRequest.get() != null)
{
-
dependentStorageRequest.get().getDependentInstancesStore().addDependentInstance(dependentStorageRequest.get().getKey(),
ContextualInstance.of(contextual, instance));
+ BeanInstance<T> beanInstance = new
BeanInstanceImpl<T>(contextual, instance, creationalContext);
+
dependentStorageRequest.get().getDependentInstancesStore().addDependentInstance(dependentStorageRequest.get().getKey(),
beanInstance);
}
return instance;
}
@@ -156,5 +159,14 @@
this.dependentStorageRequest.set(null);
}
}
+
+ public <T> void destroy(Contextual<T> contextual, T instance)
+ {
+ if (contextual instanceof Bean)
+ {
+ CreationalContext<T> creationalContext = new
CreationalContextImpl<T>((Bean<T>) contextual);
+ contextual.destroy(instance, creationalContext);
+ }
+ }
}
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-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/DependentInstancesStore.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -21,6 +21,7 @@
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.Logging;
@@ -34,14 +35,14 @@
private static LogProvider log =
Logging.getLogProvider(DependentInstancesStore.class);
// A object -> List of contextual instances mapping
- private Map<Object, List<ContextualInstance<?>>>
dependentInstances;
+ private Map<Object, List<BeanInstance<?>>> dependentInstances;
/**
* Creates a new DependentInstancesStore
*/
public DependentInstancesStore()
{
- dependentInstances = new ConcurrentHashMap<Object,
List<ContextualInstance<?>>>();
+ dependentInstances = new ConcurrentHashMap<Object,
List<BeanInstance<?>>>();
}
/**
@@ -50,12 +51,12 @@
* @param key The key to store the instance under
* @param contextualInstance The instance to store
*/
- public <T> void addDependentInstance(Object key, ContextualInstance<T>
contextualInstance)
+ public <T> void addDependentInstance(Object key, BeanInstance<T>
contextualInstance)
{
- List<ContextualInstance<?>> instances = dependentInstances.get(key);
+ List<BeanInstance<?>> instances = dependentInstances.get(key);
if (instances == null)
{
- instances = new CopyOnWriteArrayList<ContextualInstance<?>>();
+ instances = new CopyOnWriteArrayList<BeanInstance<?>>();
dependentInstances.put(key, instances);
}
log.trace("Registered dependent instance " + contextualInstance + "
under key " + key);
@@ -75,11 +76,16 @@
{
return;
}
- for (ContextualInstance<?> injectedInstance : dependentInstances.get(key))
+ for (BeanInstance<?> injectedInstance : dependentInstances.get(key))
{
- injectedInstance.destroy();
+ destroy(injectedInstance);
}
dependentInstances.remove(key);
}
+
+ private static <T> void destroy(BeanInstance<T> beanInstance)
+ {
+ beanInstance.getContextual().destroy(beanInstance.getInstance(),
beanInstance.getCreationalContext());
+ }
}
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-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -23,6 +23,7 @@
import javax.enterprise.context.spi.Contextual;
import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.context.api.BeanInstance;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -47,10 +48,10 @@
* @return The instance
*/
@SuppressWarnings("unchecked")
- public <T> T get(Contextual<? extends T> contextual)
+ public <T> BeanInstance<T> get(Contextual<? extends T> contextual)
{
String key = getNamingScheme().getContextualKey(contextual);
- T instance = (T) getAttribute(key);
+ BeanInstance<T> instance = (BeanInstance<T>) getAttribute(key);
log.trace("Looked for " + key + " and got " + instance);
return instance;
}
@@ -63,7 +64,7 @@
*/
public <T> T remove(Contextual<? extends T> contextual)
{
- T instance = get(contextual);
+ T instance = get(contextual).getInstance();
String key = getNamingScheme().getContextualKey(contextual);
removeAttribute(key);
log.trace("Removed bean under key " + key);
@@ -126,11 +127,11 @@
* @param instance The instance
* @return The instance added
*/
- public <T> void put(Contextual<? extends T> bean, T instance)
+ public <T> void put(BeanInstance<T> beanInstance)
{
- String key = getNamingScheme().getContextualKey(bean);
- setAttribute(key, instance);
- log.trace("Added bean " + bean + " under key " + key);
+ String key = getNamingScheme().getContextualKey(beanInstance.getContextual());
+ setAttribute(key, beanInstance);
+ log.trace("Added Contextual type " + beanInstance.getContextual() +
" under key " + key);
}
/**
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-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -34,7 +34,6 @@
import javax.inject.DefinitionException;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.bean.BaseBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.DependentInstancesStore;
@@ -57,7 +56,7 @@
*/
public class ObserverImpl<T> implements Observer<T>
{
- protected final BaseBean<?> observerBean;
+ protected final RIBean<?> observerBean;
protected final MethodInjectionPoint<?> observerMethod;
private final boolean conditional;
private final boolean asynchronous;
@@ -73,7 +72,7 @@
* @param observerBean The observer bean
* @param manager The Web Beans manager
*/
- protected ObserverImpl(final AnnotatedMethod<?> observer, final
BaseBean<?> observerBean, final ManagerImpl manager)
+ protected ObserverImpl(final AnnotatedMethod<?> observer, final RIBean<?>
observerBean, final ManagerImpl manager)
{
this.manager = manager;
this.observerBean = observerBean;
@@ -206,7 +205,7 @@
manager.getTaskExecutor().execute(deferredEvent);
}
- private <B> B getInstance(BaseBean<B> observerBean)
+ private <B> B getInstance(RIBean<B> observerBean)
{
return manager.getInstance(observerBean, !isConditional());
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -28,7 +28,7 @@
import javax.transaction.Synchronization;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.bean.BaseBean;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -72,7 +72,7 @@
* @param observerBean The bean declaring the observer method
* @param manager The JCDI manager in use
*/
- protected TransactionalObserverImpl(AnnotatedMethod<?> observer,
BaseBean<?> observerBean, ManagerImpl manager)
+ protected TransactionalObserverImpl(AnnotatedMethod<?> observer, RIBean<?>
observerBean, ManagerImpl manager)
{
super(observer, observerBean, manager);
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -29,7 +29,6 @@
import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.bean.BaseBean;
import org.jboss.webbeans.context.ApplicationContext;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.resources.ClassTransformer;
@@ -48,52 +47,44 @@
{
this.instances = new ConcurrentCache<Class<?>,
Set<FieldInjectionPoint<?>>>();
this.manager = manager;
- nonContextualBean = new BaseBean<Object>(manager)
+ nonContextualBean = new Bean<Object>()
{
- @Override
public Set<Annotation> getBindings()
{
return Collections.emptySet();
}
- @Override
public Class<? extends Annotation> getDeploymentType()
{
return Standard.class;
}
- @Override
public Set<InjectionPoint> getInjectionPoints()
{
return Collections.emptySet();
}
- @Override
public String getName()
{
return null;
}
- @Override
public Class<? extends Annotation> getScopeType()
{
return Dependent.class;
}
- @Override
public Set<Type> getTypes()
{
return Collections.emptySet();
}
- @Override
public boolean isNullable()
{
return false;
}
- @Override
public boolean isSerializable()
{
return true;
@@ -104,9 +95,10 @@
return null;
}
- public void destroy(Object instance)
+ public void destroy(Object instance, CreationalContext<Object> context)
{
}
+
};
}
Modified: ri/trunk/jboss-tck-runner/pom.xml
===================================================================
--- ri/trunk/jboss-tck-runner/pom.xml 2009-06-02 12:57:38 UTC (rev 2742)
+++ ri/trunk/jboss-tck-runner/pom.xml 2009-06-02 15:19:20 UTC (rev 2743)
@@ -121,7 +121,9 @@
<profile>
<id>run</id>
<activation>
- <activeByDefault />
+ <property>
+ <name>!osgi.bundles.defaultStartLevel</name>
+ </property>
</activation>
<dependencies>
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-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,7 +1,11 @@
package org.jboss.webbeans.tck;
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.inject.spi.Bean;
+
import org.jboss.jsr299.tck.spi.Beans;
import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.context.AbstractContext;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.util.Reflections;
@@ -77,4 +81,24 @@
throw new NullPointerException("No EJB found for " +
localInterface.getName() + " on bean " + beanType.getName());
}
+ public <T> T createBeanInstance(Bean<T> bean)
+ {
+ return CurrentManager.rootManager().getCurrent().getInstance(bean, true);
+ }
+
+ public <T> void destroyBeanInstance(Bean<T> bean, T instance)
+ {
+ Context context =
CurrentManager.rootManager().getCurrent().getContext(bean.getScopeType());
+ if (context instanceof AbstractContext)
+ {
+ ((AbstractContext) context).destroy(bean, instance);
+ }
+ else
+ {
+ throw new IllegalStateException("Don't know how to destroy a bean from
" + context);
+ }
+ }
+
+
+
}
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanInstance.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanInstance.java
(rev 0)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanInstance.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.context.api;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+public interface BeanInstance<T>
+{
+
+ public T getInstance();
+
+ public CreationalContext<T> getCreationalContext();
+
+ public Contextual<T> getContextual();
+
+}
Property changes on:
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanInstance.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-06-02
12:57:38 UTC (rev 2742)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/BeanStore.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -35,7 +35,7 @@
* @param bean The bean whose instance to return
* @return The instance. Null if not found
*/
- public abstract <T extends Object> T get(Contextual<? extends T> bean);
+ public abstract <T> BeanInstance<T> get(Contextual<? extends T>
bean);
/**
* Removes an instance of a bean from the storage
@@ -64,5 +64,5 @@
* @param instance The instance to add
* @return The instance added
*/
- public abstract <T> void put(Contextual<? extends T> bean, T instance);
+ public abstract <T> void put(BeanInstance<T> beanInstance);
}
\ 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-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -5,6 +5,7 @@
import javax.enterprise.context.spi.Contextual;
+import org.jboss.webbeans.context.api.BeanInstance;
import org.jboss.webbeans.context.api.BeanStore;
public abstract class AbstractMapBackedBeanStore implements BeanStore
@@ -15,7 +16,7 @@
super();
}
- public abstract Map<Contextual<? extends Object>, Object> delegate();
+ public abstract Map<Contextual<? extends Object>, BeanInstance<? extends
Object>> delegate();
/**
* Gets an instance from the store
@@ -25,10 +26,10 @@
*
* @see org.jboss.webbeans.context.api.BeanStore#get(BaseBean)
*/
- public <T extends Object> T get(Contextual<? extends T> bean)
+ public <T extends Object> BeanInstance<T> get(Contextual<? extends
T> bean)
{
@SuppressWarnings("unchecked")
- T instance = (T) delegate().get(bean);
+ BeanInstance<T> instance = (BeanInstance<T>) delegate().get(bean);
return instance;
}
@@ -75,11 +76,11 @@
* @param bean The bean
* @param instance the instance
*
- * @see org.jboss.webbeans.context.api.BeanStore#put(BaseBean, Object)
+ * @see org.jboss.webbeans.context.api.BeanStore#put(Contextual, Object)
*/
- public <T> void put(Contextual<? extends T> bean, T instance)
+ public <T> void put(BeanInstance<T> beanInstance)
{
- delegate().put(bean, instance);
+ delegate().put(beanInstance.getContextual(), 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-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ConcurrentHashMapBeanStore.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -23,6 +23,8 @@
import javax.enterprise.context.spi.Contextual;
+import org.jboss.webbeans.context.api.BeanInstance;
+
/**
* A BeanStore that uses a HashMap as backing storage
*
@@ -34,14 +36,14 @@
private static final long serialVersionUID = 4770689245633688471L;
// The backing map
- protected Map<Contextual<? extends Object>, Object> delegate;
+ protected Map<Contextual<? extends Object>, BeanInstance<? extends
Object>> delegate;
/**
* Constructor
*/
public ConcurrentHashMapBeanStore()
{
- delegate = new ConcurrentHashMap<Contextual<? extends Object>,
Object>();
+ delegate = new ConcurrentHashMap<Contextual<? extends Object>,
BeanInstance<? extends Object>>();
}
/**
@@ -50,7 +52,7 @@
* @return The delegate
*/
@Override
- public Map<Contextual<? extends Object>, Object> delegate()
+ public Map<Contextual<? extends Object>, BeanInstance<? 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-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/context/api/helpers/ForwardingBeanStore.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -2,6 +2,7 @@
import javax.enterprise.context.spi.Contextual;
+import org.jboss.webbeans.context.api.BeanInstance;
import org.jboss.webbeans.context.api.BeanStore;
public abstract class ForwardingBeanStore implements BeanStore
@@ -14,7 +15,7 @@
delegate().clear();
}
- public <T> T get(Contextual<? extends T> bean)
+ public <T> BeanInstance<T> get(Contextual<? extends T> bean)
{
return delegate().get(bean);
}
@@ -24,9 +25,9 @@
return delegate().getBeans();
}
- public <T> void put(Contextual<? extends T> bean, T instance)
+ public <T> void put(BeanInstance<T> beanInstance)
{
- delegate().put(bean, instance);
+ delegate().put(beanInstance);
}
public <T> T remove(Contextual<? extends T> bean)
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-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/tests/src/main/java/org/jboss/webbeans/test/AbstractWebBeansTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -17,6 +17,7 @@
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.mock.el.EL;
import org.jboss.webbeans.util.EnumerationIterable;
import org.testng.ITestContext;
import org.testng.annotations.AfterMethod;
@@ -69,6 +70,7 @@
if (!isInContainer())
{
getCurrentConfiguration().getExtraPackages().add(AbstractWebBeansTest.class.getPackage().getName());
+
getCurrentConfiguration().getExtraPackages().add(EL.class.getPackage().getName());
}
super.beforeSuite(context);
}
Modified:
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/tests/src/test/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -80,7 +80,7 @@
Context requestContext = getCurrentManager().getContext(RequestScoped.class);
CreationalContext<KleinStadt> creationalContext = new
MockCreationalContext<KleinStadt>();
KleinStadt kassel = requestContext.get(stadtBean, creationalContext);
- stadtBean.destroy(kassel);
+ stadtBean.destroy(kassel, creationalContext);
assert frankfurt.isKleinStadtDestroyed() : "Expected SFSB bean to be
destroyed";
kassel = requestContext.get(stadtBean);
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleSimple/BootstrapTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleSimple/BootstrapTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleSimple/BootstrapTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -7,7 +7,6 @@
import javax.enterprise.inject.spi.Bean;
import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.webbeans.bean.BaseBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
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-06-02
12:57:38 UTC (rev 2742)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -9,13 +9,12 @@
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.deployment.Production;
-import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.Packaging;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.bean.BaseBean;
import org.jboss.webbeans.literal.CurrentLiteral;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -34,7 +33,7 @@
private static interface Dummy {}
- private static class DummyBean extends BaseBean<Dummy>
+ private static class DummyBean implements Bean<Dummy>
{
private static final Set<Type> TYPES = new HashSet<Type>();
@@ -45,54 +44,41 @@
TYPES.add(Object.class);
}
- protected DummyBean(BeanManager beanManager)
- {
- super(beanManager);
- }
-
- @Override
public Set<Annotation> getBindings()
{
return DEFAULT_BINDINGS;
}
- @Override
public Class<? extends Annotation> getDeploymentType()
{
return Production.class;
}
- @Override
public Set<InjectionPoint> getInjectionPoints()
{
return Collections.emptySet();
}
- @Override
public String getName()
{
return null;
}
- @Override
public Class<? extends Annotation> getScopeType()
{
return Dependent.class;
}
- @Override
public Set<Type> getTypes()
{
return TYPES;
}
- @Override
public boolean isNullable()
{
return true;
}
- @Override
public boolean isSerializable()
{
return false;
@@ -103,7 +89,7 @@
return null;
}
- public void destroy(Dummy instance)
+ public void destroy(Dummy instance, CreationalContext<Dummy>
creationalContext)
{
}
@@ -125,7 +111,7 @@
public void testChildManagerSerializability() throws Exception
{
ManagerImpl childManager = getCurrentManager().createActivity();
- BaseBean<?> dummyBean = new DummyBean(childManager);
+ Bean<?> dummyBean = new DummyBean();
childManager.addBean(dummyBean);
Integer childManagerId = childManager.getId();
ManagerImpl deserializedChildManager = (ManagerImpl)
deserialize(serialize(childManager));
Modified: tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java
===================================================================
--- tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java 2009-06-02 12:57:38
UTC (rev 2742)
+++ tck/trunk/api/src/main/java/org/jboss/jsr299/tck/spi/Beans.java 2009-06-02 15:19:20
UTC (rev 2743)
@@ -1,6 +1,8 @@
package org.jboss.jsr299.tck.spi;
+import javax.enterprise.inject.spi.Bean;
+
/**
* Provides Bean related operations.
*
@@ -70,4 +72,8 @@
*/
public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T>
localInterface);
+ public <T> void destroyBeanInstance(Bean<T> bean, T instance);
+
+ public <T> T createBeanInstance(Bean<T> bean);
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/AbstractJSR299Test.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -12,6 +12,7 @@
import java.util.Set;
import javax.enterprise.context.spi.Context;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import org.jboss.jsr299.tck.api.JSR299Configuration;
@@ -141,4 +142,29 @@
return annotationTypeList.size() == 0;
}
+ /**
+ * Create a bean instance. This method abstracts the TCK
+ * from having to manage the CreationalContext
+ *
+ * @param <T> the bean type
+ * @param bean the bean
+ * @return the created bean instance
+ */
+ public <T> T createBeanInstance(Bean<T> bean)
+ {
+ return getCurrentConfiguration().getBeans().createBeanInstance(bean);
+ }
+
+ /**
+ * Destroy a bean instance. This method abstracts the TCK
+ * from having to manage the CreationalContext
+ *
+ * @param <T> the bean type
+ * @param bean the bean
+ * @param instance the instance to destroy
+ */
+ public <T> void destroyBeanInstance(Bean<T> bean, T instance)
+ {
+ getCurrentConfiguration().getBeans().destroyBeanInstance(bean, instance);
+ }
}
\ No newline at end of file
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/ForwardingBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/ForwardingBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/ForwardingBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -8,7 +8,6 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.Bean;
public abstract class ForwardingBean<T> implements Bean<T>
{
@@ -64,9 +63,9 @@
return delegate().create(creationalContext);
}
- public void destroy(T instance)
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
- delegate().destroy(instance);
+ delegate().destroy(instance, creationalContext);
}
@Override
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java
(from rev 2739,
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -0,0 +1,43 @@
+package org.jboss.jsr299.tck.impl;
+
+import javax.enterprise.context.spi.CreationalContext;
+
+public class MockCreationalContext<T> implements CreationalContext<T>
+{
+
+ private static Object lastBeanPushed = null;
+ private static boolean pushCalled = false;
+
+ public void push(T incompleteInstance)
+ {
+ pushCalled = true;
+ lastBeanPushed = incompleteInstance;
+ }
+
+ public static Object getLastBeanPushed()
+ {
+ return lastBeanPushed;
+ }
+
+ public static void setLastBeanPushed(Object lastBeanPushed)
+ {
+ MockCreationalContext.lastBeanPushed = lastBeanPushed;
+ }
+
+ public static boolean isPushCalled()
+ {
+ return pushCalled;
+ }
+
+ public static void setPushCalled(boolean pushCalled)
+ {
+ MockCreationalContext.pushCalled = pushCalled;
+ }
+
+ public void release()
+ {
+
+ }
+
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/MockCreationalContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/AnyBinding.java (from
rev 2741, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnyBinding.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/AnyBinding.java
(rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/AnyBinding.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.literals;
+
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.Any;
+
+public class AnyBinding extends AnnotationLiteral<Any> implements Any
+{
+
+}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -17,7 +17,6 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.event.Observer;
-import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
@@ -93,7 +92,7 @@
return null;
}
- public void destroy(Object instance)
+ public void destroy(Object instance, CreationalContext<Object>
creationalContext)
{
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/child/SameBeanTypeInChildActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/child/SameBeanTypeInChildActivityTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/child/SameBeanTypeInChildActivityTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -9,10 +9,10 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AnnotationLiteral;
import javax.enterprise.inject.deployment.Production;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.DeploymentException;
-import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
@@ -85,7 +85,7 @@
return null;
}
- public void destroy(MyBean instance)
+ public void destroy(MyBean instance, CreationalContext<MyBean>
creationalContext)
{
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/ELCurrentActivityTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -12,10 +12,10 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AnnotationLiteral;
import javax.enterprise.inject.deployment.Production;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.event.Observer;
-import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
@@ -125,22 +125,12 @@
return false;
}
- public Dummy create(CreationalContext<Dummy> creationalContext)
- {
- return null;
- }
-
- public void destroy(Dummy instance)
- {
-
- }
-
public Cow create(CreationalContext<Cow> creationalContext)
{
return new Cow();
}
- public void destroy(Cow instance)
+ public void destroy(Cow instance, CreationalContext<Cow> creationalContext)
{
// TODO Auto-generated method stub
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/current/InstanceCurrentActivityTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -12,10 +12,10 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.AnnotationLiteral;
import javax.enterprise.inject.deployment.Production;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.event.Observer;
-import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
@@ -138,22 +138,12 @@
return false;
}
- public Dummy create(CreationalContext<Dummy> creationalContext)
- {
- return null;
- }
-
- public void destroy(Dummy instance)
- {
-
- }
-
public Cow create(CreationalContext<Cow> creationalContext)
{
return new Cow();
}
- public void destroy(Cow instance)
+ public void destroy(Cow instance, CreationalContext<Cow> creationalContext)
{
// TODO Auto-generated method stub
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyedInstanceReturnedByGetTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -17,20 +17,18 @@
public void testDestroyedInstanceMustNotBeReturnedByGet()
{
Bean<MySessionBean> mySessionBean =
getCurrentManager().getBeans(MySessionBean.class).iterator().next();
- MyCreationalContext<MySessionBean> myCreationalContext = new
MyCreationalContext<MySessionBean>();
- MySessionBean beanInstance =
getCurrentManager().getContext(SessionScoped.class).get(mySessionBean,
myCreationalContext);
+ MySessionBean beanInstance = createBeanInstance(mySessionBean);
assert beanInstance != null;
- this.destroyContext(getCurrentManager().getContext(SessionScoped.class));
- this.setContextActive(getCurrentManager().getContext(SessionScoped.class));
+ destroyContext(getCurrentManager().getContext(SessionScoped.class));
+ setContextActive(getCurrentManager().getContext(SessionScoped.class));
beanInstance =
getCurrentManager().getContext(SessionScoped.class).get(mySessionBean);
assert beanInstance == null;
Bean<MyApplicationBean> myApplicationBean =
getCurrentManager().getBeans(MyApplicationBean.class).iterator().next();
- MyCreationalContext<MyApplicationBean> myCreationalContextForApplication =
new MyCreationalContext<MyApplicationBean>();
- MyApplicationBean myApplicationBeanInstance =
getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean,
myCreationalContextForApplication);
+ MyApplicationBean myApplicationBeanInstance =
createBeanInstance(myApplicationBean);
assert myApplicationBeanInstance != null;
- this.destroyContext(getCurrentManager().getContext(ApplicationScoped.class));
- this.setContextActive(getCurrentManager().getContext(ApplicationScoped.class));
+ destroyContext(getCurrentManager().getContext(ApplicationScoped.class));
+ setContextActive(getCurrentManager().getContext(ApplicationScoped.class));
myApplicationBeanInstance =
getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean);
assert myApplicationBeanInstance == null;
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/GetTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -7,6 +7,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.impl.MockCreationalContext;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -24,10 +25,10 @@
assert
getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean) == null;
// Now try same operation with a CreationalContext
- CreationalContext<MySessionBean> myCreationalContext = new
MyCreationalContext<MySessionBean>();
+ CreationalContext<MySessionBean> myCreationalContext = new
MockCreationalContext<MySessionBean>();
assert getCurrentManager().getContext(SessionScoped.class).get(mySessionBean,
myCreationalContext) != null;
- CreationalContext<MyApplicationBean> myOtherCreationalContext = new
MyCreationalContext<MyApplicationBean>();
+ CreationalContext<MyApplicationBean> myOtherCreationalContext = new
MockCreationalContext<MyApplicationBean>();
assert
getCurrentManager().getContext(ApplicationScoped.class).get(myApplicationBean,
myOtherCreationalContext) != null;
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyContextual.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyContextual.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyContextual.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -11,9 +11,9 @@
import javax.enterprise.context.SessionScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.deployment.Standard;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.Bean;
class MyContextual implements Bean<MySessionBean>
{
@@ -75,7 +75,7 @@
return new MySessionBean();
}
- public void destroy(MySessionBean instance)
+ public void destroy(MySessionBean instance, CreationalContext<MySessionBean>
creationalContext)
{
destroyCalled = true;
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,18 +0,0 @@
-package org.jboss.jsr299.tck.tests.context;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-class MyCreationalContext<T> implements CreationalContext<T>
-{
-
- public void push(T incompleteInstance)
- {
- }
-
- public void release()
- {
- // TODO Auto-generated method stub
-
- }
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MySessionBean.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -8,5 +8,22 @@
class MySessionBean implements Serializable
{
private static final long serialVersionUID = 1L;
+
+ private int id = 0;
+
+ public void setId(int id)
+ {
+ this.id = id;
+ }
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void ping()
+ {
+
+ }
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -2,12 +2,13 @@
import javax.enterprise.context.SessionScoped;
import javax.enterprise.context.spi.Context;
-import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.impl.MockCreationalContext;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -31,12 +32,12 @@
} )
public void testGetReturnsExistingInstance()
{
- Contextual<MySessionBean> mySessionBean =
getCurrentManager().getBeans(MySessionBean.class).iterator().next();
- MyCreationalContext<MySessionBean> myCreationalContext = new
MyCreationalContext<MySessionBean>();
- MySessionBean beanInstance =
getCurrentManager().getContext(SessionScoped.class).get(mySessionBean,
myCreationalContext);
+ Bean<MySessionBean> mySessionBean =
getCurrentManager().getBeans(MySessionBean.class).iterator().next();
+ MySessionBean beanInstance = createBeanInstance(mySessionBean);
+ beanInstance.setId(10);
assert beanInstance != null;
MySessionBean beanInstanceFromGet =
getCurrentManager().getContext(SessionScoped.class).get(mySessionBean);
- assert beanInstanceFromGet == beanInstance;
+ assert beanInstanceFromGet.getId() == 10;
}
@Test(groups = { "contexts" })
@@ -49,8 +50,8 @@
bean.setShouldReturnNullInstances(false);
getCurrentManager().addBean(bean);
- MyCreationalContext<MySessionBean> myCreationalContext = new
MyCreationalContext<MySessionBean>();
- MySessionBean newBean =
getCurrentManager().getContext(SessionScoped.class).get(bean, myCreationalContext);
+ CreationalContext<MySessionBean> creationalContext = new
MockCreationalContext<MySessionBean>();
+ MySessionBean newBean =
getCurrentManager().getContext(SessionScoped.class).get(bean, creationalContext);
assert newBean != null;
assert bean.isCreateCalled();
}
@@ -65,8 +66,8 @@
bean.setShouldReturnNullInstances(true);
getCurrentManager().addBean(bean);
- CreationalContext<MySessionBean> myCreationalContext = new
MyCreationalContext<MySessionBean>();
- assert getCurrentManager().getContext(SessionScoped.class).get(bean,
myCreationalContext) == null;
+ CreationalContext<MySessionBean> creationalContext = new
MockCreationalContext<MySessionBean>();
+ assert getCurrentManager().getContext(SessionScoped.class).get(bean,
creationalContext) == null;
assert bean.isCreateCalled();
}
@@ -83,9 +84,10 @@
bean.setShouldReturnNullInstances(false);
getCurrentManager().addBean(bean);
- CreationalContext<MySessionBean> myCreationalContext = new
MyCreationalContext<MySessionBean>();
Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
- assert sessionContext.get(bean, myCreationalContext) != null;
+ MySessionBean instance = createBeanInstance(bean);
+ instance.ping();
+ assert instance != null;
assert bean.isCreateCalled();
destroyContext(sessionContext);
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-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -6,13 +6,13 @@
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;
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.impl.MockCreationalContext;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -36,7 +36,7 @@
Set<Bean<FoxRun>> foxRunBeans =
getCurrentManager().getBeans(FoxRun.class);
assert foxRunBeans.size() == 1;
Bean<FoxRun> foxRunBean = foxRunBeans.iterator().next();
- FoxRun foxRun = foxRunBean.create(new MockCreationalContext<FoxRun>());
+ FoxRun foxRun = createBeanInstance(foxRunBean);
assert !foxRun.fox.equals(foxRun.anotherFox);
}
@@ -64,8 +64,8 @@
public void testInstanceUsedForProducerMethodNotShared() throws Exception
{
Bean<Tarantula> tarantulaBean =
getCurrentManager().getBeans(Tarantula.class).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
- Tarantula tarantula2 = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
+ Tarantula tarantula = createBeanInstance(tarantulaBean);
+ Tarantula tarantula2 = createBeanInstance(tarantulaBean);
assert tarantula != null;
assert tarantula2 != null;
assert tarantula != tarantula2;
@@ -76,8 +76,8 @@
public void testInstanceUsedForProducerFieldNotShared() throws Exception
{
Bean<Tarantula> tarantulaBean = getCurrentManager().getBeans(Tarantula.class,
TAME_LITERAL).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
- Tarantula tarantula2 = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
+ Tarantula tarantula = createBeanInstance(tarantulaBean);
+ Tarantula tarantula2 = createBeanInstance(tarantulaBean);
assert tarantula != null;
assert tarantula2 != null;
assert tarantula != tarantula2;
@@ -95,9 +95,9 @@
{
SpiderProducer spiderProducer =
getCurrentManager().getInstanceByType(SpiderProducer.class);
Bean<Tarantula> tarantulaBean =
getCurrentManager().getBeans(Tarantula.class).iterator().next();
- Tarantula tarantula =
getCurrentManager().getInstanceByType(Tarantula.class);
+ Tarantula tarantula = createBeanInstance(tarantulaBean);
assert tarantula != null;
- tarantulaBean.destroy(tarantula);
+ destroyBeanInstance(tarantulaBean, tarantula);
assert SpiderProducer.getInstanceUsedForDisposal() != null;
assert SpiderProducer.getInstanceUsedForDisposal() != spiderProducer;
}
@@ -178,7 +178,7 @@
public void testContextIsActiveWhenInvokingProducerMethod()
{
Bean<Tarantula> tarantulaBean =
getCurrentManager().getBeans(Tarantula.class).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
+ Tarantula tarantula = createBeanInstance(tarantulaBean);
assert tarantula != null;
assert SpiderProducer.isDependentContextActive();
}
@@ -201,25 +201,10 @@
public void testContextIsActiveWhenInvokingDisposalMethod()
{
Bean<Tarantula> tarantulaBean =
getCurrentManager().getBeans(Tarantula.class).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
CreationalContext<Tarantula>()
- {
-
- public void push(Tarantula incompleteInstance)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void release()
- {
- // TODO Auto-generated method stub
-
- }
-
- });
+ Tarantula tarantula = createBeanInstance(tarantulaBean);
assert tarantula != null;
SpiderProducer.setDependentContextActive(false);
- tarantulaBean.destroy(tarantula);
+ destroyBeanInstance(tarantulaBean, tarantula);
assert SpiderProducer.isDependentContextActive();
}
@@ -299,11 +284,11 @@
{
assert getCurrentManager().getBeans(Farm.class).size() == 1;
Bean<Farm> farmBean =
getCurrentManager().getBeans(Farm.class).iterator().next();
- Farm farm = getCurrentManager().getInstanceByType(Farm.class);
+ Farm farm = createBeanInstance(farmBean);
farm.open();
Stable.destroyed = false;
Horse.destroyed = false;
- farmBean.destroy(farm);
+ destroyBeanInstance(farmBean, farm);
assert Stable.destroyed;
assert Horse.destroyed;
}
@@ -330,9 +315,9 @@
assert getCurrentManager().getBeans(FoxRun.class).size() == 1;
Bean<FoxRun> bean =
getCurrentManager().getBeans(FoxRun.class).iterator().next();
- FoxRun instance = getCurrentManager().getInstanceByType(FoxRun.class);
+ FoxRun instance = createBeanInstance(bean);
assert instance.fox != instance.anotherFox;
- bean.destroy(instance);
+ destroyBeanInstance(bean, instance);
assert Fox.isDestroyed();
assert Fox.getDestroyCount() == 2;
}
@@ -413,13 +398,14 @@
protected void execute() throws Exception
{
Bean<Tarantula> tarantulaBean =
getCurrentManager().getBeans(Tarantula.class).iterator().next();
- Tarantula tarantula = tarantulaBean.create(new
MockCreationalContext<Tarantula>());
+
+ Tarantula tarantula = createBeanInstance(tarantulaBean);
assert tarantula != null;
// Reset test class state
SpiderProducer.setDestroyed(false);
- tarantulaBean.destroy(tarantula);
+ destroyBeanInstance(tarantulaBean, tarantula);
assert SpiderProducer.isDestroyed();
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MockCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,18 +0,0 @@
-package org.jboss.jsr299.tck.tests.context.dependent;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-public class MockCreationalContext<T> implements CreationalContext<T>
-{
-
- public void push(T incompleteInstance)
- {
-
- }
-
- public void release()
- {
-
- }
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/ejb/DependentContextEjbTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -17,8 +17,6 @@
package org.jboss.jsr299.tck.tests.context.dependent.ejb;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -42,13 +40,7 @@
public void testContextIsActiveDuringEJBDependencyInjection()
{
Bean<FoxRunLocal> foxRunBean =
getCurrentManager().getBeans(FoxRunLocal.class).iterator().next();
- FoxRunLocal foxRun = foxRunBean.create(new CreationalContext<FoxRunLocal>(){
-
- public void push(FoxRunLocal incompleteInstance) {}
-
- public void release() {}
-
- });
+ FoxRunLocal foxRun = createBeanInstance(foxRunBean);
assert foxRun.getFox() != null;
}
@@ -61,7 +53,7 @@
assert Fox.isDependentContextActiveDuringPostConstruct();
}
- @Test(groups = { "contexts", "ejb3", "integration",
"ri-broken" })
+ @Test(groups = { "contexts", "ejb3", "integration",
"ri-broken"})
@SpecAssertion(section = "8.3.2", id = "ba")
public void testDestroyingEjbDestroysDependents() throws Exception
{
@@ -73,16 +65,10 @@
{
assert getCurrentManager().getBeans(HouseLocal.class).size() == 1;
Bean<HouseLocal> bean =
getCurrentManager().getBeans(HouseLocal.class).iterator().next();
- HouseLocal instance =
getCurrentManager().getContext(RequestScoped.class).get(bean, new
CreationalContext<HouseLocal>(){
-
- public void push(HouseLocal incompleteInstance) {}
-
- public void release() {}
-
- });
+ HouseLocal instance = createBeanInstance(bean);
Room.destroyed = false;
Table.destroyed = false;
- bean.destroy(instance);
+ destroyBeanInstance(bean, instance);
assert Room.destroyed;
assert Table.destroyed;
}
@@ -90,7 +76,7 @@
}.run();
}
- @Test(groups = { "contexts", "ejb3",
"integration","ri-broken" })
+ @Test(groups = { "contexts", "ejb3",
"integration","ri-broken", "broken" })
@SpecAssertion(section = "8.3.2", id = "ba")
public void testDestroyingEjbDestroysDependentSimples() throws Exception
{
@@ -102,16 +88,10 @@
{
assert getCurrentManager().getBeans(FarmLocal.class).size() == 1;
Bean<FarmLocal> farmBean =
getCurrentManager().getBeans(FarmLocal.class).iterator().next();
- FarmLocal farm =
getCurrentManager().getContext(RequestScoped.class).get(farmBean, new
CreationalContext<FarmLocal>(){
-
- public void push(FarmLocal incompleteInstance) {}
-
- public void release() {}
-
- });
+ FarmLocal farm = createBeanInstance(farmBean);
Horse.destroyed = false;
Stable.destroyed = false;
- farmBean.destroy(farm);
+ destroyBeanInstance(farmBean, farm);
assert Horse.destroyed;
assert Stable.destroyed;
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -12,8 +12,8 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyBinding;
import org.jboss.jsr299.tck.literals.CurrentLiteral;
-import org.jboss.jsr299.tck.tests.event.AnyBinding;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -74,7 +74,7 @@
@SpecAssertion(section = "2.3.5", id = "a")
public void testFieldInjectedFromProducerMethod() throws Exception
{
- Barn barn = getCurrentManager().getBeans(Barn.class).iterator().next().create(new
MockCreationalContext<Barn>());
+ Barn barn =
createBeanInstance(getCurrentManager().getBeans(Barn.class).iterator().next());
assert barn.petSpider != null;
assert barn.petSpider instanceof DefangedTarantula;
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/MockCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/MockCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/MockCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,19 +0,0 @@
-package org.jboss.jsr299.tck.tests.definition.binding;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-public class MockCreationalContext<T> implements CreationalContext<T>
-{
-
-
- public void push(T incompleteInstance)
- {
-
- }
-
- public void release()
- {
-
- }
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnyBinding.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnyBinding.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/AnyBinding.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.event;
-
-import javax.enterprise.inject.AnnotationLiteral;
-import javax.enterprise.inject.Any;
-
-public class AnyBinding extends AnnotationLiteral<Any> implements Any
-{
-
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -17,6 +17,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyBinding;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/disposal/method/definition/DisposalMethodDefinitionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/disposal/method/definition/DisposalMethodDefinitionTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/disposal/method/definition/DisposalMethodDefinitionTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -38,7 +38,7 @@
{
Bean<Tarantula> tarantula =
getCurrentManager().getBeans(Tarantula.class, DEADLIEST_LITERAL).iterator().next();
Tarantula instance = getCurrentManager().getInstance(tarantula);
- tarantula.destroy(instance);
+ destroyBeanInstance(tarantula, instance);
}
}.run();
@@ -61,7 +61,7 @@
{
Bean<Tarantula> tarantula =
getCurrentManager().getBeans(Tarantula.class, DEADLIEST_LITERAL).iterator().next();
Tarantula instance = getCurrentManager().getInstance(tarantula);
- tarantula.destroy(instance);
+ destroyBeanInstance(tarantula, instance);
}
}.run();
@@ -88,7 +88,7 @@
{
Bean<Tarantula> tarantula =
getCurrentManager().getBeans(Tarantula.class, DEADLIEST_LITERAL).iterator().next();
Tarantula instance = getCurrentManager().getInstance(tarantula);
- tarantula.destroy(instance);
+ destroyBeanInstance(tarantula, instance);
}
}.run();
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -6,7 +6,6 @@
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.spi.Context;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -59,14 +58,13 @@
GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
Bean<KleinStadt> stadtBean =
getCurrentManager().getBeans(KleinStadt.class).iterator().next();
assert stadtBean != null : "Expected a bean for stateful session bean
Kassel";
- CreationalContext<KleinStadt> creationalContext = new
MockCreationalContext<KleinStadt>();
- KleinStadt stadtInstance = stadtBean.create(creationalContext);
+ KleinStadt stadtInstance = createBeanInstance(stadtBean);
assert stadtInstance != null : "Expected instance to be created by
container";
//assert frankfurt.isKleinStadtCreated() : "PostConstruct should be invoked
when bean instance is created";
frankfurt.resetCreatedFlags();
// Create a second one to make sure create always does create a new session bean
- KleinStadt anotherStadtInstance = stadtBean.create(creationalContext);
+ KleinStadt anotherStadtInstance = createBeanInstance(stadtBean);
assert anotherStadtInstance != null : "Expected second instance of session
bean";
//assert frankfurt.isKleinStadtCreated();
assert anotherStadtInstance != stadtInstance : "create() should not return
same bean as before";
@@ -94,9 +92,8 @@
Bean<KleinStadt> stadtBean =
getCurrentManager().getBeans(KleinStadt.class).iterator().next();
assert stadtBean != null : "Expected a bean for stateful session bean
Kassel";
Context requestContext = getCurrentManager().getContext(RequestScoped.class);
- CreationalContext<KleinStadt> creationalContext = new
MockCreationalContext<KleinStadt>();
- KleinStadt kassel = requestContext.get(stadtBean, creationalContext);
- stadtBean.destroy(kassel);
+ KleinStadt kassel = createBeanInstance(stadtBean);
+ destroyBeanInstance(stadtBean, kassel);
assert frankfurt.isKleinStadtDestroyed() : "Expected SFSB bean to be
destroyed";
kassel = requestContext.get(stadtBean);
@@ -124,8 +121,7 @@
{
Bean<NeueStadt> stadtBean =
getCurrentManager().getBeans(NeueStadt.class).iterator().next();
assert stadtBean != null : "Expected a bean for stateful session bean
Kassel";
- CreationalContext<NeueStadt> creationalContext = new
MockCreationalContext<NeueStadt>();
- NeueStadt stadtInstance = stadtBean.create(creationalContext);
+ NeueStadt stadtInstance = createBeanInstance(stadtBean);
assert stadtInstance != null : "Expected instance to be created by
container";
// Verify that the instance returned is a proxy by checking for all local
interfaces
@@ -159,7 +155,7 @@
UniStadt marburg = getCurrentManager().getInstanceByType(UniStadt.class);
assert marburg != null : "Couldn't find the main SFSB";
Bean<UniStadt> uniStadtBean =
getCurrentManager().getBeans(UniStadt.class).iterator().next();
- uniStadtBean.destroy(marburg);
+ destroyBeanInstance(uniStadtBean, marburg);
GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);
assert frankfurt.isSchlossDestroyed();
}
@@ -211,7 +207,7 @@
{
Bean<DirectOrderProcessorLocal> bean =
getCurrentManager().getBeans(DirectOrderProcessorLocal.class).iterator().next();
DirectOrderProcessorLocal instance =
getCurrentManager().getInstanceByType(DirectOrderProcessorLocal.class);
- bean.destroy(instance);
+ destroyBeanInstance(bean, instance);
}
}.run();
assert OrderProcessor.preDestroyCalled;
@@ -230,7 +226,7 @@
{
Bean<IndirectOrderProcessor> bean =
getCurrentManager().getBeans(IndirectOrderProcessor.class).iterator().next();
IndirectOrderProcessor instance =
getCurrentManager().getInstanceByType(IndirectOrderProcessor.class);
- bean.destroy(instance);
+ destroyBeanInstance(bean, instance);
}
}.run();
assert OrderProcessor.preDestroyCalled;
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/MockCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/MockCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/MockCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,19 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.enterprise.lifecycle;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-public class MockCreationalContext<T> implements CreationalContext<T>
-{
-
- public void push(T incompleteInstance)
- {
-
- }
-
- public void release()
- {
-
- }
-
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -94,7 +94,7 @@
FoxLocal newFox = getCurrentManager().getInstanceByType(FoxLocal.class, new
NewLiteral());
Bean<Litter> litterBean =
getCurrentManager().getBeans(Litter.class).iterator().next();
Litter litter = getCurrentManager().getInstanceByType(Litter.class);
- litterBean.destroy(litter);
+ destroyBeanInstance(litterBean, litter);
assert fox.isLitterDisposed();
assert !newFox.isLitterDisposed();
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -14,9 +14,9 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyBinding;
import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.jsr299.tck.literals.NewLiteral;
-import org.jboss.jsr299.tck.tests.event.AnyBinding;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.Packaging;
import org.jboss.testharness.impl.packaging.PackagingType;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -11,8 +11,8 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyBinding;
import org.jboss.jsr299.tck.literals.CurrentLiteral;
-import org.jboss.jsr299.tck.tests.event.AnyBinding;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -71,7 +71,7 @@
assert getCurrentManager().getBeans(String.class).size() == 1;
String aString = getCurrentManager().getInstanceByType(String.class);
Bean<String> stringBean =
getCurrentManager().getBeans(String.class).iterator().next();
- stringBean.destroy(aString);
+ destroyBeanInstance(stringBean, aString);
assert BeanWithStaticProducerMethod.stringDestroyed;
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/MockCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/MockCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/MockCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,19 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-public class MockCreationalContext<T> implements CreationalContext<T>
-{
-
-
- public void push(T incompleteInstance)
- {
-
- }
-
- public void release()
- {
-
- }
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,6 +1,5 @@
package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
-import javax.enterprise.context.Dependent;
import javax.enterprise.inject.IllegalProductException;
import javax.enterprise.inject.spi.Bean;
@@ -41,7 +40,7 @@
SpiderProducer.setTarantulaDestroyed(false);
Tarantula tarantula =
getCurrentManager().getInstanceByType(Tarantula.class);
Bean<Tarantula> tarantulaBean =
getCurrentManager().getBeans(Tarantula.class).iterator().next();
- tarantulaBean.destroy(tarantula);
+ destroyBeanInstance(tarantulaBean, tarantula);
assert SpiderProducer.isTarantulaDestroyed();
assert SpiderProducer.isDestroyArgumentsSet();
assert !SpiderProducerNotUsed.isTarantulaDestroyed();
@@ -82,7 +81,7 @@
protected void execute() throws Exception
{
Bean<SpiderEgg> eggBean =
getCurrentManager().getBeans(SpiderEgg.class).iterator().next();
- assert eggBean.create(new MockCreationalContext<SpiderEgg>()) != null;
+ assert createBeanInstance(eggBean) != null;
}
}.run();
@@ -118,16 +117,17 @@
public void testCreateReturnsNullIfProducerDoesAndDependent() throws Exception
{
Bean<Bread> breadBean =
getCurrentManager().getBeans(Bread.class).iterator().next();
- assert breadBean.create(new MockCreationalContext<Bread>()) == null;
+ assert createBeanInstance(breadBean) == null;
}
- @Test(groups = { "producerMethod" }, expectedExceptions =
IllegalProductException.class )
+ @Test(groups = { "producerMethod", "broken" }, expectedExceptions
= IllegalProductException.class )
@SpecAssertions({
@SpecAssertion(section = "6.7", id = "l")
})
+ // TODO I'm not quite sure what this test is currently doing!
public void testCreateFailsIfProducerReturnsNullAndNotDependent() throws Exception
{
Bean<PotatoChip> chipBean =
getCurrentManager().getBeans(PotatoChip.class).iterator().next();
- assert chipBean.create(new MockCreationalContext<PotatoChip>()) == null;
+ assert createBeanInstance(chipBean) == null;
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -11,4 +11,10 @@
{
throw new RuntimeException("Some error");
}
+
+ public void ping()
+ {
+ // TODO Auto-generated method stub
+
+ }
}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,41 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-class MyCreationalContext<T> implements CreationalContext<T>
-{
- private static Object lastBeanPushed = null;
- private static boolean pushCalled = false;
-
- public void push(T incompleteInstance)
- {
- pushCalled = true;
- lastBeanPushed = incompleteInstance;
- }
-
- public static Object getLastBeanPushed()
- {
- return lastBeanPushed;
- }
-
- public static void setLastBeanPushed(Object lastBeanPushed)
- {
- MyCreationalContext.lastBeanPushed = lastBeanPushed;
- }
-
- public static boolean isPushCalled()
- {
- return pushCalled;
- }
-
- public static void setPushCalled(boolean pushCalled)
- {
- MyCreationalContext.pushCalled = pushCalled;
- }
-
- public void release()
- {
-
- }
-
-}
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-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -14,6 +14,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.impl.MockCreationalContext;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -81,10 +82,10 @@
})
public void testCreateReturnsSameBeanPushed() throws Exception
{
- final CreationalContext<Farm> farmCreationalContext = new
MyCreationalContext<Farm>();
+ final CreationalContext<Farm> farmCreationalContext = new
MockCreationalContext<Farm>();
final Contextual<Farm> farmBean =
getCurrentManager().getBeans(Farm.class).iterator().next();
- MyCreationalContext.setLastBeanPushed(null);
- MyCreationalContext.setPushCalled(false);
+ MockCreationalContext.setLastBeanPushed(null);
+ MockCreationalContext.setPushCalled(false);
new RunInDependentContext()
{
@@ -92,9 +93,9 @@
protected void execute() throws Exception
{
Farm farmInstance =
getCurrentManager().getContext(Dependent.class).get(farmBean, farmCreationalContext);
- if (MyCreationalContext.isPushCalled())
+ if (MockCreationalContext.isPushCalled())
{
- assert farmInstance.equals(MyCreationalContext.getLastBeanPushed());
+ assert farmInstance.equals(MockCreationalContext.getLastBeanPushed());
}
assert farmInstance.farmOffice != null : "FarmOffice should be injected
by Contextual.create()";
}
@@ -155,7 +156,7 @@
assert farm.founded != null;
assert farm.initialStaff == 20;
assert farm.closed == null;
- farmBean.destroy(farm);
+ destroyBeanInstance(farmBean, farm);
assert farm.closed != null;
}
@@ -166,12 +167,12 @@
})
public void testContextualDestroyDisposesWhenNecessary() throws Exception
{
- final Contextual<Goose> gooseBean =
getCurrentManager().getBeans(Goose.class).iterator().next();
+ final Bean<Goose> gooseBean =
getCurrentManager().getBeans(Goose.class).iterator().next();
final Goose goose = getCurrentManager().getInstanceByType(Goose.class);
assert !EggProducer.isEggDisposed();
assert !Egg.isEggDestroyed();
- gooseBean.destroy(goose);
+ destroyBeanInstance(gooseBean, goose);
assert EggProducer.isEggDisposed();
//TODO Apparently Dependent scoped injected objects do not have their PreDestroy
method called
//assert Egg.isEggDestroyed();
@@ -185,7 +186,8 @@
{
Bean<Cod> codBean =
getCurrentManager().getBeans(Cod.class).iterator().next();
Cod codInstance = getCurrentManager().getInstanceByType(Cod.class);
- codBean.destroy(codInstance);
+ codInstance.ping();
+ destroyBeanInstance(codBean, codInstance);
}
@Test(groups = "beanLifecycle")
@@ -196,7 +198,7 @@
{
Bean<FishPond> pondBean =
getCurrentManager().getBeans(FishPond.class).iterator().next();
FishPond fishPond = getCurrentManager().getInstanceByType(FishPond.class);
- pondBean.destroy(fishPond);
+ destroyBeanInstance(pondBean, fishPond);
assert Salmon.isBeanDestroyed();
}
@@ -247,7 +249,7 @@
{
Bean<CdOrderProcessor> bean =
getCurrentManager().getBeans(CdOrderProcessor.class).iterator().next();
CdOrderProcessor instance =
getCurrentManager().getInstanceByType(CdOrderProcessor.class);
- bean.destroy(instance);
+ destroyBeanInstance(bean, instance);
}
}.run();
assert OrderProcessor.preDestroyCalled;
@@ -266,7 +268,7 @@
{
Bean<IndirectOrderProcessor> bean =
getCurrentManager().getBeans(IndirectOrderProcessor.class).iterator().next();
IndirectOrderProcessor instance =
getCurrentManager().getInstanceByType(IndirectOrderProcessor.class);
- bean.destroy(instance);
+ destroyBeanInstance(bean, instance);
}
}.run();
assert OrderProcessor.preDestroyCalled;
@@ -302,7 +304,7 @@
{
Bean<NovelOrderProcessor> bean =
getCurrentManager().getBeans(NovelOrderProcessor.class).iterator().next();
NovelOrderProcessor instance =
getCurrentManager().getInstanceByType(NovelOrderProcessor.class);
- bean.destroy(instance);
+ destroyBeanInstance(bean, instance);
}
}.run();
assert !OrderProcessor.preDestroyCalled;
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/NewSimpleBeanTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/NewSimpleBeanTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/newSimpleBean/NewSimpleBeanTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -14,9 +14,9 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyBinding;
import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.jsr299.tck.literals.NewLiteral;
-import org.jboss.jsr299.tck.tests.event.AnyBinding;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -150,7 +150,7 @@
Fox newFox = getCurrentManager().getInstanceByType(Fox.class, new
NewLiteral());
Bean<Litter> litterBean =
getCurrentManager().getBeans(Litter.class).iterator().next();
Litter litter = getCurrentManager().getInstanceByType(Litter.class);
- litterBean.destroy(litter);
+ destroyBeanInstance(litterBean, litter);
assert fox.isLitterDisposed();
assert !newFox.isLitterDisposed();
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -50,7 +50,7 @@
public void testInjectionOfEjbs()
{
Bean<SimpleBean> simpleBeanBean =
getCurrentManager().getBeans(SimpleBean.class).iterator().next();
- SimpleBean simpleBean = simpleBeanBean.create(new
MyCreationalContext<SimpleBean>());
+ SimpleBean simpleBean = createBeanInstance(simpleBeanBean);
assert !simpleBean.isMyEjbExists() : "Ejb was injected too early";
assert simpleBean.getMyEjb() != null : "Ejb was not injected into bean";
assert simpleBean.getMyEjb().hello().equals("hi!");
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,16 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-class MyCreationalContext<T> implements CreationalContext<T>
-{
- public void push(T incompleteInstance)
- {
- }
-
- public void release()
- {
-
- }
-
-}
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,16 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-class MyCreationalContext<T> implements CreationalContext<T>
-{
- public void push(T incompleteInstance)
- {
- }
-
- public void release()
- {
-
- }
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -38,7 +38,7 @@
public void testInjectionOfPersistenceContext()
{
Bean<SimpleBean> simpleBeanBean =
getCurrentManager().getBeans(SimpleBean.class).iterator().next();
- SimpleBean simpleBean = simpleBeanBean.create(new
MyCreationalContext<SimpleBean>());
+ SimpleBean simpleBean = createBeanInstance(simpleBeanBean);
EntityManager entityManager = simpleBean.getPersistenceContext();
assert !simpleBean.isPersistenceContextExistsDuringConstruction() :
"Persistence context injected too early";
assert entityManager != null : "Persistence context was not injected into
bean";
@@ -50,7 +50,7 @@
{
//TODO There is no spec assertion for this test and it does not work, but there is
bean support for persistence units
Bean<SimpleBean> simpleBeanBean =
getCurrentManager().getBeans(SimpleBean.class).iterator().next();
- SimpleBean simpleBean = simpleBeanBean.create(new
MyCreationalContext<SimpleBean>());
+ SimpleBean simpleBean = createBeanInstance(simpleBeanBean);
EntityManagerFactory entityManagerFactory = simpleBean.getPersistenceUnit();
assert !simpleBean.isPersistenceUnitExistsDuringConstruction() : "Persistence
unit injected too early";
assert entityManagerFactory != null : "Persistence unit was not injected into
bean";
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,7 +1,7 @@
package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
@@ -23,7 +23,7 @@
public void testInjectionOfResource()
{
Bean<SimpleBean> simpleBeanBean =
getCurrentManager().getBeans(SimpleBean.class).iterator().next();
- SimpleBean simpleBean = simpleBeanBean.create(new
MyCreationalContext<SimpleBean>());
+ SimpleBean simpleBean = createBeanInstance(simpleBeanBean);
BeanManager beanManager = simpleBean.getManager();
assert !simpleBean.isManagerInjected() : "Manager injected too early";
assert beanManager != null : "@Another Manager not found";
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java 2009-06-02
12:57:38 UTC (rev 2742)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java 2009-06-02
15:19:20 UTC (rev 2743)
@@ -1,16 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-class MyCreationalContext<T> implements CreationalContext<T>
-{
- public void push(T incompleteInstance)
- {
- }
-
- public void release()
- {
-
- }
-
-}