[webbeans-commits] Webbeans SVN: r2137 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype: session and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-23 01:25:18 -0400 (Mon, 23 Mar 2009)
New Revision: 2137
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/Animal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/AnimalStereotype.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollie.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollieLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/LongHairedDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/SessionStereotypeDefinitionTest.java
Log:
4.2 session bean tests
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/Animal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/Animal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/Animal.java 2009-03-23 05:25:18 UTC (rev 2137)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype.session;
+
+interface Animal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/AnimalStereotype.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/AnimalStereotype.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/AnimalStereotype.java 2009-03-23 05:25:18 UTC (rev 2137)
@@ -0,0 +1,23 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype.session;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.annotation.Stereotype;
+import javax.context.RequestScoped;
+
+(a)Stereotype(requiredTypes=Animal.class)
+@Target( { TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@RequestScoped
+@Inherited
+@interface AnimalStereotype
+{
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollie.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollie.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollie.java 2009-03-23 05:25:18 UTC (rev 2137)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype.session;
+
+import javax.ejb.Stateful;
+
+@Stateful
+public class BorderCollie extends LongHairedDog implements BorderCollieLocal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollieLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollieLocal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/BorderCollieLocal.java 2009-03-23 05:25:18 UTC (rev 2137)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype.session;
+
+public interface BorderCollieLocal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/LongHairedDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/LongHairedDog.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/LongHairedDog.java 2009-03-23 05:25:18 UTC (rev 2137)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype.session;
+
+@AnimalStereotype
+class LongHairedDog implements Animal
+{
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/SessionStereotypeDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/SessionStereotypeDefinitionTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/stereotype/session/SessionStereotypeDefinitionTest.java 2009-03-23 05:25:18 UTC (rev 2137)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.tests.definition.stereotype.session;
+
+import javax.context.RequestScoped;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * Spec version: PRD2
+ */
+@IntegrationTest
+@Artifact
+(a)Packaging(PackagingType.EAR)
+public class SessionStereotypeDefinitionTest extends AbstractJSR299Test
+{
+ @Test
+ @SpecAssertion(section = "4.1", id = "ae")
+ public void testStereotypeDeclaredInheritedIsInherited() throws Exception
+ {
+ assert getCurrentManager().resolveByType(BorderCollieLocal.class).iterator().next().getScopeType().equals(RequestScoped.class);
+ }
+}
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2136 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean/standard and 4 other directories.
by webbeans-commits@lists.jboss.org
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)
-@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;
}
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2135 - ri/trunk/jboss-as.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-22 17:39:35 -0400 (Sun, 22 Mar 2009)
New Revision: 2135
Modified:
ri/trunk/jboss-as/build.xml
Log:
better clean up
Modified: ri/trunk/jboss-as/build.xml
===================================================================
--- ri/trunk/jboss-as/build.xml 2009-03-22 18:48:02 UTC (rev 2134)
+++ ri/trunk/jboss-as/build.xml 2009-03-22 21:39:35 UTC (rev 2135)
@@ -3,74 +3,77 @@
<path id="maven-ant-tasks.classpath" path="../lib/maven-ant-tasks.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpathref="maven-ant-tasks.classpath" />
-
+
<property name="maven.dir" location="${basedir}/lib/maven" />
<property file="build.properties" />
- <property file="local.build.properties" />
-
+ <property file="local.build.properties" />
+
<target name="clean" description="Clean up after the JBoss updater">
- <delete dir="target" failonerror="false"/>
+ <delete dir="target" failonerror="false" />
</target>
<target name="update" depends="install-webbeans.deployer" description="Update JBoss 5 for the Web Beans RI" />
-
+
<target name="install-webbeans.deployer">
- <fail unless="jboss.home" message="Please pass in -Djboss.home=..."/>
+ <fail unless="jboss.home" message="Please pass in -Djboss.home=..." />
<delete dir="${jboss.home}/server/default/deployers/webbeans.deployer" failonerror="false" />
- <delete dir="target" failonerror="false"/>
-
- <artifact:dependencies filesetId="webbeans.deployer.fileset" versionsId="webbeans.deployer.versions">
- <dependency groupId="org.jboss.webbeans.integration" artifactId="webbeans-ri-int-deployer" version="${webbeans-ri-int.version}" type="zip"/>
- <dependency groupId="org.jboss.webbeans" artifactId="webbeans-core" version="${webbeans.version}" />
- <remoteRepository id="repository.jboss.org" url="http://repository.jboss.org/maven2" />
+ <delete dir="target" failonerror="false" />
+
+ <artifact:dependencies filesetId="webbeans.deployer.fileset" versionsId="webbeans.deployer.versions" >
+ <dependency groupId="org.jboss.webbeans.integration" artifactId="webbeans-ri-int-deployer" version="${webbeans-ri-int.version}" type="zip" />
+ <dependency groupId="org.jboss.webbeans" artifactId="webbeans-core" version="${webbeans.version}" />
+ <remoteRepository id="repository.jboss.org" url="http://repository.jboss.org/maven2" />
<remoteRepository id="snapshots.jboss.org" url="http://snapshots.jboss.org/maven2" />
- </artifact:dependencies>
-
- <mkdir dir="target" />
- <copy todir="target">
- <fileset refid="webbeans.deployer.fileset"/>
+ </artifact:dependencies>
+
+ <mkdir dir="target/dependency/lib" />
+ <copy todir="target/dependency/lib">
+ <fileset refid="webbeans.deployer.fileset" />
<chainedmapper>
- <flattenmapper />
- <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${webbeans.deployer.versions}" to="flatten" />
- </chainedmapper>
+ <flattenmapper />
+ <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${webbeans.deployer.versions}" to="flatten" />
+ </chainedmapper>
</copy>
+
+ <unzip dest="target" src="target/dependency/lib/webbeans-ri-int-deployer.zip" />
- <unzip dest="target" src="target/webbeans-ri-int-deployer.zip" />
+ <copy todir="target/webbeans.deployer/lib-int/" overwrite="true">
+ <fileset dir="target/dependency/lib">
+ <include name="webbeans-core.jar" />
+ </fileset>
+ </copy>
+
+ <delete dir="target/dependency" />
<copy todir="${jboss.home}/server/default/deployers/webbeans.deployer">
<fileset dir="target/webbeans.deployer">
<include name="**/*" />
</fileset>
</copy>
-
- <copy todir="${jboss.home}/server/default/deployers/webbeans.deployer/lib-int/" overwrite="true">
- <fileset dir="target">
- <include name="webbeans-core.jar" />
- </fileset>
- </copy>
+
</target>
-
+
<target name="install-jboss-ejb3-update">
-
- <fail unless="jboss.home" message="Please pass in -Djboss.home=..."/>
-
+
+ <fail unless="jboss.home" message="Please pass in -Djboss.home=..." />
+
<artifact:dependencies filesetId="jboss.ejb3.plugin.fileset" versionsId="jboss.ejb3.plugin.versions">
- <dependency groupId="org.jboss.ejb3" artifactId="jboss-ejb3-plugin" version="${jboss-ejb3.version}" classifier="installer"/>
- <remoteRepository id="repository.jboss.org" url="http://repository.jboss.org/maven2" />
- </artifact:dependencies>
-
- <mkdir dir="target/ejb3.plugin"/>
- <copy todir="target/ejb3.plugin">
- <fileset refid="jboss.ejb3.plugin.fileset"/>
- <chainedmapper>
- <flattenmapper />
- <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${jboss.ejb3.plugin.versions}" to="flatten" />
- </chainedmapper>
- </copy>
+ <dependency groupId="org.jboss.ejb3" artifactId="jboss-ejb3-plugin" version="${jboss-ejb3.version}" classifier="installer" />
+ <remoteRepository id="repository.jboss.org" url="http://repository.jboss.org/maven2" />
+ </artifact:dependencies>
+
+ <mkdir dir="target/ejb3.plugin" />
+ <copy todir="target/ejb3.plugin">
+ <fileset refid="jboss.ejb3.plugin.fileset" />
+ <chainedmapper>
+ <flattenmapper />
+ <mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper" from="${jboss.ejb3.plugin.versions}" to="flatten" />
+ </chainedmapper>
+ </copy>
<java jar="target/ejb3.plugin/jboss-ejb3-plugin-installer.jar" fork="true" failonerror="true">
<arg line="${jboss.home}" />
</java>
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2134 - ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-22 14:48:02 -0400 (Sun, 22 Mar 2009)
New Revision: 2134
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java
Log:
minor
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 18:46:31 UTC (rev 2133)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java 2009-03-22 18:48:02 UTC (rev 2134)
@@ -134,6 +134,7 @@
}
i++;
}
+ assert indexOfProducer > indexOfProducerDeclaringBean;
}
@Test(groups="bootstrap")
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2133 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bootstrap and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-22 14:46:31 -0400 (Sun, 22 Mar 2009)
New Revision: 2133
Added:
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/DeadlyAnimal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlySpider.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DefangedTarantula.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Spider.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tame.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tarantula.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/TarantulaProducer.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java
Log:
add more ordering and more tests
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 17:18:51 UTC (rev 2132)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -64,6 +64,7 @@
private Set<FieldInjectionPoint<?>> injectableFields;
// The initializer methods
private Set<MethodInjectionPoint<?>> initializerMethods;
+ private Set<String> dependencies;
/**
* Constructor
@@ -122,6 +123,11 @@
{
log.trace("Bean type specified in Java");
this.type = getAnnotatedItem().getRawType();
+ this.dependencies = new HashSet<String>();
+ for (Class<?> clazz = type.getSuperclass(); clazz != Object.class; clazz = clazz.getSuperclass())
+ {
+ dependencies.add(clazz.getName());
+ }
}
/**
@@ -309,6 +315,12 @@
{
return initializerMethods;
}
+
+ // TODO maybe a better way to expose this?
+ public Set<String> getSuperclasses()
+ {
+ return dependencies;
+ }
/**
* Gets a string representation
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 17:18:51 UTC (rev 2132)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -453,15 +453,6 @@
}
/**
- * Initializes the bean type
- */
- protected void initType()
- {
- log.trace("Bean type specified in Java");
- this.type = getAnnotatedItem().getRawType();
- }
-
- /**
* Returns the constructor
*
* @return The constructor
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 17:18:51 UTC (rev 2132)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -25,100 +25,56 @@
{
return o1.getId().compareTo(o2.getId());
}
- else if (o1.getType().getName().startsWith("org.jboss.webbeans") && !o2.getType().getName().startsWith("org.jboss.webbeans"))
+
+ if (o1 instanceof AbstractClassBean && o2 instanceof AbstractClassBean)
{
- return -1;
- }
- else if (!o1.getType().getName().startsWith("org.jboss.webbeans") && o2.getType().getName().startsWith("org.jboss.webbeans"))
- {
- return 1;
- }
- else if (o1 instanceof AbstractClassBean)
- {
AbstractClassBean<?> b1 = (AbstractClassBean<?>) o1;
- if (o2 instanceof NewBean && !(o1 instanceof NewBean))
+ AbstractClassBean<?> b2 = (AbstractClassBean<?>) o2;
+ if (b1.getSuperclasses().contains(b2.getType().getName()))
{
- // Always initialize new beans after class beans
- return -1;
- }
- else if (o1 instanceof NewBean && o2 instanceof AbstractClassBean && !(o2 instanceof NewBean))
- {
- // Always initialize new beans after class beans
+ // Place o1 after it's superclass
return 1;
}
- else if (o1 instanceof NewBean && !(o2 instanceof NewBean))
+ else if (b2.getSuperclasses().contains(b1.getType().getName()))
{
- // Always initialize new class beans after class beans but before other beans
+ // Place o1 before it's subclass o2
return -1;
}
- else if (o1 instanceof NewBean && o2 instanceof NewBean)
- {
- return o1.getId().compareTo(o2.getId());
- }
- else if (o2 instanceof AbstractClassBean)
- {
- AbstractClassBean<?> b2 = (AbstractClassBean<?>) o2;
- if (o1.getTypes().contains(b2.getType()))
- {
- return 1;
- }
- else if (b2.getTypes().contains(b1.getType()))
- {
- return -1;
- }
- else
- {
- return o1.getId().compareTo(o2.getId());
- }
- }
- else if (o2 instanceof AbstractProducerBean)
- {
- // Producer beans are always initialized after class beans
- return -1;
- }
- else
- {
- // Ordering doesn't matter
- return o1.getId().compareTo(o2.getId());
- }
}
- else if (o1 instanceof AbstractProducerBean)
+ else if (o2 instanceof AbstractProducerBean)
{
+ // Producer beans are always initialized after class beans
+ return -1;
+ }
+
+ if (o1 instanceof AbstractProducerBean)
+ {
AbstractProducerBean<?, ?> b1 = (AbstractProducerBean<?, ?>) o1;
- if (o2 instanceof NewBean)
+ if (o2 instanceof AbstractClassBean && b1.getDeclaringBean().equals(o2))
{
- // Always initialize producers beans after new beans
return 1;
}
- else if (o2 instanceof AbstractClassBean)
- {
- if (b1.getDeclaringBean().equals(o2))
- {
- return 1;
- }
- else
- {
- return o1.getId().compareTo(o2.getId());
- }
- }
- else
- {
- // Ordering doesn't matter
- return o1.getId().compareTo(o2.getId());
- }
}
- else
+
+ if (o1.getType().getName().startsWith("org.jboss.webbeans") && !o2.getType().getName().startsWith("org.jboss.webbeans"))
{
- if (o2 instanceof AbstractClassBean || o2 instanceof AbstractProducerBean)
- {
- // Initialize undefined ordering after defined ordering
- return 1;
- }
- else
- {
- return o1.getId().compareTo(o2.getId());
- }
+ return -1;
}
+ else if (!o1.getType().getName().startsWith("org.jboss.webbeans") && o2.getType().getName().startsWith("org.jboss.webbeans"))
+ {
+ return 1;
+ }
+
+ if (!(o1 instanceof NewBean) && o2 instanceof NewBean)
+ {
+ return -1;
+ }
+ else if (o1 instanceof NewBean && !(o2 instanceof NewBean))
+ {
+ return 1;
+ }
+
+ return o1.getId().compareTo(o2.getId());
}
}
Added: 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 (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/BootstrapTest.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,43 @@
+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;
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/BootstrapTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlyAnimal.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlyAnimal.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlyAnimal.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+interface DeadlyAnimal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlyAnimal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlySpider.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlySpider.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlySpider.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+interface DeadlySpider extends DeadlyAnimal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeadlySpider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DefangedTarantula.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DefangedTarantula.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DefangedTarantula.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+class DefangedTarantula extends Tarantula
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DefangedTarantula.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 17:18:51 UTC (rev 2132)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -3,6 +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;
@@ -110,4 +112,59 @@
}
}
+ @Test(groups="bootstrap")
+ public void testProducerMethodAfterDeclaringBean()
+ {
+ BeanDeployer beanDeployer = new BeanDeployer(manager);
+ beanDeployer.addClasses(Arrays.asList(TarantulaProducer.class, Tuna.class));
+ beanDeployer.createBeans();
+ int indexOfProducerDeclaringBean = 0;
+ int indexOfProducer = 0;
+ int i = 0;
+ assert beanDeployer.getBeans().size() == 5;
+ for (RIBean<?> bean : beanDeployer.getBeans())
+ {
+ if (bean.getType().equals(TarantulaProducer.class))
+ {
+ indexOfProducerDeclaringBean = i;
+ }
+ if (bean.getType().equals(Tarantula.class) && bean.getBindings().contains(new AnnotationLiteral<Tame>() {}))
+ {
+ indexOfProducer = i;
+ }
+ i++;
+ }
+ }
+
+ @Test(groups="bootstrap")
+ public void testClassHierarchies()
+ {
+ BeanDeployer beanDeployer = new BeanDeployer(manager);
+ beanDeployer.addClasses(Arrays.asList(Spider.class, Tarantula.class, DefangedTarantula.class, Tuna.class));
+ beanDeployer.createBeans();
+ assert beanDeployer.getBeans().size() == 8;
+ int indexOfSpider = 0;
+ int indexOfTarantula = 0;
+ int indexOfDefangedTarantula = 0;
+ int i = 0;
+ for (RIBean<?> bean : beanDeployer.getBeans())
+ {
+ if (bean.getType().equals(Spider.class))
+ {
+ indexOfSpider = i;
+ }
+ if (bean.getType().equals(Tarantula.class))
+ {
+ indexOfTarantula = i;
+ }
+ if (bean.getType().equals(DefangedTarantula.class))
+ {
+ indexOfDefangedTarantula = i;
+ }
+ i++;
+ }
+ assert indexOfDefangedTarantula > indexOfTarantula;
+ assert indexOfTarantula > indexOfSpider;
+ }
+
}
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Spider.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Spider.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Spider.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+class Spider implements Animal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Spider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tame.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tame.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tame.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Tame
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tame.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tarantula.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tarantula.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tarantula.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+class Tarantula extends Spider implements DeadlySpider
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tarantula.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/TarantulaProducer.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/TarantulaProducer.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/TarantulaProducer.java 2009-03-22 18:46:31 UTC (rev 2133)
@@ -0,0 +1,13 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.inject.Produces;
+
+public class TarantulaProducer
+{
+
+ @Produces @Tame public Tarantula produceTameTarantula()
+ {
+ return new DefangedTarantula();
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/TarantulaProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2132 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bootstrap and 6 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-22 13:18:51 -0400 (Sun, 22 Mar 2009)
New Revision: 2132
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java
ri/trunk/tests/src/test/java/com/
ri/trunk/tests/src/test/java/com/acme/
ri/trunk/tests/src/test/java/com/acme/RoadRunner.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Animal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Cow.java
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/Gazelle.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/GazelleLocal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Lion.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/LionLocal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tuna.java
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/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/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/tests/unit-tests.xml
Log:
Start work on bean ordering for deployer
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-03-22 13:27:30 UTC (rev 2131)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -48,8 +48,6 @@
{
return DEFAULT_TYPES;
}
-
-
@Override
public Set<Annotation> getBindings()
@@ -69,4 +67,10 @@
return FILTERED_ANNOTATION_TYPES;
}
+ @Override
+ public String toString()
+ {
+ return "Built-in implicit javax.event.Event bean";
+ }
+
}
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-03-22 13:27:30 UTC (rev 2131)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -80,4 +80,10 @@
return TYPES;
}
+ @Override
+ public String toString()
+ {
+ return "Built-in javax.inject.manager.InjectionPoint bean";
+ }
+
}
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-03-22 13:27:30 UTC (rev 2131)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -66,4 +66,10 @@
return FILTERED_ANNOTATION_TYPES;
}
+ @Override
+ public String toString()
+ {
+ return "Built-in implicit javax.inject.Instance bean";
+ }
+
}
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-03-22 13:27:30 UTC (rev 2131)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -56,4 +56,11 @@
return true;
}
+ @Override
+ public String toString()
+ {
+ return "Built-in javax.inject.manager.Manager bean";
+ }
+
+
}
\ No newline at end of file
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 13:27:30 UTC (rev 2131)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -3,6 +3,7 @@
import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Set;
+import java.util.TreeSet;
import javax.event.Observes;
import javax.inject.BindingType;
@@ -47,33 +48,35 @@
public BeanDeployer(ManagerImpl manager)
{
this.manager = manager;
- this.beans = new HashSet<RIBean<?>>();
+ this.beans = new TreeSet<RIBean<?>>(new BootstrapOrderingBeanComparator());
this.classes = new HashSet<AnnotatedClass<?>>();
}
-
- public void addBean(RIBean<?> bean)
+ public BeanDeployer addBean(RIBean<?> bean)
{
this.beans.add(bean);
+ return this;
}
- public void addClass(Class<?> clazz)
+ public BeanDeployer addClass(Class<?> clazz)
{
if (!clazz.isAnnotation() && !clazz.isEnum())
{
classes.add(AnnotatedClassImpl.of(clazz));
}
+ return this;
}
- public void addClasses(Iterable<Class<?>> classes)
+ public BeanDeployer addClasses(Iterable<Class<?>> classes)
{
for (Class<?> clazz : classes)
{
addClass(clazz);
}
+ return this;
}
- public void deploy()
+ public BeanDeployer createBeans()
{
for (AnnotatedClass<?> clazz : classes)
{
@@ -86,16 +89,37 @@
createSimpleBean(clazz);
}
}
+ return this;
+ }
+
+ public BeanDeployer deploy()
+ {
+ printBeans();
manager.setBeans(beans);
+ return this;
}
+ public Set<RIBean<?>> getBeans()
+ {
+ return beans;
+ }
+
+ protected void printBeans()
+ {
+ for (RIBean<?> bean : beans)
+ {
+ log.info("Bean: " + bean);
+ }
+ }
+
/**
* Creates a Web Bean from a bean abstraction and adds it to the set of
* created beans
*
* Also creates the implicit field- and method-level beans, if present
*
- * @param bean The bean representation
+ * @param bean
+ * The bean representation
*/
protected void createBean(AbstractClassBean<?> bean, final AnnotatedClass<?> annotatedClass)
{
@@ -114,8 +138,6 @@
createRealizedProducerFields(bean, annotatedClass);
createRealizedObserverMethods(bean, annotatedClass);
}
-
- log.info("Web Bean: " + bean);
}
private void createProducerMethods(AbstractClassBean<?> declaringBean, AnnotatedClass<?> annotatedClass)
@@ -132,14 +154,13 @@
ProducerMethodBean<?> bean = ProducerMethodBean.of(annotatedMethod, declaringBean, manager);
beans.add(bean);
manager.getResolver().addInjectionPoints(bean.getInjectionPoints());
- log.info("Web Bean: " + bean);
}
private void createRealizedProducerMethods(AbstractClassBean<?> declaringBean, AnnotatedClass<?> realizingClass)
{
AnnotatedClass<?> realizedClass = realizingClass.getSuperclass();
for (AnnotatedMethod<?> realizedMethod : realizedClass.getDeclaredAnnotatedMethods(Produces.class))
- {
+ {
createProducerMethod(declaringBean, realizeProducerMethod(realizedMethod, realizingClass));
}
}
@@ -148,7 +169,7 @@
{
AnnotatedClass<?> realizedClass = realizingClass.getSuperclass();
for (final AnnotatedField<?> realizedField : realizedClass.getDeclaredAnnotatedFields(Produces.class))
- {
+ {
createProducerField(declaringBean, realizeProducerField(realizedField, realizingClass));
}
}
@@ -157,7 +178,6 @@
{
ProducerFieldBean<?> bean = ProducerFieldBean.of(field, declaringBean, manager);
beans.add(bean);
- log.info("Web Bean: " + bean);
}
private void createProducerFields(AbstractClassBean<?> declaringBean, AnnotatedClass<?> annotatedClass)
@@ -167,7 +187,7 @@
createProducerField(declaringBean, field);
}
}
-
+
private void createObserverMethods(AbstractClassBean<?> declaringBean, AnnotatedClass<?> annotatedClass)
{
for (AnnotatedMethod<?> method : annotatedClass.getDeclaredMethodsWithAnnotatedParameters(Observes.class))
@@ -205,7 +225,8 @@
/**
* Indicates if the type is a simple Web Bean
*
- * @param type The type to inspect
+ * @param type
+ * The type to inspect
* @return True if simple Web Bean, false otherwise
*/
private boolean isTypeSimpleWebBean(AnnotatedClass<?> clazz)
@@ -218,11 +239,9 @@
return !Reflections.isAbstract(rawType) && !Reflections.isParameterizedType(rawType) && !servletApiAbstraction.SERVLET_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.FILTER_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.SERVLET_CONTEXT_LISTENER_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.HTTP_SESSION_LISTENER_CLASS.isAssignableFrom(rawType) && !servletApiAbstraction.SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(rawType) && !ejbApiAbstraction.ENTERPRISE_BEAN_CLASS.isAssignableFrom(rawType) && !jsfApiAbstraction.UICOMPONENT_CLASS.isAssignableFrom(rawType) && hasSimpleWebBeanConstructor(clazz);
}
-
-
private static boolean hasSimpleWebBeanConstructor(AnnotatedClass<?> type)
{
- return type.getNoArgsConstructor() != null || type.getAnnotatedConstructors(Initializer.class).size() > 0;
+ return type.getNoArgsConstructor() != null || type.getAnnotatedConstructors(Initializer.class).size() > 0;
}
private static <T> AnnotatedMethod<T> realizeProducerMethod(final AnnotatedMethod<T> method, final AnnotatedClass<?> realizingClass)
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,124 @@
+package org.jboss.webbeans.bootstrap;
+
+import java.util.Comparator;
+
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.AbstractProducerBean;
+import org.jboss.webbeans.bean.NewBean;
+import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.bean.standard.AbstractStandardBean;
+
+public class BootstrapOrderingBeanComparator implements Comparator<RIBean<?>>
+{
+
+ public int compare(RIBean<?> o1, RIBean<?> o2)
+ {
+ if (o1 instanceof AbstractStandardBean && !(o2 instanceof AbstractStandardBean))
+ {
+ return -1;
+ }
+ else if (!(o1 instanceof AbstractStandardBean) && o2 instanceof AbstractStandardBean)
+ {
+ return 1;
+ }
+ else if (o1 instanceof AbstractStandardBean && o2 instanceof AbstractStandardBean)
+ {
+ return o1.getId().compareTo(o2.getId());
+ }
+ else if (o1.getType().getName().startsWith("org.jboss.webbeans") && !o2.getType().getName().startsWith("org.jboss.webbeans"))
+ {
+ return -1;
+ }
+ else if (!o1.getType().getName().startsWith("org.jboss.webbeans") && o2.getType().getName().startsWith("org.jboss.webbeans"))
+ {
+ return 1;
+ }
+ else if (o1 instanceof AbstractClassBean)
+ {
+ AbstractClassBean<?> b1 = (AbstractClassBean<?>) o1;
+ if (o2 instanceof NewBean && !(o1 instanceof NewBean))
+ {
+ // Always initialize new beans after class beans
+ return -1;
+ }
+ else if (o1 instanceof NewBean && o2 instanceof AbstractClassBean && !(o2 instanceof NewBean))
+ {
+ // Always initialize new beans after class beans
+ return 1;
+ }
+ else if (o1 instanceof NewBean && !(o2 instanceof NewBean))
+ {
+ // Always initialize new class beans after class beans but before other beans
+ return -1;
+ }
+ else if (o1 instanceof NewBean && o2 instanceof NewBean)
+ {
+ return o1.getId().compareTo(o2.getId());
+ }
+ else if (o2 instanceof AbstractClassBean)
+ {
+ AbstractClassBean<?> b2 = (AbstractClassBean<?>) o2;
+ if (o1.getTypes().contains(b2.getType()))
+ {
+ return 1;
+ }
+ else if (b2.getTypes().contains(b1.getType()))
+ {
+ return -1;
+ }
+ else
+ {
+ return o1.getId().compareTo(o2.getId());
+ }
+ }
+ else if (o2 instanceof AbstractProducerBean)
+ {
+ // Producer beans are always initialized after class beans
+ return -1;
+ }
+ else
+ {
+ // Ordering doesn't matter
+ return o1.getId().compareTo(o2.getId());
+ }
+ }
+ else if (o1 instanceof AbstractProducerBean)
+ {
+ AbstractProducerBean<?, ?> b1 = (AbstractProducerBean<?, ?>) o1;
+ if (o2 instanceof NewBean)
+ {
+ // Always initialize producers beans after new beans
+ return 1;
+ }
+ else if (o2 instanceof AbstractClassBean)
+ {
+ if (b1.getDeclaringBean().equals(o2))
+ {
+ return 1;
+ }
+ else
+ {
+ return o1.getId().compareTo(o2.getId());
+ }
+ }
+ else
+ {
+ // Ordering doesn't matter
+ return o1.getId().compareTo(o2.getId());
+ }
+ }
+ else
+ {
+ if (o2 instanceof AbstractClassBean || o2 instanceof AbstractProducerBean)
+ {
+ // Initialize undefined ordering after defined ordering
+ return 1;
+ }
+ else
+ {
+ return o1.getId().compareTo(o2.getId());
+ }
+ }
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-22 13:27:30 UTC (rev 2131)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -134,7 +134,7 @@
beanDeployer.addClass(NumericConversationIdGenerator.class);
beanDeployer.addClass(HttpSessionManager.class);
}
- beanDeployer.deploy();
+ beanDeployer.createBeans().deploy();
}
public void boot()
Added: ri/trunk/tests/src/test/java/com/acme/RoadRunner.java
===================================================================
--- ri/trunk/tests/src/test/java/com/acme/RoadRunner.java (rev 0)
+++ ri/trunk/tests/src/test/java/com/acme/RoadRunner.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,6 @@
+package com.acme;
+
+public class RoadRunner
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/com/acme/RoadRunner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Animal.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Animal.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Animal.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+interface Animal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Animal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Cow.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Cow.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Cow.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.context.ApplicationScoped;
+
+@ApplicationScoped
+class Cow implements Animal
+{
+
+ public static boolean mooed = false;
+
+ public void moo()
+ {
+ mooed = true;
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Cow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,113 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+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.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.NewBean;
+import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.standard.AbstractStandardBean;
+import org.jboss.webbeans.bean.standard.EventBean;
+import org.jboss.webbeans.bean.standard.InjectionPointBean;
+import org.jboss.webbeans.bean.standard.InstanceBean;
+import org.jboss.webbeans.bean.standard.ManagerBean;
+import org.jboss.webbeans.bootstrap.BeanDeployer;
+import org.jboss.webbeans.mock.MockEjbDescriptor;
+import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+import com.acme.RoadRunner;
+
+@Artifact
+(a)Packaging(PackagingType.EAR)
+@Classes(packages="com.acme")
+public class DeployerOrderingTest extends AbstractWebBeansTest
+{
+
+ @Test(groups="bootstrap")
+ public void testNewSimpleBeansAfterNonNew()
+ {
+ BeanDeployer beanDeployer = new BeanDeployer(manager);
+ beanDeployer.addClasses(Arrays.asList(Cow.class, Tuna.class));
+ beanDeployer.createBeans();
+ assert beanDeployer.getBeans().size() == 4;
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(0, 2))
+ {
+ assert !(bean instanceof NewBean);
+ assert bean instanceof SimpleBean;
+ }
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(2, 4))
+ {
+ assert (bean instanceof NewBean);
+ assert bean instanceof SimpleBean;
+ }
+ }
+
+ @Test(groups="bootstrap")
+ public void testNewEnterpriseBeansAfterNonNew()
+ {
+ BeanDeployer beanDeployer = new BeanDeployer(manager);
+ beanDeployer.addClasses(Arrays.asList(Lion.class, Gazelle.class));
+ manager.getEjbDescriptorCache().add(MockEjbDescriptor.of(Lion.class));
+ manager.getEjbDescriptorCache().add(MockEjbDescriptor.of(Gazelle.class));
+ beanDeployer.createBeans();
+ assert beanDeployer.getBeans().size() == 4;
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(0, 2))
+ {
+ assert !(bean instanceof NewBean);
+ assert bean instanceof EnterpriseBean;
+ }
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(2, 4))
+ {
+ assert (bean instanceof NewBean);
+ assert bean instanceof EnterpriseBean;
+ }
+ }
+
+ @Test(groups="bootstrap")
+ public void testStandardBeansBeforeAll()
+ {
+ BeanDeployer beanDeployer = new BeanDeployer(manager);
+ beanDeployer.addBean(EventBean.of(manager)).addBean(InjectionPointBean.of(manager)).addBean(InstanceBean.of(manager)).addBean(ManagerBean.of(manager));
+ beanDeployer.addClasses(Arrays.asList(Cow.class, Tuna.class));
+ beanDeployer.createBeans();
+ assert beanDeployer.getBeans().size() == 8;
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(0, 4))
+ {
+ assert bean instanceof AbstractStandardBean;
+ }
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(4, 6))
+ {
+ assert !(bean instanceof NewBean);
+ assert bean instanceof SimpleBean;
+ }
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(6, 8))
+ {
+ assert (bean instanceof NewBean);
+ assert bean instanceof SimpleBean;
+ }
+ }
+
+ @Test(groups="bootstrap")
+ public void testOrgJbossWebbeansBeforeUsers()
+ {
+ BeanDeployer beanDeployer = new BeanDeployer(manager);
+ beanDeployer.addClasses(Arrays.asList(Cow.class, Tuna.class, RoadRunner.class));
+ beanDeployer.createBeans();
+ assert beanDeployer.getBeans().size() == 6;
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(0, 4))
+ {
+ assert bean.getType().getName().startsWith("org.jboss.webbeans");
+ }
+ for (RIBean<?> bean : new ArrayList<RIBean<?>>(beanDeployer.getBeans()).subList(4, 6))
+ {
+ assert bean.getType().getName().startsWith("com.acme");
+ }
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Gazelle.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Gazelle.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Gazelle.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Production;
+
+@Production
+@Stateful
+class Gazelle implements GazelleLocal
+{
+
+ @Remove
+ public void remove1()
+ {
+
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Gazelle.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/GazelleLocal.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/GazelleLocal.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/GazelleLocal.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.ejb.Local;
+
+@Local
+public interface GazelleLocal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/GazelleLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Lion.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Lion.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Lion.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Production;
+
+@Production
+@Stateful
+class Lion implements LionLocal
+{
+
+ @Remove
+ public void remove1()
+ {
+
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Lion.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/LionLocal.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/LionLocal.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/LionLocal.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.ejb.Local;
+
+@Local
+public interface LionLocal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/LionLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tuna.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tuna.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tuna.java 2009-03-22 17:18:51 UTC (rev 2132)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.context.RequestScoped;
+
+@RequestScoped
+class Tuna
+{
+
+ public String getName()
+ {
+ return "Ophir";
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Tuna.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/tests/unit-tests.xml
===================================================================
--- ri/trunk/tests/unit-tests.xml 2009-03-22 13:27:30 UTC (rev 2131)
+++ ri/trunk/tests/unit-tests.xml 2009-03-22 17:18:51 UTC (rev 2132)
@@ -43,6 +43,7 @@
<packages>
<package name="org.jboss.webbeans.test.examples" />
<package name="org.jboss.webbeans.test.unit.bootstrap" />
+ <package name="org.jboss.webbeans.test.unit.bootstrap.ordering" />
<package name="org.jboss.webbeans.test.unit.bootstrap.environments" />
<package name="org.jboss.webbeans.test.unit.bootstrap.environments.multipleEnterprise" />
<package name="org.jboss.webbeans.test.unit.bootstrap.environments.multipleEnterpriseAndSimple" />
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2131 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-22 09:27:30 -0400 (Sun, 22 Mar 2009)
New Revision: 2131
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
Log:
minor
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 13:24:30 UTC (rev 2130)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-22 13:27:30 UTC (rev 2131)
@@ -1,9 +1,7 @@
package org.jboss.webbeans.bootstrap;
import java.lang.annotation.Annotation;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import javax.event.Observes;
@@ -40,20 +38,17 @@
public class BeanDeployer
{
- // Empty list representing no-args
- private static List<Class<?>> NO_ARGUMENTS = Collections.emptyList();
-
private static final LogProvider log = Logging.getLogProvider(BeanDeployer.class);
private final Set<RIBean<?>> beans;
- private final Set<AnnotatedClass<?>> deferredClasses;
+ private final Set<AnnotatedClass<?>> classes;
private final ManagerImpl manager;
public BeanDeployer(ManagerImpl manager)
{
this.manager = manager;
this.beans = new HashSet<RIBean<?>>();
- this.deferredClasses = new HashSet<AnnotatedClass<?>>();
+ this.classes = new HashSet<AnnotatedClass<?>>();
}
@@ -66,7 +61,7 @@
{
if (!clazz.isAnnotation() && !clazz.isEnum())
{
- deferredClasses.add(AnnotatedClassImpl.of(clazz));
+ classes.add(AnnotatedClassImpl.of(clazz));
}
}
@@ -80,7 +75,7 @@
public void deploy()
{
- for (AnnotatedClass<?> clazz : deferredClasses)
+ for (AnnotatedClass<?> clazz : classes)
{
if (manager.getEjbDescriptorCache().containsKey(clazz.getRawType()))
{
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2130 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-03-22 09:24:30 -0400 (Sun, 22 Mar 2009)
New Revision: 2130
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewBean.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
Log:
Add a marker interface for @New beans
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewBean.java 2009-03-22 13:24:30 UTC (rev 2130)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.bean;
+
+/**
+ * Marker interface for @New beans
+ *
+ * @author Pete Muir
+ *
+ */
+public interface NewBean
+{
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-03-22 10:42:28 UTC (rev 2129)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-03-22 13:24:30 UTC (rev 2130)
@@ -33,7 +33,7 @@
*
* @author Nicklas Karlsson
*/
-public class NewEnterpriseBean<T> extends EnterpriseBean<T>
+public class NewEnterpriseBean<T> extends EnterpriseBean<T> implements NewBean
{
private static Set<Annotation> NEW_BINDING_SET = new HashSet<Annotation>(Arrays.asList(new NewLiteral()));
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java 2009-03-22 10:42:28 UTC (rev 2129)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java 2009-03-22 13:24:30 UTC (rev 2130)
@@ -34,7 +34,7 @@
*
* @author Nicklas Karlsson
*/
-public class NewSimpleBean<T> extends SimpleBean<T>
+public class NewSimpleBean<T> extends SimpleBean<T> implements NewBean
{
private static Set<Annotation> NEW_BINDING_SET = new HashSet<Annotation>(Arrays.asList(new NewLiteral()));
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2129 - in extensions/trunk/logger/src: main/java/org/jboss/webbeans/producer and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-03-22 06:42:28 -0400 (Sun, 22 Mar 2009)
New Revision: 2129
Added:
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Finch.java
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/TestAppender.java
extensions/trunk/logger/src/test/resources/log4j.xml
Modified:
extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java
extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java
extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java
Log:
Fixed outstanding bugs and finished the unit tests
Modified: extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java
===================================================================
--- extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java 2009-03-21 12:59:19 UTC (rev 2128)
+++ extensions/trunk/logger/src/main/java/org/jboss/webbeans/annotation/Logger.java 2009-03-22 10:42:28 UTC (rev 2129)
@@ -1,12 +1,16 @@
package org.jboss.webbeans.annotation;
import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import javax.annotation.NonBinding;
import javax.inject.BindingType;
/**
@@ -14,7 +18,7 @@
*
* @author Gavin King
*/
-@Target(FIELD)
+@Target({METHOD, FIELD, PARAMETER, TYPE})
@Retention(RUNTIME)
@Documented
@BindingType
@@ -23,5 +27,6 @@
/**
* @return the log category
*/
+ @NonBinding
String value() default "";
}
Modified: extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java
===================================================================
--- extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java 2009-03-21 12:59:19 UTC (rev 2128)
+++ extensions/trunk/logger/src/main/java/org/jboss/webbeans/producer/LoggerProducer.java 2009-03-22 10:42:28 UTC (rev 2129)
@@ -17,9 +17,7 @@
package org.jboss.webbeans.producer;
-import javax.context.ApplicationScoped;
import javax.inject.Current;
-import javax.inject.DefinitionException;
import javax.inject.Produces;
import javax.inject.manager.InjectionPoint;
@@ -38,17 +36,13 @@
*/
public class LoggerProducer
{
- @Produces @ApplicationScoped
+ @Produces @Logger
public Log produceLog(@Current InjectionPoint injectionPoint)
{
Log log = null;
String category = null;
- if (injectionPoint.getType().equals(Log.class))
- {
- throw new DefinitionException("Cannot use @Logger on any type other than org.jboss.webbeans.log.Log: " + injectionPoint);
- }
category = injectionPoint.getAnnotation(Logger.class).value();
- if (category == null)
+ if (category.isEmpty())
{
log = Logging.getLog((Class<?>) injectionPoint.getMember().getDeclaringClass());
}
Added: extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Finch.java
===================================================================
--- extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Finch.java (rev 0)
+++ extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Finch.java 2009-03-22 10:42:28 UTC (rev 2129)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.test.log;
+
+import org.jboss.webbeans.annotation.Logger;
+import org.jboss.webbeans.log.Log;
+
+public class Finch
+{
+ @Logger("Finch")
+ private Log log;
+
+ public void generateLogMessage()
+ {
+ log.info("A test message");
+ }
+}
Property changes on: extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/Finch.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java
===================================================================
--- extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java 2009-03-21 12:59:19 UTC (rev 2128)
+++ extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/LoggerInjectionTest.java 2009-03-22 10:42:28 UTC (rev 2129)
@@ -17,6 +17,8 @@
package org.jboss.webbeans.test.log;
+import javax.inject.ExecutionException;
+
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.webbeans.test.AbstractLogTest;
@@ -26,16 +28,26 @@
* All the tests related to the @Logger binding type and injection.
*
* @author David Allen
- *
*/
@Artifact
@Classes(packages = { "org.jboss.webbeans.producer", "org.jboss.webbeans.test.log" })
public class LoggerInjectionTest extends AbstractLogTest
{
- @Test( groups = { "broken" } )
+ @Test
public void testBasicLogInjection()
{
Sparrow bird = getCurrentManager().getInstanceByType(Sparrow.class);
bird.generateLogMessage();
+ assert TestAppender.getLastEvent() != null;
+ assert TestAppender.getLastEvent().getLoggerName().equals("org.jboss.webbeans.test.log.Sparrow");
}
+
+ @Test
+ public void testCategorySpecifiedLogger()
+ {
+ Finch bird = getCurrentManager().getInstanceByType(Finch.class);
+ bird.generateLogMessage();
+ assert TestAppender.getLastEvent() != null;
+ assert TestAppender.getLastEvent().getLoggerName().equals("Finch");
+ }
}
Added: extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/TestAppender.java
===================================================================
--- extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/TestAppender.java (rev 0)
+++ extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/TestAppender.java 2009-03-22 10:42:28 UTC (rev 2129)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.log;
+
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.varia.NullAppender;
+
+public class TestAppender extends NullAppender
+{
+ private static LoggingEvent lastEvent;
+
+ @Override
+ public void doAppend(LoggingEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public static LoggingEvent getLastEvent()
+ {
+ return lastEvent;
+ }
+
+}
Property changes on: extensions/trunk/logger/src/test/java/org/jboss/webbeans/test/log/TestAppender.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/logger/src/test/resources/log4j.xml
===================================================================
--- extensions/trunk/logger/src/test/resources/log4j.xml (rev 0)
+++ extensions/trunk/logger/src/test/resources/log4j.xml 2009-03-22 10:42:28 UTC (rev 2129)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.jboss.webbeans.test.log.TestAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{2}] %m%n"/>
+ </layout>
+ </appender>
+
+ <category name="org.jboss.webbeans.test">
+ <priority value="INFO"/>
+ </category>
+
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Property changes on: extensions/trunk/logger/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 10 months
[webbeans-commits] Webbeans SVN: r2128 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests: definition/binding/session and 5 other directories.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-03-21 08:59:19 -0400 (Sat, 21 Mar 2009)
New Revision: 2128
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollie.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollieLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/Hairy.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/HairyBinding.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/LongHairedDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/SessionBindingDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/City.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/CityProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IndirectOrderProcessor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IntermediateOrderProcessor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessorLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/SessionBeanLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorBinding.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorHenHouse.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/PoorHenHouse.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/SessionBeanInjectionTest.java
Log:
some session bean tests
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollie.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollie.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollie.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.definition.binding.session;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class BorderCollie extends LongHairedDog implements BorderCollieLocal
+{
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollieLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollieLocal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/BorderCollieLocal.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.definition.binding.session;
+
+import javax.ejb.Local;
+
+@Local
+public interface BorderCollieLocal
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/Hairy.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/Hairy.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/Hairy.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,25 @@
+package org.jboss.jsr299.tck.tests.definition.binding.session;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@Inherited
+@interface Hairy
+{
+ public boolean clipped();
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/HairyBinding.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/HairyBinding.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/HairyBinding.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.definition.binding.session;
+
+import javax.inject.AnnotationLiteral;
+
+public class HairyBinding extends AnnotationLiteral<Hairy> implements Hairy
+{
+ private boolean clipped;
+
+ public HairyBinding(boolean clipped)
+ {
+ this.clipped = clipped;
+ }
+
+ public boolean clipped()
+ {
+ return clipped;
+ }
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/LongHairedDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/LongHairedDog.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/LongHairedDog.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.definition.binding.session;
+
+@Hairy(clipped=false)
+class LongHairedDog
+{
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/SessionBindingDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/SessionBindingDefinitionTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/session/SessionBindingDefinitionTest.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,27 @@
+package org.jboss.jsr299.tck.tests.definition.binding.session;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
+public class SessionBindingDefinitionTest extends AbstractJSR299Test
+{
+ @Test
+ @SpecAssertion(section = "4.1", id = "ad")
+ public void testBindingDeclaredInheritedIsInherited() throws Exception
+ {
+ Set<? extends Annotation> bindings = getCurrentManager().resolveByType(BorderCollieLocal.class, new HairyBinding(false)).iterator().next().getBindings();
+ assert bindings.size() == 1;
+ assert bindings.iterator().next().annotationType().equals(Hairy.class);
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/City.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/City.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/City.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.disposal.definition;
+
+class City
+{
+ private boolean disposed = false;
+ void dispose() { disposed = true; }
+
+ boolean isDisposed() { return disposed; }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/CityProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/CityProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/CityProducer.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.implementation.producer.method.disposal.definition;
+
+import javax.inject.Disposes;
+import javax.inject.Produces;
+
+class CityProducer
+{
+ @Produces City createCity() { return new City(); }
+
+ void disposeCity(@Disposes City city) { city.dispose(); }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IndirectOrderProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IndirectOrderProcessor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IndirectOrderProcessor.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.session.lifecycle;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+@Stateful
+public class IndirectOrderProcessor extends IntermediateOrderProcessor implements OrderProcessorLocal
+{
+ @Remove
+ public void remove()
+ {
+
+ }
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IntermediateOrderProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IntermediateOrderProcessor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/IntermediateOrderProcessor.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.implementation.session.lifecycle;
+
+class IntermediateOrderProcessor extends OrderProcessor
+{
+
+}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessor.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,30 @@
+package org.jboss.jsr299.tck.tests.implementation.session.lifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+class OrderProcessor
+{
+ public static boolean postConstructCalled = false;
+
+ public static boolean preDestroyCalled = true;
+
+ @PostConstruct
+ public void postConstruct()
+ {
+ postConstructCalled = true;
+ }
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ preDestroyCalled = true;
+ }
+
+ public void order()
+ {
+
+ }
+
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessorLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessorLocal.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/OrderProcessorLocal.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.session.lifecycle;
+
+import javax.ejb.Local;
+
+@Local
+public interface OrderProcessorLocal
+{
+ void order();
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/SessionBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/SessionBeanLifecycleTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/session/lifecycle/SessionBeanLifecycleTest.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,32 @@
+package org.jboss.jsr299.tck.tests.implementation.session.lifecycle;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
+public class SessionBeanLifecycleTest extends AbstractJSR299Test
+{
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "4.2", id = "bac")
+ public void testIndirectSubClassInheritsPostConstructOnSuperclass() throws Exception
+ {
+ OrderProcessor.postConstructCalled = false;
+ assert getCurrentManager().resolveByType(OrderProcessorLocal.class).size() == 1;
+ new RunInDependentContext()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ getCurrentManager().getInstanceByType(OrderProcessorLocal.class).order();
+ }
+ }.run();
+ assert OrderProcessor.postConstructCalled;
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoor.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.session;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@Inherited
+@interface MegaPoor
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorBinding.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorBinding.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorBinding.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.session;
+
+import javax.inject.AnnotationLiteral;
+
+class MegaPoorBinding extends AnnotationLiteral<MegaPoor> implements MegaPoor
+{
+
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorHenHouse.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorHenHouse.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/MegaPoorHenHouse.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.session;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+@MegaPoor
+@Stateful
+public class MegaPoorHenHouse extends PoorHenHouse implements HenHouseLocal
+{
+ public Fox getFox()
+ {
+ return fox;
+ }
+
+ @Remove
+ public void remove()
+ {
+
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/PoorHenHouse.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/PoorHenHouse.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/PoorHenHouse.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.session;
+
+class PoorHenHouse extends HenHouse
+{
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/SessionBeanInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/SessionBeanInjectionTest.java 2009-03-21 10:50:31 UTC (rev 2127)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/session/SessionBeanInjectionTest.java 2009-03-21 12:59:19 UTC (rev 2128)
@@ -35,4 +35,21 @@
}
}.run();
}
+
+ @Test
+ @SpecAssertion(section = "4.2", id = "ad")
+ public void testFieldDeclaredInSessionBeanIndirectSuperclassInjected() throws Exception
+ {
+ new RunInDependentContext()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ Bean<HenHouseLocal> bean = getCurrentManager().resolveByType(HenHouseLocal.class, new MegaPoorBinding()).iterator().next();
+ HenHouseLocal henHouse = getCurrentManager().getInstance(bean);
+ assert henHouse.getFox() != null;
+ assert henHouse.getFox().getName().equals("gavin");
+ }
+ }.run();
+ }
}
15 years, 10 months