[jboss-cvs] JBossAS SVN: r94777 - in projects/kernel/trunk: weld-int and 53 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 13 12:18:41 EDT 2009
Author: alesj
Date: 2009-10-13 12:18:38 -0400 (Tue, 13 Oct 2009)
New Revision: 94777
Added:
projects/kernel/trunk/weld-int/
projects/kernel/trunk/weld-int/pom.xml
projects/kernel/trunk/weld-int/src/
projects/kernel/trunk/weld-int/src/main/
projects/kernel/trunk/weld-int/src/main/java/
projects/kernel/trunk/weld-int/src/main/java/org/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotated.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedCallable.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedConstructor.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedField.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMember.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMethod.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedParameter.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedType.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldConfigureAction.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerContextActions.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerInitializer.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldDescribeAction.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInjector.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInstantiateAction.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldKernelControllerContext.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPostConstructAction.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPreDestroyAction.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldRegisterWebBeanAction.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/metadata/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/metadata/WeldDependencyMetaData.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McAfterBeanDiscoveryObserver.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/WeldFromMcRegistry.java
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/spi/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/spi/annotated/
projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/spi/annotated/MDRAnnotatedTypeFactory.java
projects/kernel/trunk/weld-int/src/main/resources/
projects/kernel/trunk/weld-int/src/main/resources/findbugs/
projects/kernel/trunk/weld-int/src/main/resources/findbugs/exclude.xml
projects/kernel/trunk/weld-int/src/test/
projects/kernel/trunk/weld-int/src/test/java/
projects/kernel/trunk/weld-int/src/test/java/org/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AbstractWeldMcTest.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AutoDeployMcBeans.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldMcTestDelegate.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldTestSuite.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedTypeTestCase.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Child.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/NotAnnotatedBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Parent.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test1.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test2.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test3.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/Thing.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingTarget.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/test/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/test/BeanImplementationTestCase.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/Thing.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingFieldProducer.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingMethodProducer.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingConstructor.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingField.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/Bean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/FailedBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesConstructorBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesFieldBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanConstructor.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanField.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanMixed.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/InjectWeldInMcBeansTestCase.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanAnnotationsFromMetaData.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanInitializerMethod.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanMcConstructor.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWebBeanSetter.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/Simple.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBean.java
projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBeanConsumer.java
projects/kernel/trunk/weld-int/src/test/resources/
projects/kernel/trunk/weld-int/src/test/resources/META-INF/
projects/kernel/trunk/weld-int/src/test/resources/META-INF/services/
projects/kernel/trunk/weld-int/src/test/resources/META-INF/services/placeholder.txt
projects/kernel/trunk/weld-int/src/test/resources/log4j.properties
projects/kernel/trunk/weld-int/src/test/resources/org/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/validateobserver/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/validateobserver/javax.enterprise.inject.spi.Extension
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/wb/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/wb/javax.enterprise.inject.spi.Extension
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/testharness/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/testharness/impl/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/testharness/impl/packaging/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/
projects/kernel/trunk/weld-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
Removed:
projects/kernel/trunk/webbeans-int/
Modified:
projects/kernel/trunk/pom.xml
Log:
Do WebBeans to Weld rename.
TODO - enable weld-int once Weld is in better shape wrt releases.
Modified: projects/kernel/trunk/pom.xml
===================================================================
--- projects/kernel/trunk/pom.xml 2009-10-13 16:18:28 UTC (rev 94776)
+++ projects/kernel/trunk/pom.xml 2009-10-13 16:18:38 UTC (rev 94777)
@@ -29,7 +29,7 @@
<module>jmx-aop-mc-int</module>
<module>spring-int</module>
<module>guice-int</module>
- <module>webbeans-int</module>
+ <!-- module>weld-int</module -->
<module>build</module>
</modules>
@@ -53,7 +53,7 @@
<version.jboss.jbpm>3.1.1</version.jboss.jbpm>
<version.google.guice>2.0</version.google.guice>
<version.jboss.byteman>1.0.3.CP01</version.jboss.byteman>
- <version.org.jboss.webbeans.ri>1.0.0-SNAPSHOT</version.org.jboss.webbeans.ri>
+ <version.org.jboss.weld.ri>1.0.0-SNAPSHOT</version.org.jboss.weld.ri>
<version.org.jboss.ejb3.api>3.1.0-Alpha1</version.org.jboss.ejb3.api>
<version.javax.validation>1.0.CR3</version.javax.validation>
<version.javax.faces.jsf-api>1.2_12</version.javax.faces.jsf-api>
@@ -273,18 +273,18 @@
<version>${version.ant.junit}</version>
</dependency>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
+ <groupId>org.jboss.weld</groupId>
<artifactId>jsr299-api</artifactId>
- <version>${version.org.jboss.webbeans.ri}</version>
+ <version>${version.org.jboss.weld.ri}</version>
</dependency>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
- <artifactId>webbeans-core-test</artifactId>
- <version>${version.org.jboss.webbeans.ri}</version>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-test</artifactId>
+ <version>${version.org.jboss.weld.ri}</version>
</dependency>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
- <artifactId>webbeans-bean-utils</artifactId>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-bean-utils</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- Move this down to tests once finalized -->
@@ -354,9 +354,9 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
- <artifactId>webbeans-core-test</artifactId>
- <version>${version.org.jboss.webbeans.ri}</version>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-test</artifactId>
+ <version>${version.org.jboss.weld.ri}</version>
</dependency>
</dependencies>
</dependencyManagement>
Added: projects/kernel/trunk/weld-int/pom.xml
===================================================================
--- projects/kernel/trunk/weld-int/pom.xml (rev 0)
+++ projects/kernel/trunk/weld-int/pom.xml 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,111 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-mc-kernel</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-weld-int</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Microcontainer Weld Int</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Microcontainer Weld Integration</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ <!--testFailureIgnore>true</testFailureIgnore-->
+ <excludes>
+ <exclude>org/jboss/test/kernel/asynchronous/**/*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <!-- Do not add version information here, use ../pom.xml instead -->
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>jsr299-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-test</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-bean-utils</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <version>${version.javax.validation}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+</project>
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotated.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotated.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotated.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,170 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * Decorator that understands MDR metadata
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MDRAnnotated implements Annotated
+{
+ /** The delegate */
+ private Annotated delegate;
+
+ /** The MDR metadata */
+ private MetaData metaData;
+
+ /**
+ * Constructor
+ *
+ * @param delegate the delegate
+ * @param metaData the MDR metadata
+ */
+ public MDRAnnotated(Annotated delegate, MetaData metaData)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate");
+ this.delegate = delegate;
+ this.metaData = metaData;
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ Annotated getDelegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Gets the MDR metadata
+ *
+ * @return the MDR metadata
+ */
+ MetaData getMetaData()
+ {
+ return metaData;
+ }
+
+ /**
+ * Gets the base type from the delegate
+ *
+ * @return the base type
+ */
+ public Type getBaseType()
+ {
+ return delegate.getBaseType();
+ }
+
+ /**
+ * Gets the type closure from the delegate
+ *
+ * @return the type closure
+ */
+ public Set<Type> getTypeClosure()
+ {
+ return delegate.getTypeClosure();
+ }
+
+ /**
+ * Gets an annotation
+ *
+ * @param the annotation type to get
+ * @return the annotations from the delegate and the MDR metadata
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ if (metaData != null)
+ {
+ T t = metaData.getAnnotation(annotationType);
+ if (t != null)
+ return t;
+ }
+ return getDelegate().getAnnotation(annotationType);
+ }
+
+ /**
+ * Gets the annotations
+ *
+ * @return the annotations from the delegate and the MDR metadata
+ */
+ public Set<Annotation> getAnnotations()
+ {
+ Set<Annotation> annotations = new HashSet<Annotation>(getDelegate().getAnnotations());
+ if (metaData == null)
+ return annotations;
+
+ Annotation[] metaDataAnnotations = metaData.getAnnotations();
+ if (metaDataAnnotations.length == 0)
+ return annotations;
+
+ if (annotations.size() == 0)
+ {
+ Set<Annotation> metaDataAnns = new HashSet<Annotation>();
+ for (Annotation ann : metaDataAnnotations)
+ {
+ metaDataAnns.add(ann);
+ }
+ return metaDataAnns;
+ }
+
+ Map<Class<?>, Annotation> done = new HashMap<Class<?>, Annotation>();
+
+ for (Annotation annotation : annotations)
+ done.put(annotation.annotationType(), annotation);
+ for (Annotation annotation : metaDataAnnotations)
+ {
+ done.put(annotation.annotationType(), annotation);
+ }
+ return new HashSet<Annotation>(done.values());
+ }
+
+ /**
+ * Checks if an annotation is present
+ *
+ * @return true if the annotation is present in the delegate or the MDR metadata
+ */
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ if (metaData != null)
+ {
+ if (metaData.isAnnotationPresent(annotationType))
+ return true;
+ }
+ return getDelegate().isAnnotationPresent(annotationType);
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedCallable.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedCallable.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedCallable.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,112 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.ParametersSignature;
+
+/**
+ * Decorator that understands MDR metadata for a method or constructor
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MDRAnnotatedCallable<X> extends MDRAnnotatedMember<X> implements AnnotatedCallable<X>
+{
+ private final List<AnnotatedParameter<X>> parameters;
+ private MetaData mainMetaData;
+
+ /**
+ * Constructor
+ *
+ * @param owner the annotated type containing this callable
+ * @param delegate the delegate
+ * @param metaData the MDR metadata for the method or constructor
+ * @param mainMetaData the MDR metadata for the class containing this method or constructor
+ */
+ public MDRAnnotatedCallable(MDRAnnotatedType<X> owner, Annotated delegate, MetaData metaData, MetaData mainMetaData)
+ {
+ super(owner, delegate, metaData);
+ this.mainMetaData = mainMetaData;
+ parameters = initialiseParameters();
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ @Override
+ AnnotatedCallable<X> getDelegate()
+ {
+ return (AnnotatedCallable<X>) super.getDelegate();
+ }
+
+ /**
+ * initialises the parameters for this constructor or method
+ *
+ * @return the list of parameters, wrapped in decorators if there is MDR metadata
+ */
+ private List<AnnotatedParameter<X>> initialiseParameters()
+ {
+ if (getMetaData() == null)
+ return getDelegate().getParameters();
+
+ int size = getDelegate().getParameters().size();
+ List<AnnotatedParameter<X>> params = new ArrayList<AnnotatedParameter<X>>(size);
+ if (size > 0)
+ {
+ int i = 0;
+ for (AnnotatedParameter<X> param : getDelegate().getParameters())
+ {
+ MetaData parameterMetaData = mainMetaData.getComponentMetaData(getParametersSignature(i++));
+ params.add(new MDRAnnotatedParameter<X>(param, this, parameterMetaData));
+ }
+ }
+ return params;
+ }
+
+ /**
+ * Gets the MDR parameters signature for a parameter
+ *
+ * @param i the index of the parameter
+ * @return the parameter signature
+ */
+ abstract ParametersSignature getParametersSignature(int i);
+
+ /**
+ * Gets the parameters
+ *
+ * @return the parameters
+ */
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return parameters;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedConstructor.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedConstructor.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedConstructor.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import java.lang.reflect.Constructor;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.ConstructorParametersSignature;
+import org.jboss.metadata.spi.signature.ParametersSignature;
+
+/**
+ * Decorator that understands MDR metadata for constructor
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class MDRAnnotatedConstructor<X> extends MDRAnnotatedCallable<X> implements AnnotatedConstructor<X>
+{
+ /**
+ * Constructor
+ *
+ * @param owner the annotated type containing this callable
+ * @param delegate the delegate
+ * @param metaData the MDR metadata for the method or constructor
+ * @param mainMetaData the MDR metadata for the class containing this method or constructor
+ */
+ MDRAnnotatedConstructor(MDRAnnotatedType<X> owner, AnnotatedConstructor<X> delegate, MetaData metaData, MetaData mainMetaData)
+ {
+ super(owner, delegate, metaData, mainMetaData);
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ @Override
+ AnnotatedConstructor<X> getDelegate()
+ {
+ return (AnnotatedConstructor<X>)super.getDelegate();
+ }
+
+ /**
+ * Gets the java.lang.reflect.Constructor wrapped by this
+ *
+ * @return the Constructor
+ */
+ public Constructor<X> getJavaMember()
+ {
+ return getDelegate().getJavaMember();
+ }
+
+ /**
+ * Gets the MDR parameters signature for a parameter
+ *
+ * @param i the index of the parameter
+ * @return the parameter signature
+ */
+ @Override
+ ParametersSignature getParametersSignature(int i)
+ {
+ return new ConstructorParametersSignature(getJavaMember(), i);
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedField.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedField.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedField.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,70 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import java.lang.reflect.Field;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * Decorator that understands MDR metadata for a field
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class MDRAnnotatedField<X> extends MDRAnnotatedMember<X> implements AnnotatedField<X>
+{
+ /**
+ * Constructor
+ *
+ * @param owner the annotated type containing this field
+ * @param delegate the delegate
+ * @param metaData the MDR metadata for the method or constructor
+ */
+ MDRAnnotatedField(MDRAnnotatedType<X> owner, AnnotatedField<? super X> delegate, MetaData metaData)
+ {
+ super(owner, delegate, metaData);
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ @Override
+ AnnotatedField<X> getDelegate()
+ {
+ return (AnnotatedField<X>)super.getDelegate();
+ }
+
+ /**
+ * Gets the java.lang.reflect.Field wrapped by this
+ *
+ * @return the Field
+ */
+ public Field getJavaMember()
+ {
+ return getDelegate().getJavaMember();
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMember.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMember.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMember.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,97 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * Decorator that understands MDR metadata for a field, constructor or method
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MDRAnnotatedMember<X> extends MDRAnnotated implements AnnotatedMember<X>
+{
+ private MDRAnnotatedType<X> owner;
+ private volatile AnnotatedType<X> declaringOwner;
+
+ /**
+ * Constructor
+ *
+ * @param owner the annotated type containing this field
+ * @param delegate the delegate
+ * @param metaData the MDR metadata for the method or constructor
+ */
+ public MDRAnnotatedMember(MDRAnnotatedType<X> owner, Annotated delegate, MetaData metaData)
+ {
+ super(delegate, metaData);
+ if (owner == null)
+ throw new IllegalArgumentException("Null owner");
+ this.owner = owner;
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ @Override
+ AnnotatedMember<X> getDelegate()
+ {
+ return (AnnotatedMember<X>)super.getDelegate();
+ }
+
+ /**
+ * Gets the type declaring this member
+ *
+ * @return the decorated type with MDR metadata
+ */
+ public AnnotatedType<X> getDeclaringType()
+ {
+ AnnotatedType<X> declaring = getDelegate().getDeclaringType();
+ if (declaring.getJavaClass() != owner.getJavaClass())
+ {
+ if (declaringOwner == null)
+ {
+ AnnotatedType<X> type = new MDRAnnotatedType<X>(declaring, owner.getMetaData());
+ declaringOwner = type;
+ }
+ return declaringOwner;
+ }
+ return owner;
+ }
+
+ /**
+ * Is member static
+ *
+ * @return true if member is static
+ */
+ public boolean isStatic()
+ {
+ return getDelegate().isStatic();
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMethod.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMethod.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedMethod.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
+import org.jboss.metadata.spi.signature.ParametersSignature;
+
+/**
+ * Decorator that understands MDR metadata for a method
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MDRAnnotatedMethod<X> extends MDRAnnotatedCallable<X> implements AnnotatedMethod<X>
+{
+ /**
+ * Constructor
+ *
+ * @param owner the annotated type containing this callable
+ * @param delegate the delegate
+ * @param metaData the MDR metadata for the method or constructor
+ * @param mainMetaData the MDR metadata for the class containing this method or constructor
+ */
+ public MDRAnnotatedMethod(MDRAnnotatedType<X> owner, Annotated delegate, MetaData metaData, MetaData mainMetaData)
+ {
+ super(owner, delegate, metaData, mainMetaData);
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ @Override
+ public AnnotatedMethod<X> getDelegate()
+ {
+ return (AnnotatedMethod<X>)super.getDelegate();
+
+ }
+
+ /**
+ * Gets the java.lang.reflect.Method wrapped by this
+ *
+ * @return the Method
+ */
+ public Method getJavaMember()
+ {
+ return getDelegate().getJavaMember();
+ }
+
+ /**
+ * Gets the MDR parameters signature for a parameter
+ *
+ * @param i the index of the parameter
+ * @return the parameter signature
+ */
+ @Override
+ ParametersSignature getParametersSignature(int i)
+ {
+ return new MethodParametersSignature(getJavaMember(), i);
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedParameter.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedParameter.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedParameter.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * Decorator that understands MDR metadata for a parameter
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MDRAnnotatedParameter<X> extends MDRAnnotated implements AnnotatedParameter<X>
+{
+ private final AnnotatedCallable<X> callable;
+
+ /**
+ * Constructor
+ *
+ * @param delegate the delegate
+ * @param callable the method or constructor owning this parameter
+ * @param metaData the MDR metadata for the method or constructor
+ */
+ public MDRAnnotatedParameter(Annotated delegate, AnnotatedCallable<X> callable, MetaData metaData)
+ {
+ super(delegate, metaData);
+ this.callable = callable;
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ @Override
+ AnnotatedParameter<X> getDelegate()
+ {
+ return (AnnotatedParameter<X>)super.getDelegate();
+ }
+
+ /**
+ * Gets the method or constructor containing this parameter
+ *
+ * @return the method or constructor
+ */
+ public AnnotatedCallable<X> getDeclaringCallable()
+ {
+ return callable;
+ }
+
+ /**
+ * Get the index of this parameter
+ *
+ * @return the index
+ */
+ public int getPosition()
+ {
+ return getDelegate().getPosition();
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedType.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedType.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedType.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,175 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.ConstructorSignature;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+
+/**
+ * Decorator that understands MDR metadata for a type
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class MDRAnnotatedType<X> extends MDRAnnotated implements AnnotatedType<X>
+{
+ /** The decorated constructors */
+ private final Set<AnnotatedConstructor<X>> annotatedConstructors;
+
+ /** The decorated fields */
+ private final Set<AnnotatedField<? super X>> annotatedFields;
+
+ /** The decorated methods */
+ private final Set<AnnotatedMethod<? super X>> annotatedMethods;
+
+ /**
+ * Constructor
+ *
+ * @param delegate the delegate
+ * @param metaData the MDR metadata
+ */
+ MDRAnnotatedType(AnnotatedType<X> delegate, MetaData metaData)
+ {
+ super(delegate, metaData);
+ annotatedConstructors = initialiseConstructors();
+ annotatedFields = initialiseAnnotatedFields();
+ annotatedMethods = initialiseMethods();
+ }
+
+ /**
+ * Decorates the fields if MDR metadata is present
+ *
+ * @return the fields
+ */
+ private Set<AnnotatedField<? super X>> initialiseAnnotatedFields()
+ {
+ if (getMetaData() == null)
+ return getDelegate().getFields();
+
+ Set<AnnotatedField<? super X>> fields = new HashSet<AnnotatedField<? super X>>();
+ for (AnnotatedField<? super X> field : getDelegate().getFields())
+ {
+ MetaData fieldMetaData = getMetaData().getComponentMetaData(new FieldSignature(field.getJavaMember()));
+ fields.add(new MDRAnnotatedField<X>(this, field, fieldMetaData));
+ }
+ return fields;
+ }
+
+ /**
+ * Decorates the constructors if MDR metadata is present
+ *
+ * @return the constructors
+ */
+ private Set<AnnotatedConstructor<X>> initialiseConstructors()
+ {
+ if (getMetaData() == null)
+ return getDelegate().getConstructors();
+
+ Set<AnnotatedConstructor<X>> constructors = new HashSet<AnnotatedConstructor<X>>();
+ for (AnnotatedConstructor<X> constructor : getDelegate().getConstructors())
+ {
+ MetaData constructorMetaData = getMetaData().getComponentMetaData(new ConstructorSignature(constructor.getJavaMember()));
+ constructors.add(new MDRAnnotatedConstructor<X>(this, constructor, constructorMetaData, getMetaData()));
+ }
+ return constructors;
+ }
+
+ /**
+ * Decorates the methods if MDR metadata is present
+ *
+ * @return the methods
+ */
+ private Set<AnnotatedMethod<? super X>> initialiseMethods()
+ {
+ if (getMetaData() == null)
+ return getDelegate().getMethods();
+
+ Set<AnnotatedMethod<? super X>> methods = new HashSet<AnnotatedMethod<? super X>>();
+ for (AnnotatedMethod<? super X> method : getDelegate().getMethods())
+ {
+ MetaData MethodMetaData = getMetaData().getComponentMetaData(new MethodSignature(method.getJavaMember()));
+ methods.add(new MDRAnnotatedMethod<X>(this, method, MethodMetaData, getMetaData()));
+ }
+ return methods;
+ }
+
+ /**
+ * Gets the delegate
+ *
+ * @return the delegate
+ */
+ @Override
+ AnnotatedType<X> getDelegate()
+ {
+ return (AnnotatedType<X>)super.getDelegate();
+ }
+
+ /**
+ * Gets the constructors decorated with MDR metadata
+ *
+ * @return the constructors
+ */
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return annotatedConstructors;
+ }
+
+ /**
+ * Gets the fields decorated with MDR metadata
+ *
+ * @return the fields
+ */
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return annotatedFields;
+ }
+
+ /**
+ * Gets the methods decorated with MDR metadata
+ *
+ * @return the methods
+ */
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return annotatedMethods;
+ }
+
+ /**
+ * Gets the java class wrapped by this
+ *
+ * @return the java class
+ */
+ public Class<X> getJavaClass()
+ {
+ return getDelegate().getJavaClass();
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.annotated;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.kernel.weld.spi.annotated.MDRAnnotatedTypeFactory;
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * Decorates annotated types to understand MDR metadata
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MDRAnnotatedTypeFactoryImpl extends MDRAnnotatedTypeFactory
+{
+ public <T> AnnotatedType<T> getAnnotatedType(AnnotatedType<T> delegate, MetaData metaData)
+ {
+ return new MDRAnnotatedType<T>(delegate, metaData);
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldConfigureAction.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldConfigureAction.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldConfigureAction.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import org.jboss.kernel.plugins.dependency.ConfigureAction;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * ConfigureAction that handles both MC style configuration and Weld configuration
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldConfigureAction extends ConfigureAction
+{
+ @Override
+ protected void installActionInternal(KernelControllerContext context) throws Throwable
+ {
+ super.installActionInternal(context);
+
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WeldKernelControllerContext");
+
+ WeldInjector<?> injector = ((WeldKernelControllerContext)context).getWeldInjector();
+ if (injector != null)
+ injector.inject();
+ }
+
+ @Override
+ protected void uninstallActionInternal(KernelControllerContext context)
+ {
+ super.uninstallActionInternal(context);
+
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WeldKernelControllerContext");
+
+ WeldInjector<?> injector = ((WeldKernelControllerContext)context).getWeldInjector();
+ if (injector != null)
+ injector.unconfigure();
+ }
+}
\ No newline at end of file
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerContextActions.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerContextActions.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerContextActions.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.dependency.plugins.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.dependency.CreateDestroyLifecycleAction;
+import org.jboss.kernel.plugins.dependency.InstallAction;
+import org.jboss.kernel.plugins.dependency.KernelControllerContextActions;
+import org.jboss.kernel.plugins.dependency.PreInstallAction;
+import org.jboss.kernel.plugins.dependency.StartStopLifecycleAction;
+
+/**
+ * ControllerContextActions for contexts that need to interact with web beans
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldControllerContextActions extends KernelControllerContextActions
+{
+ private static final WeldControllerContextActions INSTANCE;
+ static
+ {
+ Map<ControllerState, ControllerContextAction> actions = new HashMap<ControllerState, ControllerContextAction>();
+
+ actions.put(ControllerState.PRE_INSTALL, new PreInstallAction());
+ actions.put(ControllerState.DESCRIBED, new WeldDescribeAction());
+ actions.put(ControllerState.INSTANTIATED, new WeldInstantiateAction());
+ actions.put(WeldPostConstructAction.STATE, new WeldPostConstructAction());
+ actions.put(ControllerState.CONFIGURED, new WeldConfigureAction());
+ actions.put(ControllerState.CREATE, new CreateDestroyLifecycleAction());
+ actions.put(WeldPreDestroyAction.STATE, new WeldPreDestroyAction());
+ actions.put(ControllerState.START, new StartStopLifecycleAction());
+ actions.put(WeldRegisterWebBeanAction.STATE, new WeldRegisterWebBeanAction());
+ actions.put(ControllerState.INSTALLED, new InstallAction());
+ INSTANCE = new WeldControllerContextActions(actions);
+ }
+
+ protected WeldControllerContextActions(Map<ControllerState, ControllerContextAction> actions)
+ {
+ // FIXME WeldControllerContextActions constructor
+ super(actions);
+ }
+
+ public static WeldControllerContextActions getInstance()
+ {
+ return INSTANCE;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerInitializer.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerInitializer.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldControllerInitializer.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * Helper to add the Web Beans controller context actions to the controller
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldControllerInitializer
+{
+ private static volatile boolean addedControllerStates;
+
+ static void initializeController(Controller controller)
+ {
+ if (!addedControllerStates)
+ {
+ addControllerStates(controller);
+ }
+ }
+
+ private static synchronized void addControllerStates(Controller controller)
+ {
+ if (!addedControllerStates)
+ {
+ controller.addState(WeldPostConstructAction.STATE, ControllerState.CONFIGURED);
+ controller.addState(WeldPreDestroyAction.STATE, ControllerState.START);
+ controller.addState(WeldRegisterWebBeanAction.STATE, ControllerState.INSTALLED);
+ addedControllerStates = true;
+ }
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldDescribeAction.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldDescribeAction.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldDescribeAction.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import org.jboss.kernel.plugins.dependency.DescribeAction;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * DescribeAction that looks for weld interaction
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldDescribeAction extends DescribeAction
+{
+
+ @Override
+ protected void applyAnnotations(KernelControllerContext context) throws Throwable
+ {
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+
+ super.applyAnnotations(context);
+
+ @SuppressWarnings("unchecked")
+ WeldInjector<?> webBeansInjector = new WeldInjector((WeldKernelControllerContext)context, context.getBeanInfo().getClassInfo().getType());
+ webBeansInjector.describe();
+ }
+
+ @Override
+ protected void cleanAnnotations(KernelControllerContext context)
+ {
+ super.cleanAnnotations(context);
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInjector.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInjector.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInjector.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,385 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.enterprise.context.NormalScope;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.stereotype.Stereotype;
+import javax.inject.Qualifier;
+import javax.inject.Scope;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.dependency.AbstractMetaDataVisitor;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
+import org.jboss.kernel.weld.plugins.metadata.WeldDependencyMetaData;
+import org.jboss.kernel.weld.spi.annotated.MDRAnnotatedTypeFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldInjector<T>
+{
+ final static Logger log = Logger.getLogger(WeldInjector.class);
+
+ //TODO should cache the annotated types and injection targets, taking into account metadata at instance level and below
+
+ /**
+ * The web beans kernel controller context 'owning' this injector
+ */
+ WeldKernelControllerContext context;
+
+ /**
+ * The annotated type of the bean class
+ */
+ AnnotatedType<T> type;
+
+ /**
+ * injection target of this bean used to inject WB->MC
+ */
+ private final InjectionTarget<T> it;
+
+ /**
+ * The creational context for WB->MC injection
+ */
+ private CreationalContext<T> creationalContext;
+
+ /**
+ * True if web beans should constuct this object
+ */
+ private boolean createInWeld;
+
+ /**
+ * Constrcutor
+ *
+ * @param context The controller context 'owning' this injector
+ * @param clazz the class of this bean
+ * @throws IllegalArgumentException if any of the parameters are null
+ */
+ WeldInjector(WeldKernelControllerContext context, Class<T> clazz)
+ {
+ if (context == null)
+ throw new IllegalArgumentException("Null context");
+ if (clazz == null)
+ throw new IllegalArgumentException("Null clazz");
+
+ this.context = context;
+ creationalContext = context.getManager().createCreationalContext(null);
+
+ type = createMdrDecoratedAnnotatedType(clazz);
+ it = getInjectionTarget(clazz);
+ }
+
+ /**
+ * Gets the injection target
+ */
+ private InjectionTarget<T> getInjectionTarget(Class<T> clazz)
+ {
+ return context.getManager().createInjectionTarget(type);
+ }
+
+ /**
+ * Check if the bean has web beans annotations
+ * @return true if bean has web beans annotations
+ */
+ boolean hasWebBeanAnnotations()
+ {
+ if (hasWebBeanAnnotations(type, AnnotationChecker.BINDING))
+ return true;
+
+ for (AnnotatedMethod<?> method : type.getMethods())
+ {
+ if (hasWebBeanAnnotations(method, AnnotationChecker.PRODUCER))
+ return true;
+ }
+
+ for (AnnotatedField<?> method : type.getFields())
+ {
+ if (hasWebBeanAnnotations(method, AnnotationChecker.PRODUCER))
+ return true;
+ }
+
+ return false;
+ }
+
+ boolean hasWebBeanAnnotations(Annotated annotated, AnnotationChecker checker)
+ {
+ Set<Annotation> annotations = annotated.getAnnotations();
+ for (Annotation annotation : annotations)
+ {
+ if (checker.matches(annotation))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check if the bean should be constructed by web beans
+ *
+ * @return true if the bean should be constructed by web beans
+ */
+ boolean createInWeld()
+ {
+ return createInWeld;
+ }
+
+ /**
+ * Method to be called during DESCRIBE state. Sets the annotated type in the context if
+ * this bean should be registered in web beans. If the bean should have web beans injection
+ * performed on it, this injector is set in the context, and WeldDependencyMetaData is
+ * created for each web beans injection point.
+ */
+ void describe()
+ {
+ if (hasWebBeanAnnotations())
+ {
+ context.setAnnotatedType(type);
+ }
+
+ AnnotationMetaDataVisitor annotationsVisitor = new AnnotationMetaDataVisitor(context);
+ annotationsVisitor.before();
+ try
+ {
+ if (it.getInjectionPoints().size() > 0)
+ {
+ context.setWeldInjector(this);
+ BeanMetaData metaData = context.getBeanMetaData();
+ for (InjectionPoint injectionPoint : it.getInjectionPoints())
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(metaData);
+
+ DependencyMetaData dependency = new WeldDependencyMetaData(injectionPoint);
+ if (!containsDependency(dependency))
+ {
+ builder.addDependency(dependency);
+
+ dependency.describeVisit(annotationsVisitor);
+ dependency.initialVisit(annotationsVisitor);
+ }
+
+ if (injectionPoint.getMember() instanceof Constructor)
+ {
+ createInWeld = true;
+ }
+ }
+ }
+ }
+ finally
+ {
+ annotationsVisitor.after();
+ }
+ }
+
+ /**
+ * Instantiates the bean using web beans
+ *
+ * @return the created instance
+ * @throws IllegalStateException if this bean should not be created using web beans
+ */
+ T instantiate()
+ {
+ if (!createInWeld)
+ throw new IllegalStateException(context.getName() + " should not be created using web beans");
+
+ T t = it.produce(creationalContext);
+ return t;
+ }
+
+ /**
+ * Performs injection from web beans into the bean
+ */
+ void inject()
+ {
+ it.inject((T)context.getTarget(), creationalContext);
+ }
+
+ /**
+ * Unseta all fields that were set by web beans
+ */
+ void unconfigure()
+ {
+ Object tgt = context.getTarget();
+ for (InjectionPoint ip : it.getInjectionPoints())
+ {
+ //TODO Any point in creating ClassInfo here?
+ if (ip.getMember() instanceof Method)
+ {
+ Method m = (Method)ip.getMember();
+ Object[] params = new Object[m.getParameterTypes().length];
+ try
+ {
+ m.invoke(tgt, params);
+ }
+ catch(Exception e)
+ {
+ log.warn("Error unsetting values for method " + m.getName() + " in bean " + context.getName(), e);
+ }
+ }
+ else if (ip.getMember() instanceof Field)
+ {
+ Field f = (Field)ip.getMember();
+ try
+ {
+ f.set(tgt, null);
+ }
+ catch (Exception e)
+ {
+ log.warn("Error unsetting values for field " + f.getName() + " in bean " + context.getName(), e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Invokes the @PostConstruct method if any
+ *
+ * @param instance the instance
+ * @throws IllegalArgumentException if the instance is null
+ */
+ void postConstruct(Object instance) {
+ if (instance == null)
+ throw new IllegalArgumentException("Null instance");
+
+ it.postConstruct((T)instance);
+ }
+
+ /**
+ * Invokes the @PreDestroy method if any
+ *
+ * @param instance the instance
+ * @throws IllegalArgumentException if the instance is null
+ */
+ void preDestroy(Object instance) {
+ if (instance == null)
+ throw new IllegalArgumentException("Null instance");
+
+ it.preDestroy((T)instance);
+ creationalContext.release();
+ }
+
+ /**
+ * Checks if the context contains the passed in dependency
+ *
+ * @param dependency the dependency to check
+ * @return true if the context contains the dependency
+ */
+ private boolean containsDependency(DependencyMetaData dependency)
+ {
+ return context.getBeanMetaData().getDepends() != null && context.getBeanMetaData().getDepends().contains(dependency);
+ }
+
+ /**
+ * Decorates an annotated type with the contexts MDR metadata
+ *
+ * @param clazz
+ * @return the decorated annotated type
+ */
+ private AnnotatedType<T> createMdrDecoratedAnnotatedType(Class<T> clazz)
+ {
+ AnnotatedType<T> type = context.getManager().createAnnotatedType(clazz);
+
+ KernelController controller = (KernelController)context.getController();
+ Kernel kernel = controller.getKernel();
+ KernelMetaDataRepository repository = kernel.getMetaDataRepository();
+ MetaData metaData = repository.getMetaData(context);
+
+ return MDRAnnotatedTypeFactory.getInstance().getAnnotatedType(type, metaData);
+ }
+
+ class AnnotationMetaDataVisitor extends AbstractMetaDataVisitor
+ {
+ public AnnotationMetaDataVisitor(KernelControllerContext context)
+ {
+ super(context.getBeanMetaData(), context);
+ }
+
+ // push bean meta data as first node
+ public void before()
+ {
+ visitorNodeStack.push(bmd);
+ }
+
+ // remove bean meta data
+ public void after()
+ {
+ visitorNodeStack.pop();
+ visitorNodeStack = null;
+ }
+ }
+
+ private interface AnnotationChecker
+ {
+ boolean matches(Annotation annotation);
+
+ AnnotationChecker BINDING = new BindingAnnotationChecker();
+
+ AnnotationChecker PRODUCER = new ProducerAnnotationChecker();
+ }
+
+ private static class BindingAnnotationChecker implements AnnotationChecker
+ {
+ public boolean matches(Annotation annotation)
+ {
+ for (Annotation meta : annotation.annotationType().getAnnotations())
+ {
+ Class<? extends Annotation> metaType = meta.annotationType();
+ if (/*metaType == Policy.class ||*/ metaType == Qualifier.class || metaType == Stereotype.class || metaType == Scope.class || metaType == NormalScope.class)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ private static class ProducerAnnotationChecker implements AnnotationChecker
+ {
+
+ public boolean matches(Annotation annotation)
+ {
+ if (annotation.annotationType() == Produces.class)
+ return true;
+ return false;
+ }
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInstantiateAction.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInstantiateAction.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldInstantiateAction.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.dependency.InstantiateAction;
+import org.jboss.kernel.spi.dependency.InstantiateKernelControllerContextAware;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
+
+/**
+ * InstantiateAction that determines if a bean should be instantiated by web beans, and if so delegates
+ * to instantiation to web beans. Otherwise, it instantiates it normally using normal MC instantiation.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldInstantiateAction extends InstantiateAction
+{
+ @Override
+ protected void installActionInternal(KernelControllerContext context) throws Throwable
+ {
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+
+ WeldInjector<?> injector = ((WeldKernelControllerContext)context).getWeldInjector();
+ if (injector != null && injector.createInWeld())
+ context.setTarget(injector.instantiate());
+ else
+ super.installActionInternal(context);
+ }
+
+ @Override
+ protected void uninstallActionInternal(KernelControllerContext context)
+ {
+ context.setTarget(null);
+ }
+
+ protected ControllerState getState()
+ {
+ return ControllerState.INSTANTIATED;
+ }
+
+ protected Class<? extends KernelControllerContextAware> getActionAwareInterface()
+ {
+ return InstantiateKernelControllerContextAware.class;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldKernelControllerContext.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldKernelControllerContext.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldKernelControllerContext.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext;
+
+/**
+ * ControllerContext for beans that need to interact with web beans.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldKernelControllerContext extends AbstractKernelControllerContext
+{
+ WeldInjector<?> webBeansInjector;
+ BeanManager manager;
+ AnnotatedType<?> type;
+
+
+ /**
+ * Create an abstract controller context
+ *
+ * @param info the bean info
+ * @param metaData the meta data
+ * @param target any target object
+ * @param manager the bean manager to use
+ */
+ public WeldKernelControllerContext(BeanInfo info, BeanMetaData metaData, Object target, BeanManager manager)
+ {
+ super(info, metaData, WeldControllerContextActions.getInstance(), target);
+ if (manager == null)
+ throw new IllegalArgumentException("Null manager");
+ this.manager = manager;
+ }
+
+ @Override
+ public void setController(Controller controller)
+ {
+ WeldControllerInitializer.initializeController(controller);
+ super.setController(controller);
+ }
+
+ /**
+ * Gets the beanmanager
+ *
+ * @return the bean manager
+ */
+ public BeanManager getManager()
+ {
+ return manager;
+ }
+
+ /**
+ * Sets the web beans injector
+ *
+ * @param webBeansInjector the web beans injector
+ */
+ void setWeldInjector(WeldInjector<?> webBeansInjector)
+ {
+ this.webBeansInjector = webBeansInjector;
+ }
+
+ /**
+ * Gets the web beans injector
+ *
+ * @return the web beans injector
+ */
+ WeldInjector<?> getWeldInjector()
+ {
+ return webBeansInjector;
+ }
+
+ /**
+ * Gets the annotated type. This is only set if the bean is a candidate for lookup from web beans
+ *
+ * @return the type, or null if not a candidate for lookup from web beans
+ */
+ public AnnotatedType<?> getAnnotatedType()
+ {
+ return type;
+ }
+
+ /**
+ * Sets the annotated type. This should only be set if the bean is a candidate for lookup from web beans
+ *
+ * @param type the type
+ */
+ public void setAnnotatedType(AnnotatedType<?> type)
+ {
+ this.type = type;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPostConstructAction.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPostConstructAction.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPostConstructAction.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.dependency.InstallsAwareAction;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * ControllerContextAction to call the @PostConstruct methods
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldPostConstructAction extends InstallsAwareAction
+{
+ final static ControllerState STATE = new ControllerState("POST_CONSTRUCT");
+
+ @Override
+ protected ControllerState getState()
+ {
+ return STATE;
+ }
+
+ @Override
+ public void installActionInternal(KernelControllerContext context)
+ {
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WeldKernelControllerContext");
+
+ WeldInjector<?> injector = ((WeldKernelControllerContext)context).getWeldInjector();
+ if (injector != null)
+ injector.postConstruct(context.getTarget());
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPreDestroyAction.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPreDestroyAction.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldPreDestroyAction.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.dependency.InstallsAwareAction;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * ControllerContextAction to call the @PreDestroy methods
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldPreDestroyAction extends InstallsAwareAction
+{
+ final static ControllerState STATE = new ControllerState("PRE_DESTROY");
+
+ @Override
+ protected ControllerState getState()
+ {
+ return STATE;
+ }
+
+ @Override
+ public void uninstallActionInternal(KernelControllerContext context)
+ {
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WeldKernelControllerContext");
+
+ WeldInjector<?> injector = ((WeldKernelControllerContext)context).getWeldInjector();
+ if (injector != null)
+ injector.preDestroy(context.getTarget());
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldRegisterWebBeanAction.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldRegisterWebBeanAction.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/dependency/WeldRegisterWebBeanAction.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.dependency;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.dependency.KernelControllerContextAction;
+import org.jboss.kernel.spi.dependency.InstantiateKernelControllerContextAware;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
+import org.jboss.kernel.weld.plugins.weld.WeldFromMcRegistry;
+
+/**
+ * ControllerContextAction to register an MC bean as a candidate for lookup from web beans.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldRegisterWebBeanAction extends KernelControllerContextAction
+{
+ final static ControllerState STATE = new ControllerState("REGISTER_WEB_BEAN");
+
+ @Override
+ protected void installActionInternal(KernelControllerContext context) throws Throwable
+ {
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+
+ WeldFromMcRegistry.registerBean((WeldKernelControllerContext)context);
+ }
+
+ @Override
+ protected void uninstallActionInternal(KernelControllerContext context)
+ {
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+
+ WeldFromMcRegistry.unregisterBean((WeldKernelControllerContext)context);
+ }
+
+ protected Class<? extends KernelControllerContextAware> getActionAwareInterface()
+ {
+ return InstantiateKernelControllerContextAware.class;
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/metadata/WeldDependencyMetaData.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/metadata/WeldDependencyMetaData.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/metadata/WeldDependencyMetaData.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,141 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.weld.plugins.dependency.WeldKernelControllerContext;
+
+/**
+ * DependencyMetaData representing a dependency on a web bean
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldDependencyMetaData extends AbstractDependencyMetaData
+{
+ private static final long serialVersionUID = 1L;
+
+ /** The web beans injection point */
+ private final InjectionPoint injectionPoint;
+
+ /** The web beans kernel controller context of the bean containing the dependency */
+ private WeldKernelControllerContext context;
+
+ /** When the dependency is required. If the injection point is a constructor, this will be ControllerState.INSTATIATED,
+ * otherwise it will be ControllerState.CONFIGURED
+ */
+ private final ControllerState whenRequired;
+
+
+ /**
+ * Constructor
+ *
+ * @param injectionPoint the injection point
+ */
+ public WeldDependencyMetaData(InjectionPoint injectionPoint)
+ {
+ super(injectionPoint);
+ this.injectionPoint = injectionPoint;
+
+ if (injectionPoint.getMember() instanceof Constructor)
+ whenRequired = ControllerState.INSTANTIATED;
+ else
+ whenRequired = ControllerState.CONFIGURED;
+
+ }
+
+ public void initialVisit(MetaDataVisitor visitor)
+ {
+ ControllerContext context = visitor.getControllerContext();
+ if (context instanceof WeldKernelControllerContext == false)
+ throw new IllegalStateException("Context is not a WeldKernelControllerContext " + context.getName());
+ this.context = (WeldKernelControllerContext)context;
+
+ visitor.addDependency(new WeldDependencyItem(context.getName()));
+ }
+
+ @Override
+ protected int getHashCode()
+ {
+ int i = 17;
+ i = 31 * i + injectionPoint.getMember().hashCode();
+ for (Annotation ann : injectionPoint.getQualifiers())
+ {
+ i = 31 * i + ann.hashCode();
+ }
+ return i;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof WeldDependencyMetaData == false)
+ return false;
+ return equals(injectionPoint.getMember(), ((WeldDependencyMetaData)obj).injectionPoint.getMember()) &&
+ equals(injectionPoint.getQualifiers(), ((WeldDependencyMetaData)obj).injectionPoint.getQualifiers());
+ }
+
+ /**
+ * DependencyItem representing a web beans injection point
+ */
+ private class WeldDependencyItem extends AbstractDependencyItem
+ {
+ public WeldDependencyItem(Object name)
+ {
+ super(name, null, whenRequired, null);
+ }
+
+ public boolean resolve(Controller controller)
+ {
+ try
+ {
+ context.getManager().validate(injectionPoint);
+ setIDependOn(injectionPoint);
+ setResolved(true);
+ }
+ catch(InjectionException e)
+ {
+ setResolved(false);
+ }
+
+ return isResolved();
+ }
+
+ @Override
+ public void unresolved()
+ {
+ setIDependOn(null);
+ setResolved(false);
+ }
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McAfterBeanDiscoveryObserver.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McAfterBeanDiscoveryObserver.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/McAfterBeanDiscoveryObserver.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.weld;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+/**
+ * Web Beans extension bean to register MC beans that should be accessible from web beans
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McAfterBeanDiscoveryObserver implements Extension
+{
+ public void observe(@Observes BeforeBeanDiscovery event)
+ {
+ for (AnnotatedType<?> type : WeldFromMcRegistry.getTypes())
+ {
+ event.addAnnotatedType(type);
+ }
+ }
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/WeldFromMcRegistry.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/WeldFromMcRegistry.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/WeldFromMcRegistry.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,80 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.plugins.weld;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.kernel.weld.plugins.dependency.WeldKernelControllerContext;
+
+/**
+ * Registry of MC beans that should be accessible from web beans
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldFromMcRegistry
+{
+ //TODO need some way to register by controller and to determine which controller a beanmanager should look in
+
+ /**
+ * Map of context name and bean implentation of MC beans that should be accessible from web beans
+ */
+ private static final Map<Object, AnnotatedType<?>> typesByContext = new ConcurrentHashMap<Object, AnnotatedType<?>>();
+
+ /**
+ * Check if a context should be accessible from web beans, and if so register it as a web bean.
+ *
+ * @param context the context to register in web beans
+ */
+ public static void registerBean(WeldKernelControllerContext context)
+ {
+ AnnotatedType<?> type = context.getAnnotatedType();
+ if (type != null)
+ {
+ typesByContext.put(context, type);
+ }
+ }
+
+ /**
+ * Unregister an mc context as a web bean
+ *
+ * @param context the context to register in web beans
+ */
+ public static void unregisterBean(WeldKernelControllerContext context)
+ {
+ typesByContext.remove(context);
+ }
+
+ /**
+ * Get a copy of all the MC beans that should be registered as web beans
+ */
+ public static Collection<AnnotatedType<?>> getTypes()
+ {
+ return Collections.unmodifiableCollection(typesByContext.values());
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/spi/annotated/MDRAnnotatedTypeFactory.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/spi/annotated/MDRAnnotatedTypeFactory.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/spi/annotated/MDRAnnotatedTypeFactory.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.weld.spi.annotated;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.kernel.weld.plugins.annotated.MDRAnnotatedTypeFactoryImpl;
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * Singleton used to decorate annotated types to understand MDR metadata
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MDRAnnotatedTypeFactory
+{
+ private final static MDRAnnotatedTypeFactory INSTANCE = new MDRAnnotatedTypeFactoryImpl();
+
+ /**
+ * Get the singleton instance
+ *
+ * @return the singleton
+ */
+ public static MDRAnnotatedTypeFactory getInstance()
+ {
+ return INSTANCE;
+ }
+
+ /**
+ * Decorate an annotated type to understand MDR metadata
+ *
+ * @param delegate the type to decorate
+ * @param metaData the MDR metadata for the bean
+ * @return the type decorated with MDR metadata
+ */
+ public abstract <T> AnnotatedType<T> getAnnotatedType(AnnotatedType<T> delegate, MetaData metaData);
+}
Added: projects/kernel/trunk/weld-int/src/main/resources/findbugs/exclude.xml
===================================================================
--- projects/kernel/trunk/weld-int/src/main/resources/findbugs/exclude.xml (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/resources/findbugs/exclude.xml 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,30 @@
+<FindBugsFilter>
+ <!-- hashcode comes from JBossObject/gethashCode() -->
+ <Match>
+ <Class name="org.jboss.kernel.weld.plugins.metadata.WeldDependencyMetaData"/>
+ <Method name="equals" params="java.lang.Object" returns="boolean"/>
+ <Bug pattern="HE_EQUALS_NO_HASHCODE"/>
+ </Match>
+
+ <!-- Asymmetric dependency? -->
+ <Match>
+ <Class name="org.jboss.kernel.weld.plugins.metadata.WeldDependencyMetaData"/>
+ <Method name="equals" params="java.lang.Object" returns="boolean"/>
+ <Bug pattern="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC"/>
+ </Match>
+
+ <!-- Exclude these non serializable field errors until it is clear if the metadata classes actually need to be serialized,
+ in which case there should be some tests testing that -->
+ <Match>
+ <Class name="org.jboss.kernel.weld.plugins.metadata.WeldDependencyMetaData"/>
+ <Field name="context"/>
+ <Bug pattern="SE_BAD_FIELD"/>
+ </Match>
+
+ <Match>
+ <Class name="org.jboss.kernel.weld.plugins.metadata.WeldDependencyMetaData"/>
+ <Field name="injectionPoint"/>
+ <Bug pattern="SE_BAD_FIELD"/>
+ </Match>
+
+</FindBugsFilter>
\ No newline at end of file
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AbstractWeldMcTest.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AbstractWeldMcTest.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AbstractWeldMcTest.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,170 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld;
+
+import java.util.Collection;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.kernel.weld.plugins.dependency.WeldKernelControllerContext;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractWeldMcTest extends MicrocontainerTest
+{
+ /**
+ * Whether or not, and when, to deploy mc beans on test setup
+ */
+ protected static AutoDeployMcBeans autodeployMcBeans = AutoDeployMcBeans.NONE;
+
+ /**
+ * Classes that should be deployed as web beans on startup
+ */
+ protected static Class<?>[] autodeployWbClasses;
+
+
+ public AbstractWeldMcTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get the test delegate
+ *
+ * @param clazz the test class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ return new WeldMcTestDelegate(clazz, autodeployMcBeans, autodeployWbClasses);
+ }
+
+ /**
+ * Get the delegate
+ *
+ * @return the delegate
+ */
+ protected WeldMcTestDelegate getDelegate()
+ {
+ return (WeldMcTestDelegate)super.getDelegate();
+ }
+
+ /**
+ * Gets the bean manager
+ *
+ * @return the bean manager
+ * @throws Exception if the manager could not be determined
+ */
+ protected BeanManager getCurrentManager() throws Exception
+ {
+ return getDelegate().getCurrentManager();
+ }
+
+ /**
+ * Deploys the web beans classes
+ *
+ * @param webBeansClasses The classes that should be deployed as web beans
+ * @throws Exception if an error happened during deployment
+ */
+ protected void deployWeld(Class<?>...webBeansClasses) throws Exception
+ {
+ getDelegate().deployWeld(webBeansClasses);
+ }
+
+ /**
+ * Deploys the web beans classes
+ *
+ * @param extension package in which to search for a file named {@link WeldMcTestDelegate#EXTENSION_FILE} for extensions.
+ * @param webBeansClasses The classes that should be deployed as web beans
+ * @throws Exception if an error happened during deployment
+ */
+ protected void deployWeld(Package extension, Class<?>...webBeansClasses) throws Exception
+ {
+ getDelegate().deployWeld(extension, webBeansClasses);
+ }
+
+ /**
+ * Undeploys the web beans classes if some were deployed
+ *
+ * @throws Exception if an error happened during deployment
+ */
+ protected void undeployWeld() throws Exception
+ {
+ getDelegate().undeployWeld();
+ }
+
+ /**
+ * Create a WeldKernelControllerContext and deploy it into the microcontainer
+ *
+ * @param beanMetaData the bean metadata to deploy
+ * @return the WeldKernelControllerContext
+ * @throws Exception if an error happened during deployment
+ */
+ protected WeldKernelControllerContext deploy(BeanMetaData beanMetaData) throws Exception
+ {
+ return getDelegate().deploy(beanMetaData);
+ }
+
+ /**
+ * Check that a collection has the expected size
+ *
+ * @param expected the expected size
+ * @param the collection to check
+ * @throws AssertionFailedError if the collection does not have the expected size
+ */
+ protected void assertSize(int expected, Collection<?> collection)
+ {
+ if (collection == null)
+ {
+ if (expected == 0)
+ return;
+ else
+ fail("Expected size: " + expected + " for null collection");
+ }
+
+ if (collection.size() != expected)
+ fail("Expected size: " + expected + " was " + collection.size());
+ }
+
+ /**
+ * Creates a bean metadata
+ *
+ * @param name the name of the bean
+ * @param clazz the class of the bean
+ */
+ protected BeanMetaData createBeanMetaData(String name, Class<?> clazz)
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name, clazz.getName());
+ builder.setAccessMode(BeanAccessMode.ALL);
+ return builder.getBeanMetaData();
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AutoDeployMcBeans.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AutoDeployMcBeans.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/AutoDeployMcBeans.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld;
+
+/**
+ * Enum to determine if the test framework should deploy the MC beans automatically on setup,
+ * and if it should happen before or after the web beans are deployed
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public enum AutoDeployMcBeans
+{
+ /** Do not autodeploy MC beans */
+ NONE,
+
+ /** Autodeploy MC beans before Web beans */
+ BEFORE,
+
+ /** Autodeploy MC beans after Web beans */
+ AFTER
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldMcTestDelegate.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldMcTestDelegate.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldMcTestDelegate.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,335 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.weld.plugins.dependency.WeldKernelControllerContext;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.weld.mock.MockEELifecycle;
+import org.jboss.weld.mock.TestContainer;
+
+/**
+ * Delegate for the weld-int test framework
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldMcTestDelegate extends MicrocontainerTestDelegate
+{
+ /**
+ * The name of the file used to define extensions to be deployed
+ */
+ public static final String EXTENSION_FILE = "javax.enterprise.inject.spi.Extension";
+
+ /**
+ * If and when beans should be deployed to MC
+ */
+ protected AutoDeployMcBeans autoDeployMcBeans;
+
+ /**
+ * Classes that should be automatically deployed as web beans
+ */
+ protected Class<?>[] autodeployWbClasses;
+
+ /**
+ * Here in case somebody needs to call {@link #getCurrentManager()} before any web beans are deployed. This will be
+ * a different bean manager from the bean manager to which web beans are deployed, but is good enough to call
+ * {@link BeanManager#createAnnotatedType(Class)}, {@link BeanManager#createCreationalContext(javax.enterprise.context.spi.Contextual)},
+ * {@link BeanManager#createInjectionTarget(javax.enterprise.inject.spi.AnnotatedType)} etc. on
+ */
+ TestContainer bootstrapContainer;
+
+ /**
+ * Contains the web beans deployment (either done automatically if autodeployWbClasses is set, or by calling deployWeld() manually)
+ */
+ TestContainer testContainer;
+
+ /**
+ * File containing the extensions for the deployment
+ */
+ File extensionFile;
+
+ /**
+ * Constructor
+ *
+ * @param clazz the test class
+ * @param autoDeployMcBeans if and when mc beans should be deployed automatically
+ * @param autodeployWbClasses classes that should be automatically deployed as web beans
+ */
+ protected WeldMcTestDelegate(Class<?> clazz, AutoDeployMcBeans autoDeployMcBeans, Class<?>...autodeployWbClasses) throws Exception
+ {
+ super(clazz);
+ this.autoDeployMcBeans = autoDeployMcBeans;
+ this.autodeployWbClasses = autodeployWbClasses;
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ AbstractBootstrap bootstrap = getBootstrap();
+ bootstrap.run();
+ kernel = bootstrap.getKernel();
+
+ // Create the deployer
+ deployer = createDeployer();
+
+ if (autoDeployMcBeans == AutoDeployMcBeans.BEFORE)
+ deploy();
+
+ if (autodeployWbClasses != null && autodeployWbClasses.length > 0)
+ deployWeld(autodeployWbClasses);
+
+ if (autoDeployMcBeans == AutoDeployMcBeans.AFTER)
+ deploy();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ if (autoDeployMcBeans == AutoDeployMcBeans.AFTER)
+ undeploy();
+
+ undeployWeld();
+
+ if (autoDeployMcBeans == AutoDeployMcBeans.BEFORE)
+ undeploy();
+
+ super.tearDown();
+ }
+
+ /**
+ * Deploys classes as web beans and sets {@link #lifecycle} to point to the created lifecycle
+ *
+ * @param classes the classes to be deployed as web beans
+ * @throws Exception if an error occured
+ */
+ protected void deployWeld(Class<?>...classes) throws Exception
+ {
+ deployWeld(null, classes);
+ }
+
+ /**
+ * Deploys classes as web beans and sets {@link #lifecycle} to point to the created lifecycle
+ *
+ * @param extension the package containing the {@link #EXTENSION_FILE} if you want to deploy extensions
+ * @param classes the classes to be deployed as web beans
+ * @throws Exception if an error occured
+ */
+ protected void deployWeld(Package extension, Class<?>...classes) throws Exception
+ {
+ deployWeld(false, extension, classes);
+ }
+
+ /**
+ * Deploys classes as web beans
+ *
+ * @param isForBootstrap if false, sets {@link #lifecycle} to point to the created lifecycle
+ * @param extension the package containing the {@link #EXTENSION_FILE} if you want to deploy extensions
+ * @param classes the classes to be deployed as web beans
+ * @throws Exception if an error occured
+ */
+ protected TestContainer deployWeld(boolean isForBootstrap, Package extension, Class<?>...classes) throws Exception
+ {
+ copyExtensions(extension);
+
+ TestContainer testContainer = new TestContainer(new MockEELifecycle(), Arrays.asList(classes), null);
+ testContainer.startContainer();
+ testContainer.ensureRequestActive();
+
+
+ if (!isForBootstrap)
+ {
+ this.testContainer = testContainer;
+ }
+ return testContainer;
+ }
+
+ /**
+ * Undeploys the weld deployed if {@link #lifecycle} is set
+ */
+ protected void undeployWeld() throws Exception
+ {
+ if (testContainer != null)
+ {
+ testContainer.startContainer();
+ }
+ if (extensionFile != null)
+ {
+ extensionFile.delete();
+ }
+ }
+
+ /**
+ * Copies the extension definition file to the META-INF/services directory
+ * where web beans will look for it
+ *
+ * @param extension the package containing the extension file. If null no copy will be attempted
+ */
+ protected void copyExtensions(Package extension)
+ {
+ if (extension == null)
+ return;
+
+ URL url = findExtension(extension);
+ if (url != null)
+ {
+ getLog().debug("Deploying extensions " + url);
+ File metaInfServicesDirectory = findMetaInfServicesDirectory();
+ extensionFile = new File(metaInfServicesDirectory, EXTENSION_FILE);
+ if (extensionFile.exists())
+ {
+ extensionFile.delete();
+ }
+ InputStream in = null;
+ OutputStream out = null;
+ try
+ {
+ in = url.openStream();
+ out = new FileOutputStream(extensionFile);
+ int i = in.read();
+ while (i != -1)
+ {
+ out.write(i);
+ i = in.read();
+ }
+ }
+ catch(IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ close(out);
+ close(in);
+ }
+ }
+ }
+
+ private void close(Closeable closable)
+ {
+ if (closable == null)
+ return;
+ try
+ {
+ closable.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ /**
+ * Searches the package for an extension file
+ *
+ * @param extension the package to search for the extension
+ * @return the url of the found extension file, or null if no extension file could be found
+ */
+ private URL findExtension(Package extension)
+ {
+ String extensionFileName = extension.getName().replace('.', '/') + "/" + EXTENSION_FILE;
+ return Thread.currentThread().getContextClassLoader().getResource(extensionFileName);
+ }
+
+ /**
+ * Finds the META-INF/services directory to where the extension file should be copied
+ *
+ * @return the META-INF/services directory
+ */
+ private File findMetaInfServicesDirectory()
+ {
+ try
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource("META-INF/services/placeholder.txt");
+ if (url == null)
+ throw new IllegalStateException("Should have been able to find META-INF/services/ directory under resources");
+ File file = new File(url.toURI());
+ return file.getParentFile();
+ }
+ catch (URISyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Create a WeldKernelControllerContext and deploy it into the microcontainer
+ *
+ * @param beanMetaData the bean metadata to deploy
+ * @return the WeldKernelControllerContext
+ * @throws Exception if an error happened during deployment
+ */
+ protected WeldKernelControllerContext deploy(BeanMetaData beanMetaData) throws Exception
+ {
+ KernelController controller = kernel.getController();
+ log.debug("Deploying " + beanMetaData);
+ try
+ {
+ WeldKernelControllerContext context = new WeldKernelControllerContext(null, beanMetaData, null, getCurrentManager());
+ controller.install(context);
+ log.debug("Deployed " + context.getName());
+ return context;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error deploying bean: " + beanMetaData, t);
+ }
+ }
+
+ /**
+ * Gets the current bean manager used. This will either be the bean manager for the
+ * deployed web beans as set in {@link #testContainer}, or a 'bootstrap' bean manager as
+ * described in {@link #bootstrapContainer}
+ */
+ protected BeanManager getCurrentManager() throws Exception
+ {
+ if (testContainer != null)
+ return testContainer.getBeanManager();
+ else if (bootstrapContainer == null)
+ bootstrapContainer = deployWeld(true, null);
+
+ return bootstrapContainer.getBeanManager();
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldTestSuite.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldTestSuite.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/WeldTestSuite.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.kernel.weld.annotated.AnnotatedTypeTestCase;
+import org.jboss.test.kernel.weld.beanwrapper.test.BeanImplementationTestCase;
+import org.jboss.test.kernel.weld.mctowb.test.InjectMcBeansInWeldTestCase;
+import org.jboss.test.kernel.weld.wbtomc.test.InjectWeldInMcBeansTestCase;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldTestSuite extends TestSuite
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("MC/Web Beans Tests");
+
+ suite.addTest(AnnotatedTypeTestCase.suite());
+ suite.addTest(BeanImplementationTestCase.suite());
+ suite.addTest(InjectWeldInMcBeansTestCase.suite());
+ suite.addTest(InjectMcBeansInWeldTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Test1("XXX")
+ at Test3
+public class AnnotatedBean
+{
+ @Test1("XXX")
+ @Test3
+ int field;
+
+ @Test1("XXX")
+ @Test3
+ public AnnotatedBean()
+ {
+
+ }
+
+ @Test1("XXX")
+ @Test3
+ public AnnotatedBean(@Test1("XXX") @Test3 int i, @Test1("XXX") @Test3 int j)
+ {
+
+ }
+
+ @Test1("XXX")
+ @Test3
+ void method()
+ {
+
+ }
+
+ @Test1("XXX")
+ @Test3
+ void method(@Test1("XXX") @Test3 int i)
+ {
+
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedTypeTestCase.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedTypeTestCase.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/AnnotatedTypeTestCase.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,516 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.annotation.factory.AnnotationCreator;
+import org.jboss.kernel.weld.spi.annotated.MDRAnnotatedTypeFactory;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
+import org.jboss.metadata.spi.signature.ConstructorParametersSignature;
+import org.jboss.metadata.spi.signature.ConstructorSignature;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.test.kernel.weld.AbstractWeldMcTest;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotatedTypeTestCase extends AbstractWeldMcTest
+{
+ public AnnotatedTypeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(AnnotatedTypeTestCase.class);
+ }
+
+ public void testNoAnnotationsOnClassNullMetaData() throws Exception
+ {
+ AnnotatedType<NotAnnotatedBean> type = createAnnotatedType(NotAnnotatedBean.class, null);
+ checkNotAnnotatedNoAnnotations(type);
+ }
+
+ public void testNoAnnotationsOnClassEmptyMetaData() throws Exception
+ {
+ AnnotatedType<NotAnnotatedBean> type = createAnnotatedType(NotAnnotatedBean.class, createEmptyMetaData());
+ checkNotAnnotatedNoAnnotations(type);
+ }
+
+ public void testNoAnnotationsOnClassWithMetaData() throws Exception
+ {
+ MetaData metaData = createMetaDataWithAnnotations(NotAnnotatedBean.class);
+ AnnotatedType<NotAnnotatedBean> type = createAnnotatedType(NotAnnotatedBean.class, metaData);
+
+ assertAnnotations(type, "A", Test1.class, Test2.class);
+
+ assertSize(2, type.getConstructors());
+ for (AnnotatedConstructor<NotAnnotatedBean> ctor : type.getConstructors())
+ {
+ if (ctor.getParameters().size() == 0)
+ {
+ assertAnnotations(ctor, "A", Test1.class, Test2.class);
+ }
+ else
+ {
+ assertSize(2, ctor.getParameters());
+ assertAnnotations(ctor, "A", Test1.class, Test2.class);
+ AnnotatedParameter<NotAnnotatedBean> param1 = ctor.getParameters().get(0);
+ assertAnnotations(param1, "A", Test1.class, Test2.class);
+ AnnotatedParameter<NotAnnotatedBean> param2 = ctor.getParameters().get(1);
+ assertAnnotations(param2, "A", Test1.class, Test2.class);
+ }
+ }
+
+ assertSize(1, type.getFields());
+ AnnotatedField<? super NotAnnotatedBean> field = type.getFields().iterator().next();
+ assertAnnotations(field, "A", Test1.class, Test2.class);
+
+ assertSize(2, type.getMethods());
+ for (AnnotatedMethod<? super NotAnnotatedBean> method : type.getMethods())
+ {
+ if (method.getParameters().size() == 0)
+ {
+ assertAnnotations(method, "A", Test1.class, Test2.class);
+ }
+ else
+ {
+ assertAnnotations(method, "A", Test1.class, Test2.class);
+ assertAnnotations(method.getParameters().iterator().next(), "A", Test1.class, Test2.class);
+ }
+ }
+ }
+
+ public void testAnnotationsOnClassNullMetaData() throws Exception
+ {
+ AnnotatedType<AnnotatedBean> type = createAnnotatedType(AnnotatedBean.class, null);
+ checkAnnotatedBeanNoMetaData(type);
+ }
+
+ public void testAnnotationsOnClassEmptyMetaData() throws Exception
+ {
+ AnnotatedType<AnnotatedBean> type = createAnnotatedType(AnnotatedBean.class, createEmptyMetaData());
+ checkAnnotatedBeanNoMetaData(type);
+ }
+
+ public void testAnnotationsOnClassWithMetaData() throws Exception
+ {
+ MetaData metaData = createMetaDataWithAnnotations(AnnotatedBean.class);
+ AnnotatedType<AnnotatedBean> type = createAnnotatedType(AnnotatedBean.class, metaData);
+
+ assertAnnotations(type, "A", Test1.class, Test2.class, Test3.class);
+
+ assertSize(2, type.getConstructors());
+ for (AnnotatedConstructor<AnnotatedBean> ctor : type.getConstructors())
+ {
+ if (ctor.getParameters().size() == 0)
+ {
+ assertAnnotations(ctor, "A", Test1.class, Test2.class, Test3.class);
+
+ //Check the declaring type
+ AnnotatedType<AnnotatedBean> decl = ctor.getDeclaringType();
+ assertEquals(AnnotatedBean.class, decl.getJavaClass());
+ assertAnnotations(decl, "A", Test1.class, Test2.class, Test3.class);
+
+ for (AnnotatedConstructor<AnnotatedBean> innerCtor : decl.getConstructors())
+ {
+ assertAnnotations(innerCtor, "A", Test1.class, Test2.class, Test3.class);
+ }
+ }
+ else
+ {
+ assertSize(2, ctor.getParameters());
+ assertAnnotations(ctor, "A", Test1.class, Test2.class, Test3.class);
+ AnnotatedParameter<AnnotatedBean> param1 = ctor.getParameters().get(0);
+ assertAnnotations(param1, "A", Test1.class, Test2.class, Test3.class);
+ AnnotatedParameter<AnnotatedBean> param2 = ctor.getParameters().get(1);
+ assertAnnotations(param2, "A", Test1.class, Test2.class, Test3.class);
+ }
+ }
+
+ assertSize(1, type.getFields());
+ AnnotatedField<? super AnnotatedBean> field = type.getFields().iterator().next();
+ assertAnnotations(field, "A", Test1.class, Test2.class, Test3.class);
+ //Check the declaring type
+ AnnotatedType<? super AnnotatedBean> declaring = field.getDeclaringType();
+ assertEquals(AnnotatedBean.class, declaring.getJavaClass());
+ assertAnnotations(declaring, "A", Test1.class, Test2.class, Test3.class);
+ assertAnnotations(declaring.getFields().iterator().next(), "A", Test1.class, Test2.class, Test3.class);
+
+ assertSize(2, type.getMethods());
+ for (AnnotatedMethod<? super AnnotatedBean> method : type.getMethods())
+ {
+ if (method.getParameters().size() == 0)
+ {
+ assertAnnotations(method, "A", Test1.class, Test2.class, Test3.class);
+
+ //Check the declaring type
+ AnnotatedType<? super AnnotatedBean> decl = method.getDeclaringType();
+ assertEquals(AnnotatedBean.class, decl.getJavaClass());
+ assertAnnotations(decl, "A", Test1.class, Test2.class, Test3.class);
+
+ for (AnnotatedMethod<? super AnnotatedBean> innerMethod : decl.getMethods())
+ {
+ assertAnnotations(innerMethod, "A", Test1.class, Test2.class, Test3.class);
+ }
+ }
+ else
+ {
+ assertAnnotations(method, "A", Test1.class, Test2.class, Test3.class);
+ assertAnnotations(method.getParameters().iterator().next(), "A", Test1.class, Test2.class, Test3.class);
+ }
+ }
+ }
+
+ public void testInheritance() throws Exception
+ {
+ AnnotatedType<Child> type = getCurrentManager().createAnnotatedType(Child.class);
+
+ assertSize(1, type.getConstructors());
+
+ assertSize(2, type.getFields());
+ for (AnnotatedField<? super Child> field : type.getFields())
+ {
+ if (field.getJavaMember().getName().equals("parent"))
+ {
+ assertEquals(Parent.class, field.getDeclaringType().getJavaClass());
+ }
+ else if (field.getJavaMember().getName().equals("child"))
+ {
+ assertEquals(Child.class, field.getDeclaringType().getJavaClass());
+ }
+ else
+ {
+ fail("Unknown field " + field.getJavaMember());
+ }
+ }
+
+ assertSize(2, type.getMethods());
+ for (AnnotatedMethod<? super Child> method : type.getMethods())
+ {
+ if (method.getJavaMember().getName().equals("parentMethod"))
+ {
+ assertEquals(Parent.class, method.getDeclaringType().getJavaClass());
+ }
+ else if (method.getJavaMember().getName().equals("childMethod"))
+ {
+ assertEquals(Child.class, method.getDeclaringType().getJavaClass());
+ }
+ else
+ {
+ fail("Unknown method " + method.getJavaMember());
+ }
+ }
+
+ type = createAnnotatedTypeForInheritance(type);
+ assertAnnotations(type, null, Test2.class);
+
+ assertSize(1, type.getConstructors());
+ assertAnnotations(type.getConstructors().iterator().next(), null, Test1.class);
+
+ assertSize(2, type.getFields());
+ for (AnnotatedField<? super Child> field : type.getFields())
+ {
+ if (field.getJavaMember().getName().equals("parent"))
+ {
+ assertEquals(Parent.class, field.getDeclaringType().getJavaClass());
+ assertAnnotations(field, null, Test2.class);
+ checkAnnotationsOnParentClass(field.getDeclaringType());
+
+ }
+ else if (field.getJavaMember().getName().equals("child"))
+ {
+ assertEquals(Child.class, field.getDeclaringType().getJavaClass());
+ assertAnnotations(field, null, Test1.class);
+ }
+ else
+ {
+ fail("Unknown field " + field.getJavaMember());
+ }
+ }
+
+ assertSize(2, type.getMethods());
+ for (AnnotatedMethod<? super Child> method : type.getMethods())
+ {
+ if (method.getJavaMember().getName().equals("parentMethod"))
+ {
+ assertEquals(Parent.class, method.getDeclaringType().getJavaClass());
+ assertAnnotations(method, null, Test2.class);
+ checkAnnotationsOnParentClass(method.getDeclaringType());
+ }
+ else if (method.getJavaMember().getName().equals("childMethod"))
+ {
+ assertEquals(Child.class, method.getDeclaringType().getJavaClass());
+ assertAnnotations(method, null, Test1.class);
+ }
+ else
+ {
+ fail("Unknown method " + method.getJavaMember());
+ }
+ }
+ }
+
+ private void checkAnnotationsOnParentClass(AnnotatedType<? super Child> type)
+ {
+ assertEquals(Parent.class, type.getJavaClass());
+ assertAnnotations(type, null, Test2.class);
+
+ assertSize(1, type.getConstructors());
+ assertAnnotations(type.getConstructors().iterator().next(), null, Test1.class);
+
+ assertSize(1, type.getFields());
+ assertAnnotations(type.getFields().iterator().next(), null, Test2.class);
+
+ assertSize(1, type.getMethods());
+ assertAnnotations(type.getMethods().iterator().next(), null, Test2.class);
+ }
+
+ private void checkNotAnnotatedNoAnnotations(AnnotatedType<?> type)
+ {
+ assertAnnotations(type);
+
+ assertSize(2, type.getConstructors());
+ for (AnnotatedConstructor<?> ctor : type.getConstructors())
+ {
+ assertAnnotations(ctor);
+
+ for (AnnotatedParameter<?> param : ctor.getParameters())
+ {
+ assertAnnotations(param);
+ }
+ }
+
+ assertSize(2, type.getMethods());
+ for (AnnotatedMethod<?> method : type.getMethods())
+ {
+ assertAnnotations(method);
+
+ for (AnnotatedParameter<?> param : method.getParameters())
+ {
+ assertAnnotations(param);
+ }
+ }
+
+ assertSize(1, type.getFields());
+ for (AnnotatedField<?> field : type.getFields())
+ {
+ assertAnnotations(field);
+ }
+ }
+
+ private void checkAnnotatedBeanNoMetaData(AnnotatedType<?> type)
+ {
+ assertAnnotations(type, "XXX", Test1.class, Test3.class);
+
+ assertSize(2, type.getConstructors());
+ for (AnnotatedConstructor<?> ctor : type.getConstructors())
+ {
+ assertAnnotations(ctor, "XXX", Test1.class, Test3.class);
+
+ for (AnnotatedParameter<?> param : ctor.getParameters())
+ {
+ assertAnnotations(param, "XXX", Test1.class, Test3.class);
+ }
+ }
+
+ assertSize(2, type.getMethods());
+ for (AnnotatedMethod<?> method : type.getMethods())
+ {
+ assertAnnotations(method, "XXX", Test1.class, Test3.class);
+
+ for (AnnotatedParameter<?> param : method.getParameters())
+ {
+ assertAnnotations(param, "XXX", Test1.class, Test3.class);
+ }
+ }
+
+ assertSize(1, type.getFields());
+ for (AnnotatedField<?> field : type.getFields())
+ {
+ assertAnnotations(field, "XXX", Test1.class, Test3.class);
+ }
+ }
+
+ private void assertAnnotations(Annotated annotated)
+ {
+ assertAnnotations(annotated, null);
+ }
+
+ private void assertAnnotations(Annotated annotated, String test1String, Class<? extends Annotation>...annotations)
+ {
+ Set<Annotation> actual = annotated.getAnnotations();
+ assertEquals(actual.size(), annotations.length);
+
+ for (Class<? extends Annotation> clazz : annotations)
+ {
+ Annotation found = null;
+ for (Annotation annotation : actual)
+ {
+ if (annotation.annotationType() == clazz)
+ {
+ found = annotation;
+ break;
+ }
+ }
+
+ if (found == null)
+ fail("Could not find annotation in set of annotations " + clazz.getName());
+
+ Annotation ann = annotated.getAnnotation(clazz);
+ assertNotNull(ann);
+ assertEquals(found, ann);
+ if (clazz == Test1.class && test1String != null)
+ assertEquals(test1String, ((Test1)ann).value());
+ }
+ }
+
+ private MetaData createEmptyMetaData()
+ {
+ return new MetaDataRetrievalToMetaDataBridge(new MemoryMetaDataLoader());
+ }
+
+ private <T> AnnotatedType<T> createAnnotatedType(Class<T> clazz, MetaData metadata) throws Exception
+ {
+ AnnotatedType<T> type = getCurrentManager().createAnnotatedType(clazz);
+ return MDRAnnotatedTypeFactory.getInstance().getAnnotatedType(type, metadata);
+ }
+
+ private MetaData createMetaDataWithAnnotations(Class<?> clazz) throws Exception
+ {
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader();
+ loader.addAnnotation(createTest1());
+ loader.addAnnotation(createTest2());
+
+ Constructor<?> ctorNoParams = clazz.getDeclaredConstructor();
+ MemoryMetaDataLoader component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new ConstructorSignature(ctorNoParams), component);
+
+ Constructor<?> ctorWithParam = clazz.getDeclaredConstructor(Integer.TYPE, Integer.TYPE);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new ConstructorSignature(ctorWithParam), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new ConstructorParametersSignature(ctorWithParam, 0), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new ConstructorParametersSignature(ctorWithParam, 1), component);
+
+
+ Field field = clazz.getDeclaredField("field");
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new FieldSignature(field), component);
+
+ Method methodNoParams = clazz.getDeclaredMethod("method");
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new MethodSignature(methodNoParams), component);
+
+ Method methodWithParams = clazz.getDeclaredMethod("method", Integer.TYPE);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new MethodSignature(methodWithParams), component);
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new MethodParametersSignature(methodWithParams, 0), component);
+
+
+ return new MetaDataRetrievalToMetaDataBridge(loader);
+ }
+
+ private AnnotatedType<Child> createAnnotatedTypeForInheritance(AnnotatedType<Child> type) throws Exception
+ {
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader();
+ loader.addAnnotation(createTest2());
+
+ Constructor<Child> ctor = Child.class.getConstructor();
+ MemoryMetaDataLoader component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ loader.addComponentMetaDataRetrieval(new ConstructorSignature(ctor), component);
+
+ Method childMethod = Child.class.getDeclaredMethod("childMethod");
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ loader.addComponentMetaDataRetrieval(new MethodSignature(childMethod), component);
+
+ Method parentMethod = Parent.class.getDeclaredMethod("parentMethod");
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new MethodSignature(parentMethod), component);
+
+ Field child = Child.class.getDeclaredField("child");
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest1());
+ loader.addComponentMetaDataRetrieval(new FieldSignature(child), component);
+
+ Field parent = Parent.class.getDeclaredField("parent");
+ component = new MemoryMetaDataLoader();
+ component.addAnnotation(createTest2());
+ loader.addComponentMetaDataRetrieval(new FieldSignature(parent), component);
+
+ return MDRAnnotatedTypeFactory.getInstance().getAnnotatedType(type, new MetaDataRetrievalToMetaDataBridge(loader));
+ }
+
+
+
+ private Test1 createTest1() throws Exception
+ {
+ return (Test1)AnnotationCreator.createAnnotation("@" + Test1.class.getName() + "(\"A\")", (ClassLoader)null);
+ }
+
+ private Test2 createTest2() throws Exception
+ {
+ return (Test2)AnnotationCreator.createAnnotation("@" + Test2.class.getName(), (ClassLoader)null);
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Child.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Child.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Child.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Child extends Parent
+{
+ int child;
+
+ void childMethod()
+ {
+
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/NotAnnotatedBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/NotAnnotatedBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/NotAnnotatedBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NotAnnotatedBean
+{
+ int field;
+
+ public NotAnnotatedBean()
+ {
+
+ }
+
+ public NotAnnotatedBean(int i, int j)
+ {
+
+ }
+
+ void method()
+ {
+
+ }
+
+ void method(int i)
+ {
+
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Parent.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Parent.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Parent.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Parent
+{
+ int parent;
+
+ void parentMethod()
+ {
+
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test1.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test1.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test1.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Test1 {
+ String value();
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test2.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test2.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test2.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Test2 {
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test3.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test3.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/annotated/Test3.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.annotated;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Test3 {
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/Thing.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/Thing.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/Thing.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.beanwrapper.support;
+
+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 java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Qualifier
+ at Target({METHOD, FIELD, PARAMETER, TYPE})
+public @interface Thing
+{
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.beanwrapper.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Thing
+public class ThingBean
+{
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingTarget.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingTarget.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/support/ThingTarget.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.beanwrapper.support;
+
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThingTarget
+{
+ @Inject @Thing ThingBean field;
+
+ Thing notInjected;
+
+ @Inject
+ public ThingTarget(@Thing ThingBean bean)
+ {
+
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/test/BeanImplementationTestCase.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/test/BeanImplementationTestCase.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/beanwrapper/test/BeanImplementationTestCase.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,227 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.beanwrapper.test;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.kernel.weld.AbstractWeldMcTest;
+import org.jboss.test.kernel.weld.beanwrapper.support.Thing;
+import org.jboss.test.kernel.weld.beanwrapper.support.ThingBean;
+import org.jboss.test.kernel.weld.beanwrapper.support.ThingTarget;
+import org.jboss.weld.beanutils.spi.Beans;
+import org.jboss.weld.beanutils.spi.ExistingBeanDescriber;
+
+/**
+ * Tests the Bean
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanImplementationTestCase extends AbstractWeldMcTest
+{
+ public BeanImplementationTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(BeanImplementationTestCase.class);
+ }
+
+ public void testSimple() throws Exception
+ {
+ ThingBean thingBean = new ThingBean();
+ Bean<ThingBean> thingImpl = assertBeanImpl(thingBean, "thing", false, Dependent.class, false, bindingSet(Thing.class, Any.class));
+ assertSize(0, thingImpl.getInjectionPoints());
+
+ ThingTarget thingTarget = new ThingTarget(thingBean);
+ Bean<ThingTarget> targetImpl = assertBeanImpl(thingTarget, "target", false, Dependent.class, false, bindingSet(Default.class, Any.class));
+ assertSize(2, targetImpl.getInjectionPoints());
+ Set<InjectionPoint> injectionPoints = targetImpl.getInjectionPoints();
+ for (InjectionPoint point : injectionPoints)
+ {
+ if (point.getMember() instanceof Field)
+ {
+ assertEquals("field", point.getMember().getName());
+ }
+ else if (point.getMember() instanceof Constructor)
+ {
+ assertEquals(1, ((Constructor<?>)point.getMember()).getParameterTypes().length);
+ }
+ }
+ }
+
+ public void testDecoratedType() throws Exception
+ {
+ ThingBean thingBean = new ThingBean();
+ Bean<ThingBean> thingImpl = assertBeanImpl(thingBean, "thing", false, Dependent.class, true, bindingSet(Thing.class, Any.class));
+ assertSize(0, thingImpl.getInjectionPoints());
+
+ ThingTarget thingTarget = new ThingTarget(thingBean);
+ Bean<ThingTarget> targetImpl = assertBeanImpl(thingTarget, "target", false, Dependent.class, true, bindingSet(Default.class, Any.class));
+ assertSize(2, targetImpl.getInjectionPoints());
+ Set<InjectionPoint> injectionPoints = targetImpl.getInjectionPoints();
+ for (InjectionPoint point : injectionPoints)
+ {
+ if (point.getMember() instanceof Field)
+ {
+ assertEquals("field", point.getMember().getName());
+ }
+ else if (point.getMember() instanceof Constructor)
+ {
+ assertEquals(1, ((Constructor<?>)point.getMember()).getParameterTypes().length);
+ }
+ }
+ }
+
+ private Set<Class<? extends Annotation>> bindingSet(Class<? extends Annotation>...bindings)
+ {
+ Set<Class<? extends Annotation>> set = new HashSet<Class<? extends Annotation>>();
+ for (Class<? extends Annotation> binding : bindings)
+ set.add(binding);
+ return set;
+ }
+
+ private <T> Bean<T> assertBeanImpl(T instance, String name, boolean alternative, Class<? extends Annotation> scopeType,
+ boolean decorateAnnotatedType, Set<Class<? extends Annotation>> bindings) throws Exception
+ {
+ AnnotatedType<T> type = getCurrentManager().createAnnotatedType((Class<T>)instance.getClass());
+
+ if (decorateAnnotatedType)
+ {
+ type = new MockAnnotatedType<T>(type);
+ }
+
+ Beans<T> beans = ExistingBeanDescriber.describePreinstantiatedBean(type, null, getCurrentManager(), instance);
+
+ assertNotNull(beans);
+
+ assertNotNull(beans.getMainBean());
+ assertNull(beans.getMainBean().getName());
+ assertEquals(alternative, beans.getMainBean().isAlternative());
+ assertBindings(beans.getMainBean().getQualifiers(), bindings);
+ assertEquals(scopeType, beans.getMainBean().getScope());
+ InjectionTarget<T> target = getCurrentManager().createInjectionTarget(getCurrentManager().createAnnotatedType((Class<T>)instance.getClass()));
+ assertEquals(target.getInjectionPoints(), beans.getMainBean().getInjectionPoints());
+
+ assertNotNull(beans.getNewBean());
+ assertNull(beans.getNewBean().getName());
+ assertEquals(alternative, beans.getNewBean().isAlternative());
+ assertBindings(beans.getNewBean().getQualifiers(), bindingSet(New.class));
+ assertEquals(scopeType, beans.getNewBean().getScope());
+ target = getCurrentManager().createInjectionTarget(getCurrentManager().createAnnotatedType((Class<T>)instance.getClass()));
+ assertEquals(target.getInjectionPoints(), beans.getNewBean().getInjectionPoints());
+
+ assertSize(0, beans.getMethodProducerBeans());
+ assertSize(0, beans.getFieldProducerBeans());
+
+ return beans.getMainBean();
+ }
+
+ private void assertBindings(Set<Annotation> actual, Set<Class<? extends Annotation>> expected)
+ {
+ if (expected == null)
+ assertSize(0, actual);
+ else
+ {
+ assertSize(expected.size(), actual);
+ for (Annotation ann : actual)
+ assertTrue(expected.contains(ann.annotationType()));
+ }
+ }
+
+ private class MockAnnotatedType<T> implements AnnotatedType<T>
+ {
+ AnnotatedType<T> delegate;
+
+ public MockAnnotatedType(AnnotatedType<T> delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return delegate.getAnnotation(annotationType);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return delegate.getAnnotations();
+ }
+
+ public Type getBaseType()
+ {
+ return delegate.getBaseType();
+ }
+
+ public Set<AnnotatedConstructor<T>> getConstructors()
+ {
+ return delegate.getConstructors();
+ }
+
+ public Set<AnnotatedField<? super T>> getFields()
+ {
+ return delegate.getFields();
+ }
+
+ public Class<T> getJavaClass()
+ {
+ return delegate.getJavaClass();
+ }
+
+ public Set<AnnotatedMethod<? super T>> getMethods()
+ {
+ return delegate.getMethods();
+ }
+
+ public Set<Type> getTypeClosure()
+ {
+ return delegate.getTypeClosure();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return delegate.isAnnotationPresent(annotationType);
+ }
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/Thing.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/Thing.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/Thing.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.mc;
+
+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 java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Qualifier
+ at Target({METHOD, FIELD, PARAMETER, TYPE})
+public @interface Thing
+{
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.mc;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Thing
+public class ThingBean
+{
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingFieldProducer.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingFieldProducer.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingFieldProducer.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.mc;
+
+import javax.enterprise.inject.Produces;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThingFieldProducer
+{
+ @Produces @Thing
+ ThingBean thing = new ThingBean();
+
+ public ThingBean getThing()
+ {
+ return thing;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingMethodProducer.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingMethodProducer.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/mc/ThingMethodProducer.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.mc;
+
+import javax.enterprise.inject.Produces;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThingMethodProducer
+{
+ ThingBean thing = new ThingBean();
+
+ @Produces @Thing
+ ThingBean createThing()
+ {
+ return thing;
+ }
+
+ public ThingBean getThing()
+ {
+ return thing;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/validateobserver/TestObserver.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.validateobserver;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+import org.jboss.kernel.weld.plugins.weld.McAfterBeanDiscoveryObserver;
+import org.jboss.testharness.impl.packaging.Artifact;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Artifact
+public class TestObserver extends McAfterBeanDiscoveryObserver implements Extension
+{
+ public static boolean invoked;
+
+ @Override
+ public void observe(@Observes BeforeBeanDiscovery event)
+ {
+ super.observe(event);
+ invoked = true;
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/TestMcAfterBeanDiscoveryObserver.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.wb;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+
+import org.jboss.kernel.weld.plugins.weld.McAfterBeanDiscoveryObserver;
+import org.jboss.testharness.impl.packaging.Artifact;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Artifact
+public class TestMcAfterBeanDiscoveryObserver extends McAfterBeanDiscoveryObserver
+{
+
+ @Override
+ public void observe(@Observes BeforeBeanDiscovery event)
+ {
+ super.observe(event);
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingConstructor.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingConstructor.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingConstructor.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.wb;
+
+import javax.inject.Inject;
+
+import org.jboss.test.kernel.weld.mctowb.support.mc.Thing;
+import org.jboss.test.kernel.weld.mctowb.support.mc.ThingBean;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThingConstructor
+{
+ public ThingBean thing;
+
+ @Inject
+ public ThingConstructor(@Thing ThingBean thing)
+ {
+ this.thing = thing;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingField.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingField.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/support/wb/ThingField.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.support.wb;
+
+import javax.inject.Inject;
+
+import org.jboss.test.kernel.weld.mctowb.support.mc.Thing;
+import org.jboss.test.kernel.weld.mctowb.support.mc.ThingBean;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThingField
+{
+ @Inject @Thing
+ public ThingBean thing;
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/mctowb/test/InjectMcBeansInWeldTestCase.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,154 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.mctowb.test;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.kernel.weld.plugins.dependency.WeldKernelControllerContext;
+import org.jboss.test.kernel.weld.AbstractWeldMcTest;
+import org.jboss.test.kernel.weld.mctowb.support.mc.ThingBean;
+import org.jboss.test.kernel.weld.mctowb.support.mc.ThingMethodProducer;
+import org.jboss.test.kernel.weld.mctowb.support.validateobserver.TestObserver;
+import org.jboss.test.kernel.weld.mctowb.support.wb.TestMcAfterBeanDiscoveryObserver;
+import org.jboss.test.kernel.weld.mctowb.support.wb.ThingConstructor;
+import org.jboss.test.kernel.weld.mctowb.support.wb.ThingField;
+import org.jboss.testharness.impl.packaging.Artifact;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Artifact
+public class InjectMcBeansInWeldTestCase extends AbstractWeldMcTest
+{
+ public InjectMcBeansInWeldTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(InjectMcBeansInWeldTestCase.class);
+ }
+
+ public void testMcAfterBeanDiscoveryInvokerCalled() throws Exception
+ {
+ TestObserver.invoked = false;
+ try
+ {
+ deployWeld(TestObserver.class.getPackage(), TestObserver.class);
+ assertTrue(TestObserver.invoked);
+ }
+ finally
+ {
+ undeployWeld();
+ }
+ }
+
+ public void testInjectMcBeanIntoField() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingBean.class));
+ try
+ {
+ ThingBean thing = assertBean("thing", ThingBean.class);
+ deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingField.class);
+ Set<Bean<?>> beans = getCurrentManager().getBeans(ThingField.class);
+ assertEquals(1, beans.size());
+ Bean<ThingField> bean = (Bean<ThingField>)beans.iterator().next();
+ CreationalContext<ThingField> createCtx = getCurrentManager().createCreationalContext(null);
+ ThingField thingField = bean.create(createCtx);
+ assertEquals(thing, thingField.thing);
+ }
+ finally
+ {
+ undeployWeld();
+ undeploy(context);
+ }
+ }
+
+
+ public void testInjectMcBeanIntoConstructor() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingBean.class));
+ try
+ {
+ ThingBean thing = assertBean("thing", ThingBean.class);
+ deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingConstructor.class);
+ Set<Bean<?>> beans = getCurrentManager().getBeans(ThingConstructor.class);
+ assertEquals(1, beans.size());
+ Bean<ThingConstructor> bean = (Bean<ThingConstructor>)beans.iterator().next();
+ CreationalContext<ThingConstructor> createCtx = getCurrentManager().createCreationalContext(null);
+ ThingConstructor thingField = bean.create(createCtx);
+ assertEquals(thing, thingField.thing);
+ }
+ finally
+ {
+ undeployWeld();
+ undeploy(context);
+ }
+ }
+
+ public void testInjectMcMethodProducedBeanIntoField() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("thing", ThingMethodProducer.class));
+ try
+ {
+ ThingMethodProducer thing = assertBean("thing", ThingMethodProducer.class);
+ deployWeld(TestMcAfterBeanDiscoveryObserver.class.getPackage(), TestMcAfterBeanDiscoveryObserver.class, ThingField.class);
+ Set<Bean<?>> beans = getCurrentManager().getBeans(ThingField.class);
+ assertEquals(1, beans.size());
+ Bean<ThingField> bean = (Bean<ThingField>)beans.iterator().next();
+ CreationalContext<ThingField> createCtx = getCurrentManager().createCreationalContext(null);
+
+
+ ThingField thingField = bean.create(createCtx);
+ assertEquals(thing.getThing(), thingField.thing);
+ }
+ finally
+ {
+ undeployWeld();
+ undeploy(context);
+ }
+ }
+
+ public void testInjectMcMethodProducedBeanIntoConstructor() throws Exception
+ {
+ fail("NYI");
+ }
+
+ public void testInjectMcFieldProducedBeanIntoField() throws Exception
+ {
+ fail("NYI");
+ }
+
+ public void testInjectMcFieldProducedBeanIntoConstructor() throws Exception
+ {
+ fail("NYI");
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/Bean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/Bean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/Bean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.support;
+
+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 java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Qualifier
+ at Target({METHOD, FIELD, PARAMETER, TYPE})
+public @interface Bean {
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/FailedBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/FailedBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/FailedBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.support;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.jboss.test.kernel.weld.wbtomc.test.WebBean;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class FailedBean
+{
+ @Inject @Default @Bean WebBean bean;
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesConstructorBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesConstructorBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesConstructorBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.support;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.jboss.test.kernel.weld.wbtomc.test.WebBean;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MissingDependenciesConstructorBean
+{
+ @Inject
+ public MissingDependenciesConstructorBean(@Default @Bean WebBean bean)
+ {
+
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesFieldBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesFieldBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/support/MissingDependenciesFieldBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.support;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.jboss.test.kernel.weld.wbtomc.test.WebBean;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MissingDependenciesFieldBean
+{
+ @Inject @Default @Bean WebBean bean;
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanConstructor.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanConstructor.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanConstructor.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExternalBeanConstructor
+{
+ WebBean bean;
+
+ WebBean nonAnnotated;
+
+ @Inject
+ public ExternalBeanConstructor(@Default WebBean bean)
+ {
+ this.bean = bean;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanField.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanField.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanField.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExternalBeanField
+{
+ @Inject @Default WebBean bean;
+
+ WebBean nonAnnotated;
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanMixed.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanMixed.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/ExternalBeanMixed.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExternalBeanMixed
+{
+ @Inject @Default WebBean fieldBean;
+
+ WebBean nonAnnotated;
+
+ WebBean constructorBean;
+
+ @Inject
+ public ExternalBeanMixed(@Default WebBean bean)
+ {
+ this.constructorBean = bean;
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/InjectWeldInMcBeansTestCase.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/InjectWeldInMcBeansTestCase.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/InjectWeldInMcBeansTestCase.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,401 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.inject.Inject;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.weld.plugins.dependency.WeldKernelControllerContext;
+import org.jboss.test.kernel.weld.AbstractWeldMcTest;
+import org.jboss.test.kernel.weld.wbtomc.support.FailedBean;
+import org.jboss.test.kernel.weld.wbtomc.support.MissingDependenciesConstructorBean;
+import org.jboss.test.kernel.weld.wbtomc.support.MissingDependenciesFieldBean;
+import org.jboss.testharness.impl.packaging.Artifact;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Artifact
+public class InjectWeldInMcBeansTestCase extends AbstractWeldMcTest
+{
+ static
+ {
+ autodeployWbClasses = new Class[] {WebBean.class};
+ }
+
+ public InjectWeldInMcBeansTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(InjectWeldInMcBeansTestCase.class);
+ }
+
+ public void testInjectFromWeldToExternalFieldObject() throws Exception
+ {
+ NonContextual<ExternalBeanField> nonContextual = new NonContextual<ExternalBeanField>(getCurrentManager(), ExternalBeanField.class);
+
+ ExternalBeanField bean = new ExternalBeanField();
+ assertNull(bean.bean);
+ nonContextual.postConstruct(bean);
+ assertNotNull(bean.bean);
+ assertNull(bean.nonAnnotated);
+ nonContextual.preDestroy(bean);
+ }
+
+ public void testInjectFromWeldToExternalFieldObjectCreatedByProducer() throws Exception
+ {
+ NonContextual<ExternalBeanField> nonContextual = new NonContextual<ExternalBeanField>(getCurrentManager(), ExternalBeanField.class);
+
+ ExternalBeanField bean = nonContextual.produce();
+ assertNull(bean.bean);
+ nonContextual.postConstruct(bean);
+ assertNotNull(bean.bean);
+ assertNull(bean.nonAnnotated);
+ nonContextual.preDestroy(bean);
+ }
+
+ public void testInjectFromWeldToExternalConstructorObject() throws Exception
+ {
+ NonContextual<ExternalBeanConstructor> nonContextual = new NonContextual<ExternalBeanConstructor>(getCurrentManager(), ExternalBeanConstructor.class);
+
+ ExternalBeanConstructor bean = nonContextual.produce();
+ assertNotNull(bean.bean);
+ assertNull(bean.nonAnnotated);
+ nonContextual.preDestroy(bean);
+ }
+
+ public void testInjectFromWeldToExternalMixedObject() throws Exception
+ {
+ NonContextual<ExternalBeanMixed> nonContextual = new NonContextual<ExternalBeanMixed>(getCurrentManager(), ExternalBeanMixed.class);
+
+ ExternalBeanMixed bean = nonContextual.produce();
+ assertNotNull(bean.constructorBean);
+ assertNull(bean.fieldBean);
+ assertNull(bean.nonAnnotated);
+
+ nonContextual.postConstruct(bean);
+ assertNotNull(bean.constructorBean);
+ assertNotNull(bean.fieldBean);
+ assertNull(bean.nonAnnotated);
+
+ nonContextual.preDestroy(bean);
+ }
+
+ public void testFailedInjectFromWeldToExternalObject() throws Exception
+ {
+ NonContextual<FailedBean> nonContextual = new NonContextual<FailedBean>(getCurrentManager(), FailedBean.class);
+
+ FailedBean bean = new FailedBean();
+ assertNull(bean.getBean());
+ try
+ {
+ nonContextual.postConstruct(bean);
+ fail("Should not be here");
+ }
+ catch(UnsatisfiedResolutionException expected)
+ {
+
+ }
+ }
+
+ public void testInjectFromWeldToMcInitializer() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", McBeanInitializerMethod.class));
+ McBeanInitializerMethod bean = null;
+ try
+ {
+ bean = assertBean("McBean", McBeanInitializerMethod.class);
+ assertNotNull(bean.getBean());
+ assertNull(bean.getNonInject());
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ assertNull(bean.getBean());
+ }
+
+ public void testInjectFromWeldToMcField() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", McBean.class));
+ McBean bean = null;
+ try
+ {
+ bean = assertBean("McBean", McBean.class);
+ assertNotNull(bean.getBean());
+ assertNotNull(bean.getBeanFromConstructor());
+ assertNull(bean.getNonInject());
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ assertNull(bean.getBean());
+ }
+
+// public void testInjectFromWeldToMcSetter() throws Exception
+// {
+// WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", McBeanWebBeanSetter.class));
+// McBeanWebBeanSetter bean = null;
+// try
+// {
+// bean = assertBean("McBean", McBeanWebBeanSetter.class);
+// assertNotNull(bean.getBean());
+// assertNull(bean.getNonInject());
+// }
+// finally
+// {
+// undeploy(context);
+// }
+// assertNull(bean.getBean());
+// }
+
+ public void testInjectFromWeldToMcMcConstructorNoParams() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", McBeanMcConstructor.class));
+ McBeanMcConstructor bean = null;
+ try
+ {
+ bean = assertBean("McBean", McBeanMcConstructor.class);
+ assertNotNull(bean.getBean());
+ assertNull(bean.getNonInject());
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ assertNull(bean.getBean());
+ }
+
+ public void testInjectFromWeldToMcMcConstructorWithParams() throws Exception
+ {
+ WeldKernelControllerContext contextSimple = deploy(createBeanMetaData("Simple", Simple.class));
+
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("McBean", McBeanMcConstructor.class.getName());
+ builder.addConstructorParameter(Simple.class.getName(), builder.createInject("Simple"));
+ WeldKernelControllerContext context = deploy(builder.getBeanMetaData());
+
+
+ try
+ {
+ Simple simple = assertBean("Simple", Simple.class);
+ McBeanMcConstructor bean = assertBean("McBean", McBeanMcConstructor.class);
+ assertNotNull(bean.getBean());
+ assertNull(bean.getNonInject());
+ assertNotNull(bean.getSimple());
+ assertEquals(simple, bean.getSimple());
+ }
+ finally
+ {
+ undeploy(context);
+ undeploy(contextSimple);
+ }
+ }
+
+ public void testConstructorMissingDependencies() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", MissingDependenciesConstructorBean.class));
+
+ try
+ {
+ assertNoControllerContext("McBean", ControllerState.INSTALLED);
+ ControllerContext ctx = getControllerContext("McBean", ControllerState.DESCRIBED);
+ assertSame(context, ctx);
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ }
+
+ public void testFieldMissingDependencies() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", MissingDependenciesFieldBean.class));
+
+ try
+ {
+ assertNoControllerContext("McBean", ControllerState.INSTALLED);
+ ControllerContext ctx = getControllerContext("McBean", ControllerState.INSTANTIATED);
+ assertSame(context, ctx);
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ }
+
+ public void testDependenciesNotDuplicated() throws Throwable
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", McBean.class));
+ try
+ {
+ assertNotNull(context.getBeanMetaData().getDepends());
+ int dependsSize = context.getBeanMetaData().getDepends().size();
+ assertTrue(dependsSize > 0);
+
+ assertNotNull(context.getDependencyInfo().getIDependOn(null));
+ int dependencySize = context.getDependencyInfo().getIDependOn(null).size();
+ assertTrue(dependencySize > 0);
+
+ change(context, ControllerState.PRE_INSTALL);
+ assertNotNull(context.getBeanMetaData().getDepends());
+ assertEquals(dependsSize, context.getBeanMetaData().getDepends().size());
+ assertNotNull(context.getDependencyInfo().getIDependOn(null));
+ assertEquals(dependencySize, context.getDependencyInfo().getIDependOn(null).size());
+
+ change(context, ControllerState.INSTALLED);
+ assertNotNull(context.getBeanMetaData().getDepends());
+ assertEquals(dependsSize, context.getBeanMetaData().getDepends().size());
+ assertNotNull(context.getDependencyInfo().getIDependOn(null));
+ assertEquals(dependencySize, context.getDependencyInfo().getIDependOn(null).size());
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ }
+
+ public void testPostConstructAndPreDestroy() throws Exception
+ {
+ WeldKernelControllerContext context = deploy(createBeanMetaData("McBean", McBeanWithPostConstructAndPreDestroy.class));
+ McBeanWithPostConstructAndPreDestroy bean = null;
+ try
+ {
+ bean = assertBean("McBean", McBeanWithPostConstructAndPreDestroy.class);
+ assertNotNull(bean.getBean());
+ assertTrue(bean.isPostConstructCalled());
+ assertFalse(bean.isPreDestroyCalled());
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ assertNull(bean.getBean());
+ assertTrue(bean.isPreDestroyCalled());
+ }
+
+ public void testAnnotationsFromMetaData() throws Exception
+ {
+ AbstractBeanMetaData metaData = new AbstractBeanMetaData("McBean", McBeanAnnotationsFromMetaData.class.getName());
+ metaData.setAccessMode(BeanAccessMode.ALL);
+
+ AbstractConstructorMetaData ctor = new AbstractConstructorMetaData();
+ AnnotationMetaData initializer = new AbstractAnnotationMetaData("@" + Inject.class.getName());
+ ctor.setAnnotations(Collections.singleton(initializer));
+ AbstractParameterMetaData param = new AbstractParameterMetaData(WebBean.class.getName(), (String)null);
+ AnnotationMetaData current = new AbstractAnnotationMetaData("@" + Default.class.getName());
+ param.setAnnotations(Collections.singleton(current));
+ ctor.setParameters(Collections.singletonList((ParameterMetaData)param));
+ metaData.setConstructor(ctor);
+
+ AbstractPropertyMetaData property = new AbstractPropertyMetaData("bean", (String)null);
+ Set<AnnotationMetaData> propertyAnns = new HashSet<AnnotationMetaData>();
+ propertyAnns.add(new AbstractAnnotationMetaData("@" + Default.class.getName()));
+ propertyAnns.add(new AbstractAnnotationMetaData("@" + Inject.class.getName()));
+
+ property.setAnnotations(propertyAnns);
+ metaData.addProperty(property);
+
+ WeldKernelControllerContext context = deploy(metaData);
+ McBeanAnnotationsFromMetaData bean = null;
+ try
+ {
+ bean = assertBean("McBean", McBeanAnnotationsFromMetaData.class);
+ assertNotNull(bean.getBean());
+ assertNotNull(bean.getBeanFromConstructor());
+ assertNull(bean.getNonInject());
+ }
+ finally
+ {
+ undeploy(context);
+ }
+ }
+
+ public class NonContextual<T> {
+
+ final InjectionTarget<T> it;
+ final BeanManager manager;
+ Class<T> clazz;
+
+ public NonContextual(BeanManager manager, Class<T> clazz) {
+ this.manager = manager;
+ AnnotatedType<T> type = manager.createAnnotatedType(clazz);
+ this.it = manager.createInjectionTarget(type);
+ this.clazz = clazz;
+ }
+
+ public Class<T> getClazz()
+ {
+ return clazz;
+ }
+
+ public InjectionTarget<T> getInjectionTarget()
+ {
+ return it;
+ }
+
+ public CreationalContext<T> postConstruct(T instance) {
+ CreationalContext<T> cc = manager.createCreationalContext(null);
+ it.inject(instance, cc);
+ it.postConstruct(instance);
+ return cc;
+ }
+
+ public T produce()
+ {
+ CreationalContext<T> cc = manager.createCreationalContext(null);
+ return it.produce(cc);
+ }
+
+ public void preDestroy(T instance) {
+ it.preDestroy(instance);
+ }
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBean
+{
+ WebBean beanFromConstructor;
+
+ @Inject @Default
+ WebBean bean;
+
+ WebBean nonInject;
+
+ @Inject
+ public McBean(@Default WebBean beanFromConstructor)
+ {
+ this.beanFromConstructor = beanFromConstructor;
+ }
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+
+ public WebBean getBeanFromConstructor()
+ {
+ return beanFromConstructor;
+ }
+
+ public WebBean getNonInject()
+ {
+ return nonInject;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanAnnotationsFromMetaData.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanAnnotationsFromMetaData.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanAnnotationsFromMetaData.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanAnnotationsFromMetaData
+{
+ WebBean beanFromConstructor;
+
+ /*@Current*/
+ WebBean bean;
+
+ WebBean nonInject;
+
+// /*@Initializer*/
+ public McBeanAnnotationsFromMetaData(/*@Current*/ WebBean beanFromConstructor)
+ {
+ this.beanFromConstructor = beanFromConstructor;
+ }
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+
+ public WebBean getBeanFromConstructor()
+ {
+ return beanFromConstructor;
+ }
+
+ public WebBean getNonInject()
+ {
+ return nonInject;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanInitializerMethod.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanInitializerMethod.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanInitializerMethod.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanInitializerMethod
+{
+ WebBean bean;
+
+ WebBean nonInject;
+
+ @Inject
+ public void initializerMethod(@Default WebBean bean)
+ {
+ this.bean = bean;
+ }
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+
+ public WebBean getNonInject()
+ {
+ return nonInject;
+ }
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanMcConstructor.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanMcConstructor.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanMcConstructor.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanMcConstructor
+{
+ @Inject @Default
+ WebBean bean;
+
+ Simple simple;
+
+ WebBean nonInject;
+
+ public McBeanMcConstructor()
+ {
+
+ }
+
+ public McBeanMcConstructor(Simple simple)
+ {
+ this.simple = simple;
+ }
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+
+ public WebBean getNonInject()
+ {
+ return nonInject;
+ }
+
+ public Simple getSimple()
+ {
+ return simple;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWebBeanSetter.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWebBeanSetter.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWebBeanSetter.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanWebBeanSetter
+{
+ WebBean bean;
+
+ WebBean nonInject;
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+
+ @Inject @Default
+ public void setBean(WebBean bean)
+ {
+ this.bean = bean;
+ }
+
+ public WebBean getNonInject()
+ {
+ return nonInject;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanWithPostConstructAndPreDestroy
+{
+ @Inject @Default
+ WebBean bean;
+
+ boolean postConstructCalled;
+
+ boolean preDestroyCalled;
+
+ @Inject
+ public McBeanWithPostConstructAndPreDestroy()
+ {
+ }
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+
+ public boolean isPostConstructCalled()
+ {
+ return postConstructCalled;
+ }
+
+ public boolean isPreDestroyCalled()
+ {
+ return preDestroyCalled;
+ }
+
+ @PostConstruct
+ public void postConstruct()
+ {
+ postConstructCalled = true;
+ }
+
+ @PreDestroy
+ public void preDestroy()
+ {
+ preDestroyCalled = true;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/Simple.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/Simple.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/Simple.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Simple
+{
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBean.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBean.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBean.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBean
+{
+
+}
Added: projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBeanConsumer.java
===================================================================
--- projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBeanConsumer.java (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/java/org/jboss/test/kernel/weld/wbtomc/test/WebBeanConsumer.java 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.weld.wbtomc.test;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBeanConsumer
+{
+ @Inject @Default
+ WebBean bean;
+
+ public WebBean getBean()
+ {
+ return bean;
+ }
+}
Added: projects/kernel/trunk/weld-int/src/test/resources/META-INF/services/placeholder.txt
===================================================================
--- projects/kernel/trunk/weld-int/src/test/resources/META-INF/services/placeholder.txt (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/resources/META-INF/services/placeholder.txt 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,2 @@
+DO NOT REMOVE!!!!
+Purpose is to be able to identify the META-INF/services directory
\ No newline at end of file
Added: projects/kernel/trunk/weld-int/src/test/resources/log4j.properties
===================================================================
--- projects/kernel/trunk/weld-int/src/test/resources/log4j.properties (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/resources/log4j.properties 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1,6 @@
+log4j.rootCategory=DEBUG, console
+log4j.category.org.jboss.xb.builder=TRACE, console
+
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+log4j.appender.console=org.apache.log4j.ConsoleAppender
\ No newline at end of file
Added: projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/validateobserver/javax.enterprise.inject.spi.Extension
===================================================================
--- projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/validateobserver/javax.enterprise.inject.spi.Extension (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/validateobserver/javax.enterprise.inject.spi.Extension 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1 @@
+org.jboss.test.kernel.weld.mctowb.support.validateobserver.TestObserver
\ No newline at end of file
Added: projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/wb/javax.enterprise.inject.spi.Extension
===================================================================
--- projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/wb/javax.enterprise.inject.spi.Extension (rev 0)
+++ projects/kernel/trunk/weld-int/src/test/resources/org/jboss/test/kernel/weld/mctowb/support/wb/javax.enterprise.inject.spi.Extension 2009-10-13 16:18:38 UTC (rev 94777)
@@ -0,0 +1 @@
+org.jboss.test.kernel.weld.mctowb.support.wb.TestMcAfterBeanDiscoveryObserver
\ No newline at end of file
Added: projects/kernel/trunk/weld-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
===================================================================
More information about the jboss-cvs-commits
mailing list