Author: pete.muir(a)jboss.org
Date: 2009-03-22 18:36:22 -0400 (Sun, 22 Mar 2009)
New Revision: 2136
Removed:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/BootstrapTest.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.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/standard/AbstractStandardBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.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/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java
Log:
explicit call of initialize
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-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -132,10 +132,9 @@
/**
* Initializes the bean and its metadata
*/
- protected void init()
+ public void initialize()
{
mergedStereotypes = new MergedStereotypes<T,
E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class));
- initBindings();
if (isSpecializing())
{
preSpecialize();
@@ -143,7 +142,6 @@
postSpecialize();
}
initDefaultBindings();
- initType();
initPrimitive();
if (log.isDebugEnabled())
log.debug("Building Web Bean bean metadata for " + getType());
@@ -151,7 +149,6 @@
initDeploymentType();
checkDeploymentType();
initScopeType();
- initTypes();
initSerializable();
initProxyable();
checkRequiredTypesImplemented();
@@ -299,13 +296,8 @@
return false;
}
}
-
+
/**
- * Initializes the type of the bean
- */
- protected abstract void initType();
-
- /**
* Validates the deployment type
*/
protected void checkDeploymentType()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -82,9 +82,9 @@
* Initializes the bean and its metadata
*/
@Override
- protected void init()
+ public void initialize()
{
- super.init();
+ super.initialize();
checkScopeAllowed();
checkBeanImplementation();
initInitializerMethods();
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-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -115,7 +115,6 @@
/**
* Initializes the type
*/
- @Override
protected void initType()
{
try
@@ -175,9 +174,9 @@
* Initializes the bean and its metadata
*/
@Override
- protected void init()
+ public void initialize()
{
- super.init();
+ super.initialize();
checkProducerReturnType();
}
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-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -90,15 +90,6 @@
protected EnterpriseBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(type, manager);
- init();
- }
-
- /**
- * Initializes the bean and its metadata
- */
- @Override
- protected void init()
- {
initType();
Iterable<InternalEjbDescriptor<T>> ejbDescriptors =
manager.getEjbDescriptorCache().get(getType());
if (ejbDescriptors == null)
@@ -116,7 +107,17 @@
throw new RuntimeException("TODO Multiple EJBs have the same bean class!
" + getType());
}
}
- super.init();
+ initTypes();
+ initBindings();
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize()
+ {
+ super.initialize();
initProxyClass();
initInjectionPoints();
checkEJBTypeAllowed();
@@ -197,6 +198,7 @@
protected void specialize()
{
this.specializedBean = EnterpriseBean.of(getAnnotatedItem().getSuperclass(),
manager);
+ this.specializedBean.initialize();
}
/**
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-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -61,7 +61,9 @@
{
super(declaringBean, manager);
this.field = field;
- init();
+ initType();
+ initTypes();
+ initBindings();
}
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-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -68,7 +68,9 @@
{
super(declaringBean, manager);
this.method = MethodInjectionPoint.of(this, method);
- init();
+ initType();
+ initTypes();
+ initBindings();
}
protected T produceInstance(CreationalContext<T> creationalContext)
@@ -80,9 +82,9 @@
* Initializes the bean and its metadata
*/
@Override
- protected void init()
+ public void initialize()
{
- super.init();
+ super.initialize();
checkProducerMethod();
//initDisposalMethod();
initInjectionPoints();
@@ -215,7 +217,10 @@
@Override
protected void specialize()
{
- this.specializedBean =
ProducerMethodBean.of(declaringBean.getAnnotatedItem().getSuperclass().getMethod(getAnnotatedItem().getAnnotatedMethod()),
SimpleBean.of(declaringBean.getAnnotatedItem().getSuperclass(), manager), manager);
+ SimpleBean<?> superClassBean =
SimpleBean.of(declaringBean.getAnnotatedItem().getSuperclass(), manager);
+ superClassBean.initialize();
+ this.specializedBean =
ProducerMethodBean.of(declaringBean.getAnnotatedItem().getSuperclass().getMethod(getAnnotatedItem().getAnnotatedMethod()),
superClassBean, manager);
+ this.specializedBean.initialize();
}
}
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-03-22 21:39:35
UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-03-22 22:36:22
UTC (rev 2136)
@@ -54,6 +54,8 @@
}
public abstract Class<T> getType();
+
+ public abstract void initialize();
public abstract boolean isSpecializing();
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-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -42,7 +42,6 @@
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MetaDataCache;
@@ -82,20 +81,6 @@
* @param manager the current manager
* @return A Web Bean
*/
- @Deprecated
- public static <T> SimpleBean<T> of(Class<T> clazz, ManagerImpl
manager)
- {
- return of(AnnotatedClassImpl.of(clazz), manager);
- }
-
- /**
- * Creates a simple, annotation defined Web Bean
- *
- * @param <T> The type
- * @param clazz The class
- * @param manager the current manager
- * @return A Web Bean
- */
public static <T> SimpleBean<T> of(AnnotatedClass<T> clazz,
ManagerImpl manager)
{
return new SimpleBean<T>(clazz, manager);
@@ -110,7 +95,9 @@
protected SimpleBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(type, manager);
- init();
+ initType();
+ initTypes();
+ initBindings();
}
/**
@@ -296,9 +283,9 @@
* Initializes the bean and its metadata
*/
@Override
- protected void init()
+ public void initialize()
{
- super.init();
+ super.initialize();
initConstructor();
checkType();
initInjectionPoints();
@@ -375,6 +362,7 @@
protected void specialize()
{
this.specializedBean = SimpleBean.of(getAnnotatedItem().getSuperclass(), manager);
+ this.specializedBean.initialize();
}
/**
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-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -21,6 +21,12 @@
{
super(manager);
}
+
+ @Override
+ public void initialize()
+ {
+ // No-op
+ }
private static final Annotation[] DEFAULT_BINDING_ARRAY = { new CurrentLiteral() };
private static final Set<Annotation> DEFAULT_BINDING = new
HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -42,6 +42,7 @@
private static final LogProvider log = Logging.getLogProvider(BeanDeployer.class);
private final Set<RIBean<?>> beans;
+ private final Set<ObserverImpl<?>> observers;
private final Set<AnnotatedClass<?>> classes;
private final ManagerImpl manager;
@@ -50,6 +51,7 @@
this.manager = manager;
this.beans = new TreeSet<RIBean<?>>(new
BootstrapOrderingBeanComparator());
this.classes = new HashSet<AnnotatedClass<?>>();
+ this.observers = new HashSet<ObserverImpl<?>>();
}
public BeanDeployer addBean(RIBean<?> bean)
@@ -94,8 +96,18 @@
public BeanDeployer deploy()
{
- printBeans();
+ for (RIBean<?> bean : beans)
+ {
+ bean.initialize();
+ log.info("Bean: " + bean);
+ }
manager.setBeans(beans);
+ for (ObserverImpl<?> observer : observers)
+ {
+ observer.initialize();
+ log.info("Observer : " + observer);
+ manager.addObserver(observer);
+ }
return this;
}
@@ -106,10 +118,7 @@
protected void printBeans()
{
- for (RIBean<?> bean : beans)
- {
- log.info("Bean: " + bean);
- }
+
}
/**
@@ -204,7 +213,7 @@
private void createObserverMethod(AbstractClassBean<?> declaringBean,
AnnotatedMethod<?> method)
{
ObserverImpl<?> observer = ObserverFactory.create(method, declaringBean,
manager);
- manager.addObserver(observer);
+ observers.add(observer);
}
private void createSimpleBean(AnnotatedClass<?> annotatedClass)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java 2009-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -13,18 +13,28 @@
public int compare(RIBean<?> o1, RIBean<?> o2)
{
- if (o1 instanceof AbstractStandardBean && !(o2 instanceof
AbstractStandardBean))
+ if (o1 instanceof AbstractClassBean && o2 instanceof AbstractProducerBean)
{
+// AbstractProducerBean<?, ?> b2 = (AbstractProducerBean<?, ?>) o2;
+// System.out.println(" declaring bean " +
b2.getDeclaringBean().getType());
+// if (b2.getDeclaringBean().equals(o1))
+// {
+// System.out.println(" class " + o1.getType() + " <
producer " + o2.getType());
+// return -1;
+// }
return -1;
}
- else if (!(o1 instanceof AbstractStandardBean) && o2 instanceof
AbstractStandardBean)
+ else if (o1 instanceof AbstractProducerBean && o2 instanceof
AbstractClassBean)
{
+// AbstractProducerBean<?, ?> b1 = (AbstractProducerBean<?, ?>) o1;
+// System.out.println(" declaring bean " +
b1.getDeclaringBean().getType());
+// if (b1.getDeclaringBean().equals(o2))
+// {
+// System.out.println(" class " + o2.getType() + " <
producer " + o1.getType());
+// return 1;
+// }
return 1;
}
- else if (o1 instanceof AbstractStandardBean && o2 instanceof
AbstractStandardBean)
- {
- return o1.getId().compareTo(o2.getId());
- }
if (o1 instanceof AbstractClassBean && o2 instanceof AbstractClassBean)
{
@@ -41,20 +51,19 @@
return -1;
}
}
- else if (o2 instanceof AbstractProducerBean)
+
+ if (o1 instanceof AbstractStandardBean && !(o2 instanceof
AbstractStandardBean))
{
- // Producer beans are always initialized after class beans
return -1;
}
-
- if (o1 instanceof AbstractProducerBean)
+ else if (!(o1 instanceof AbstractStandardBean) && o2 instanceof
AbstractStandardBean)
{
- AbstractProducerBean<?, ?> b1 = (AbstractProducerBean<?, ?>) o1;
- if (o2 instanceof AbstractClassBean &&
b1.getDeclaringBean().equals(o2))
- {
- return 1;
- }
+ return 1;
}
+ else if (o1 instanceof AbstractStandardBean && o2 instanceof
AbstractStandardBean)
+ {
+ return o1.getId().compareTo(o2.getId());
+ }
if (o1.getType().getName().startsWith("org.jboss.webbeans") &&
!o2.getType().getName().startsWith("org.jboss.webbeans"))
{
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-03-22
21:39:35 UTC (rev 2135)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -75,7 +75,7 @@
this.manager = manager;
this.observerBean = observerBean;
this.observerMethod = MethodInjectionPoint.of(observerBean, observer);
- checkObserverMethod();
+
@SuppressWarnings("unchecked")
Class<T> c = (Class<T>)
observerMethod.getAnnotatedParameters(Observes.class).get(0).getRawType();
@@ -84,18 +84,19 @@
this.bindings =
observerMethod.getAnnotatedParameters(Observes.class).get(0).getBindingsAsArray();
this.conditional =
!observerMethod.getAnnotatedParameters(IfExists.class).isEmpty();
this.asynchronous =
!observerMethod.getAnnotatedParameters(Asynchronously.class).isEmpty();
- init();
}
-
+
/**
* Completes initialization of the observer and allows derived types to
* override behavior.
*/
- protected void init()
+ public void initialize()
{
-
+ checkObserverMethod();
}
+
+
/**
* Performs validation of the observer method for compliance with the
* specifications.
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-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -79,8 +79,9 @@
}
@Override
- protected void init()
+ public void initialize()
{
+ super.initialize();
initTransactionObservationPhase();
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -74,7 +74,7 @@
* @param constructor The constructor method
* @param declaringClass The declaring class
*/
- public AnnotatedConstructorImpl(Constructor<T> constructor,
AnnotatedType<T> declaringClass)
+ protected AnnotatedConstructorImpl(Constructor<T> constructor,
AnnotatedType<T> declaringClass)
{
super(AnnotationStore.of(constructor), constructor,
constructor.getDeclaringClass(), constructor.getDeclaringClass());
this.constructor = constructor;
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -54,7 +54,7 @@
* @param field The actual field
* @param declaringClass The abstraction of the declaring class
*/
- public AnnotatedFieldImpl(Field field, AnnotatedType<?> declaringClass)
+ protected AnnotatedFieldImpl(Field field, AnnotatedType<?> declaringClass)
{
super(AnnotationStore.of(field), field, (Class<T>) field.getType(),
field.getGenericType());
this.field = field;
Deleted:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/BootstrapTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/BootstrapTest.java 2009-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/BootstrapTest.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -1,43 +0,0 @@
-package org.jboss.webbeans.test.unit.bootstrap.ordering;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.manager.Bean;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Packaging;
-import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.webbeans.bean.ProducerMethodBean;
-import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
-import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
-import org.testng.annotations.Test;
-
-@Artifact
-(a)Packaging(PackagingType.EAR)
-public class BootstrapTest extends AbstractWebBeansTest
-{
-
- @Test(groups="bootstrap")
- public void testProducerMethodBean()
- {
- //deployBeans(TarantulaProducer.class);
- List<Bean<?>> beans = manager.getBeans();
- Map<Class<?>, Bean<?>> classes = new HashMap<Class<?>,
Bean<?>>();
- for (Bean<?> bean : beans)
- {
- if (bean instanceof RIBean)
- {
- classes.put(((RIBean<?>) bean).getType(), bean);
- }
- }
- assert classes.containsKey(TarantulaProducer.class);
- assert classes.containsKey(Tarantula.class);
-
- assert classes.get(TarantulaProducer.class) instanceof SimpleBean;
- assert classes.get(Tarantula.class) instanceof ProducerMethodBean;
- }
-
-}
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java 2009-03-22
21:39:35 UTC (rev 2135)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java 2009-03-22
22:36:22 UTC (rev 2136)
@@ -3,12 +3,8 @@
import java.util.ArrayList;
import java.util.Arrays;
-import javax.inject.AnnotationLiteral;
-
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.Packaging;
-import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.NewBean;
import org.jboss.webbeans.bean.RIBean;
@@ -19,18 +15,44 @@
import org.jboss.webbeans.bean.standard.InstanceBean;
import org.jboss.webbeans.bean.standard.ManagerBean;
import org.jboss.webbeans.bootstrap.BeanDeployer;
+import org.jboss.webbeans.literal.NewLiteral;
import org.jboss.webbeans.mock.MockEjbDescriptor;
-import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.jboss.webbeans.mock.MockServletLifecycle;
+import org.jboss.webbeans.mock.MockWebBeanDiscovery;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.acme.RoadRunner;
-@Artifact
-(a)Packaging(PackagingType.EAR)
-(a)Classes(packages="com.acme")
-public class DeployerOrderingTest extends AbstractWebBeansTest
+public class DeployerOrderingTest
{
+ private MockServletLifecycle lifecycle;
+ private ManagerImpl manager;
+
+ @BeforeClass
+ public void beforeClass() throws Throwable
+ {
+ lifecycle = new MockServletLifecycle();
+ lifecycle.initialize();
+ MockWebBeanDiscovery discovery = lifecycle.getWebBeanDiscovery();
+ lifecycle.beginApplication();
+ lifecycle.beginSession();
+ lifecycle.beginRequest();
+ manager = CurrentManager.rootManager();
+ }
+
+ @AfterClass(alwaysRun=true)
+ public void afterClass() throws Exception
+ {
+ lifecycle.endRequest();
+ lifecycle.endSession();
+ lifecycle.endApplication();
+ CurrentManager.setRootManager(null);
+ lifecycle = null;
+ }
+
@Test(groups="bootstrap")
public void testNewSimpleBeansAfterNonNew()
{
@@ -124,11 +146,11 @@
assert beanDeployer.getBeans().size() == 5;
for (RIBean<?> bean : beanDeployer.getBeans())
{
- if (bean.getType().equals(TarantulaProducer.class))
+ if (bean.getType().equals(TarantulaProducer.class) &&
!bean.getBindings().contains(new NewLiteral()))
{
indexOfProducerDeclaringBean = i;
}
- if (bean.getType().equals(Tarantula.class) &&
bean.getBindings().contains(new AnnotationLiteral<Tame>() {}))
+ if (bean.getType().equals(Tarantula.class) &&
!bean.getBindings().contains(new NewLiteral()))
{
indexOfProducer = i;
}