[jboss-cvs] JBossAS SVN: r92878 - in projects/kernel/trunk: aop-mc-int and 58 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 27 12:42:16 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-08-27 12:42:14 -0400 (Thu, 27 Aug 2009)
New Revision: 92878

Added:
   projects/kernel/trunk/webbeans-int/
   projects/kernel/trunk/webbeans-int/.classpath
   projects/kernel/trunk/webbeans-int/.project
   projects/kernel/trunk/webbeans-int/.settings/
   projects/kernel/trunk/webbeans-int/.settings/org.eclipse.jdt.core.prefs
   projects/kernel/trunk/webbeans-int/pom.xml
   projects/kernel/trunk/webbeans-int/src/
   projects/kernel/trunk/webbeans-int/src/main/
   projects/kernel/trunk/webbeans-int/src/main/java/
   projects/kernel/trunk/webbeans-int/src/main/java/org/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotated.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedCallable.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedConstructor.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedField.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMember.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMethod.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedParameter.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedType.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansConfigureAction.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerContextActions.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerInitializer.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansDescribeAction.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInjector.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInstantiateAction.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansKernelControllerContext.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPostConstructAction.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPreDestroyAction.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansRegisterWebBeanAction.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/metadata/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/metadata/WebBeansDependencyMetaData.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/BeanImpl.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/McAfterBeanDiscoveryObserver.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/WebBeansFromMcRegistry.java
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/spi/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/spi/annotated/
   projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/spi/annotated/MDRAnnotatedTypeFactory.java
   projects/kernel/trunk/webbeans-int/src/main/resources/
   projects/kernel/trunk/webbeans-int/src/test/
   projects/kernel/trunk/webbeans-int/src/test/java/
   projects/kernel/trunk/webbeans-int/src/test/java/org/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AbstractWebBeansMcTest.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AutoDeployMcBeans.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansMcTestDelegate.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansTestSuite.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedTypeTestCase.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Child.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/NotAnnotatedBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Parent.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test1.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test2.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test3.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/Thing.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingTarget.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/test/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/test/BeanImplementationTestCase.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/TestObserver.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/TestMcAfterBeanDiscoveryObserver.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingConstructor.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingField.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/Thing.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/ThingBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/test/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/test/InjectMcBeansInWebBeansTestCase.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/Bean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/FailedBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesConstructorBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesFieldBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanConstructor.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanField.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanMixed.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/InjectWebBeansInMcBeansTestCase.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanAnnotationsFromMetaData.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanInitializerMethod.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanMcConstructor.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWebBeanSetter.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/Simple.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBean.java
   projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBeanConsumer.java
   projects/kernel/trunk/webbeans-int/src/test/resources/
   projects/kernel/trunk/webbeans-int/src/test/resources/META-INF/
   projects/kernel/trunk/webbeans-int/src/test/resources/META-INF/services/
   projects/kernel/trunk/webbeans-int/src/test/resources/META-INF/services/placeholder.txt
   projects/kernel/trunk/webbeans-int/src/test/resources/log4j.properties
   projects/kernel/trunk/webbeans-int/src/test/resources/org/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/javax.enterprise.inject.spi.Extension
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/javax.enterprise.inject.spi.Extension
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/testharness/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/testharness/impl/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/testharness/impl/packaging/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/
   projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
Modified:
   projects/kernel/trunk/aop-mc-int/.classpath
   projects/kernel/trunk/jmx-aop-mc-int/.classpath
   projects/kernel/trunk/kernel/.classpath
   projects/kernel/trunk/kernel/pom.xml
   projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
   projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
   projects/kernel/trunk/kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
   projects/kernel/trunk/pom.xml
Log:
[JBKERNEL-51] Initial commit of web beans integration prototype

Modified: projects/kernel/trunk/aop-mc-int/.classpath
===================================================================
--- projects/kernel/trunk/aop-mc-int/.classpath	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/aop-mc-int/.classpath	2009-08-27 16:42:14 UTC (rev 92878)
@@ -10,7 +10,7 @@
   <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.0.2/byteman-1.0.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.10.0.GA/javassist-3.10.0.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR3/jboss-aop-2.1.0.CR3.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR3/jboss-aop-2.1.0.CR3-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA-sources.jar"/>

Modified: projects/kernel/trunk/jmx-aop-mc-int/.classpath
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/.classpath	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/jmx-aop-mc-int/.classpath	2009-08-27 16:42:14 UTC (rev 92878)
@@ -12,7 +12,7 @@
   <classpathentry kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.0.2/byteman-1.0.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.10.0.GA/javassist-3.10.0.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR3/jboss-aop-2.1.0.CR3.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR3/jboss-aop-2.1.0.CR3-sources.jar"/>
   <classpathentry kind="src" path="/jboss-aop-mc-int"/>

Modified: projects/kernel/trunk/kernel/.classpath
===================================================================
--- projects/kernel/trunk/kernel/.classpath	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/kernel/.classpath	2009-08-27 16:42:14 UTC (rev 92878)
@@ -10,7 +10,7 @@
   <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.0.2/byteman-1.0.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.10.0.GA/javassist-3.10.0.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA-sources.jar"/>
   <classpathentry kind="src" path="/jboss-dependency"/>

Modified: projects/kernel/trunk/kernel/pom.xml
===================================================================
--- projects/kernel/trunk/kernel/pom.xml	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/kernel/pom.xml	2009-08-27 16:42:14 UTC (rev 92878)
@@ -27,7 +27,7 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <!-- skip>true</skip -->
+          <!--skip>true</skip-->
           <!--testFailureIgnore>true</testFailureIgnore-->
           <excludes>
             <exclude>org/jboss/test/kernel/asynchronous/**/*</exclude>

Modified: projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
===================================================================
--- projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -926,13 +926,19 @@
 
    public BeanMetaDataBuilder addDependency(Object dependency)
    {
+      addDependency(createDependencyMetaData(dependency));
+      return this;
+   }
+   
+   public BeanMetaDataBuilder addDependency(DependencyMetaData dependency)
+   {
       Set<DependencyMetaData> dependencies = beanMetaData.getDepends();
       if (dependencies == null)
       {
          dependencies = new HashSet<DependencyMetaData>();
          beanMetaData.setDepends(dependencies);
       }
-      dependencies.add(createDependencyMetaData(dependency));
+      dependencies.add(dependency);
       return this;
    }
 

Modified: projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
===================================================================
--- projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -38,6 +38,7 @@
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
 import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
 import org.jboss.beans.metadata.spi.ConstructorMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
 import org.jboss.beans.metadata.spi.LifecycleMetaData;
 import org.jboss.beans.metadata.spi.ParameterMetaData;
 import org.jboss.beans.metadata.spi.PropertyMetaData;
@@ -890,8 +891,17 @@
     * @return this builder
     */
    public abstract BeanMetaDataBuilder addDependency(Object dependency);
-
+   
    /**
+    * Add a dependency
+    *
+    * @see BeanMetaData#getDepends()
+    * @param dependency the dependency metadata metadata
+    * @return this builder
+    */
+   public abstract BeanMetaDataBuilder addDependency(DependencyMetaData dependency);
+   
+   /**
     * Add an install where the install method resides in the bean being built here
     * 
     * @see BeanMetaData#getInstalls()

Modified: projects/kernel/trunk/kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
===================================================================
--- projects/kernel/trunk/kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -126,7 +126,20 @@
     */
    public AbstractKernelControllerContext(BeanInfo info, BeanMetaData metaData, Object target)
    {
-      super(metaData.getName(), determineAliases(metaData), target == null ? actions : noInstantiate, new AbstractDependencyInfo(), target);
+      this(info, metaData, target == null ? actions : noInstantiate, target);
+   }
+   
+   /**
+    * Create an abstract controller context
+    *
+    * @param info     the bean info
+    * @param metaData the meta data
+    * @param actions the kernel controller context actions
+    * @param target   any target object
+    */
+   protected AbstractKernelControllerContext(BeanInfo info, BeanMetaData metaData, KernelControllerContextActions actions, Object target)
+   {
+      super(metaData.getName(), determineAliases(metaData), actions, new AbstractDependencyInfo(), target);
       this.info = info;
       this.metaData = metaData;
       ControllerMode mode = metaData.getMode();

Modified: projects/kernel/trunk/pom.xml
===================================================================
--- projects/kernel/trunk/pom.xml	2009-08-27 16:14:20 UTC (rev 92877)
+++ projects/kernel/trunk/pom.xml	2009-08-27 16:42:14 UTC (rev 92878)
@@ -29,6 +29,7 @@
     <module>jmx-aop-mc-int</module>
     <module>spring-int</module>
     <module>guice-int</module>
+    <module>webbeans-int</module>
     <module>build</module>
   </modules>
 
@@ -39,7 +40,7 @@
     <version.jbossxb>2.0.2-SNAPSHOT</version.jbossxb>
     <version.jboss.man>2.1.1.CR1</version.jboss.man>
     <version.jboss.vfs>2.1.2.GA</version.jboss.vfs>
-    <version.javassist>3.10.0.GA</version.javassist>
+    <version.javassist>3.11.0.GA</version.javassist>
     <version.jboss.aop>2.1.0.CR3</version.jboss.aop>
     <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
     <version.org.jboss.mdr>2.0.2.GA</version.org.jboss.mdr>
@@ -51,7 +52,11 @@
     <version.jboss.drools>4.0.1</version.jboss.drools>
     <version.jboss.jbpm>3.1.1</version.jboss.jbpm>
     <version.google.guice>2.0</version.google.guice>
-    <version.jboss.byteman>1.0.2</version.jboss.byteman>
+    <version.jboss.byteman>1.0.2</version.jboss.byteman>    
+    <version.org.jboss.webbeans.ri>1.0.0-SNAPSHOT</version.org.jboss.webbeans.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>
   </properties>
 
   <build>
@@ -257,6 +262,39 @@
         <artifactId>ant-junit</artifactId>
         <version>${version.ant.junit}</version>
       </dependency>
+      <dependency>
+        <groupId>org.jboss.webbeans</groupId>
+        <artifactId>jsr299-api</artifactId>
+        <version>${version.org.jboss.webbeans.ri}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.webbeans</groupId>
+        <artifactId>webbeans-core-test</artifactId>
+        <version>${version.org.jboss.webbeans.ri}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.webbeans</groupId>
+        <artifactId>webbeans-bean-utils</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+      </dependency>
+      <!-- Move this down to tests once finalized -->
+      <dependency>
+        <groupId>org.jboss.ejb3</groupId>
+        <artifactId>jboss-ejb3-api</artifactId>
+        <version>${version.org.jboss.ejb3.api}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>javax.validation</groupId>
+        <artifactId>validation-api</artifactId>
+        <version>${version.javax.validation}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>javax.faces</groupId>
+        <artifactId>jsf-api</artifactId>
+        <version>${version.javax.faces.jsf-api}</version>
+      </dependency>
       <!-- test dependencies -->
       <dependency>
         <groupId>org.jboss.test</groupId>
@@ -293,6 +331,23 @@
         <version>${version.jboss.byteman}</version>
         <scope>test</scope>
       </dependency>
+      <dependency>
+        <groupId>org.testng</groupId>
+          <artifactId>testng</artifactId>
+          <version>5.8</version>
+          <classifier>jdk15</classifier>
+          <exclusions>
+            <exclusion>
+              <groupId>junit</groupId>
+              <artifactId>junit</artifactId>
+            </exclusion>
+          </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.jboss.webbeans</groupId>
+        <artifactId>webbeans-core-test</artifactId>
+        <version>${version.org.jboss.webbeans.ri}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 


Property changes on: projects/kernel/trunk/webbeans-int
___________________________________________________________________
Name: svn:ignore
   + target


Added: projects/kernel/trunk/webbeans-int/.classpath
===================================================================
--- projects/kernel/trunk/webbeans-int/.classpath	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/.classpath	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,61 @@
+<classpath>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/el/el-api/2.1.2-b04/el-api-2.1.2-b04.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar" sourcepath="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/ws/jaxws-api/2.1/jaxws-api-2.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/faces/jsf-api/1.2_12/jsf-api-1.2_12.jar" sourcepath="M2_REPO/javax/faces/jsf-api/1.2_12/jsf-api-1.2_12-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar" sourcepath="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar" sourcepath="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/soap/saaj-api/1.3/saaj-api-1.3.jar" sourcepath="M2_REPO/javax/xml/soap/saaj-api/1.3/saaj-api-1.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar" sourcepath="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar" sourcepath="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/validation/validation-api/1.0.CR3/validation-api-1.0.CR3.jar" sourcepath="M2_REPO/javax/validation/validation-api/1.0.CR3/validation-api-1.0.CR3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/glassfish/web/el-impl/2.1.2-b04/el-impl-2.1.2-b04.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/google/collections/google-collections/1.0-rc2/google-collections-1.0-rc2.jar" sourcepath="M2_REPO/com/google/collections/google-collections/1.0-rc2/google-collections-1.0-rc2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.11.0.GA/javassist-3.11.0.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-dependency/2.2.0-SNAPSHOT/jboss-dependency-2.2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/kernel/jboss-dependency/2.2.0-SNAPSHOT/jboss-dependency-2.2.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-api/3.1.0-Alpha1/jboss-ejb3-api-3.1.0-Alpha1.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-api/3.1.0-Alpha1/jboss-ejb3-api-3.1.0-Alpha1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-kernel/2.2.0-SNAPSHOT/jboss-kernel-2.2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/kernel/jboss-kernel/2.2.0-SNAPSHOT/jboss-kernel-2.2.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-kernel/2.2.0-SNAPSHOT/jboss-kernel-2.2.0-SNAPSHOT-tests.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.CR1/jboss-managed-2.1.1.CR1.jar" sourcepath="M2_REPO/org/jboss/man/jboss-managed/2.1.1.CR1/jboss-managed-2.1.1.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.2.GA/jboss-mdr-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.2.GA/jboss-mdr-2.0.2.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.CR1/jboss-metatype-2.1.1.CR1.jar" sourcepath="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.CR1/jboss-metatype-2.1.1.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/test-harness/jboss-test-harness/1.0.0-SNAPSHOT/jboss-test-harness-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/test-harness/jboss-test-harness/1.0.0-SNAPSHOT/jboss-test-harness-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/test-harness/jboss-test-harness-api/1.0.0-SNAPSHOT/jboss-test-harness-api-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/test-harness/jboss-test-harness-api/1.0.0-SNAPSHOT/jboss-test-harness-api-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR2/jboss-transaction-api-1.0.1.CR2.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR2/jboss-transaction-api-1.0.1.CR2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.2-SNAPSHOT/jbossxb-2.0.2-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.2-SNAPSHOT/jbossxb-2.0.2-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/webbeans/jsr299-api/1.0.0-SNAPSHOT/jsr299-api-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/webbeans/jsr299-api/1.0.0-SNAPSHOT/jsr299-api-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar" sourcepath="M2_REPO/junit/junit/4.4/junit-4.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/webbeans/webbeans-api/1.0.0-SNAPSHOT/webbeans-api-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/webbeans/webbeans-api/1.0.0-SNAPSHOT/webbeans-api-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/webbeans/webbeans-bean-utils/1.0.0-SNAPSHOT/webbeans-bean-utils-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/webbeans/webbeans-bean-utils/1.0.0-SNAPSHOT/webbeans-bean-utils-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/webbeans/webbeans-core/1.0.0-SNAPSHOT/webbeans-core-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/webbeans/webbeans-core/1.0.0-SNAPSHOT/webbeans-core-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/webbeans/webbeans-core-test/1.0.0-SNAPSHOT/webbeans-core-test-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/webbeans/webbeans-core-test/1.0.0-SNAPSHOT/webbeans-core-test-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/webbeans/webbeans-logging/1.0.0-SNAPSHOT/webbeans-logging-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/webbeans/webbeans-logging/1.0.0-SNAPSHOT/webbeans-logging-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/webbeans/webbeans-spi/1.0.0-SNAPSHOT/webbeans-spi-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/webbeans/webbeans-spi/1.0.0-SNAPSHOT/webbeans-spi-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+</classpath>
\ No newline at end of file

Added: projects/kernel/trunk/webbeans-int/.project
===================================================================
--- projects/kernel/trunk/webbeans-int/.project	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/.project	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,13 @@
+<projectDescription>
+  <name>jboss-webbeans-int</name>
+  <comment>JBoss Microcontainer Web Beans Integration</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: projects/kernel/trunk/webbeans-int/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/kernel/trunk/webbeans-int/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/.settings/org.eclipse.jdt.core.prefs	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,5 @@
+#Mon Aug 03 15:19:13 BST 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5

Added: projects/kernel/trunk/webbeans-int/pom.xml
===================================================================
--- projects/kernel/trunk/webbeans-int/pom.xml	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/pom.xml	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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-webbeans-int</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss Microcontainer Web Beans Int</name>
+  <url>http://www.jboss.com/products/jbossmc</url>
+  <description>JBoss Microcontainer Web Beans 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.webbeans</groupId>
+      <artifactId>jsr299-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.webbeans</groupId>
+      <artifactId>webbeans-core-test</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.testng</groupId>
+          <artifactId>testng</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.webbeans</groupId>
+      <artifactId>webbeans-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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotated.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotated.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotated.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedCallable.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedCallable.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedCallable.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedConstructor.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedConstructor.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedConstructor.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedField.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedField.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedField.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMember.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMember.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMember.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMethod.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMethod.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedMethod.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedParameter.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedParameter.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedParameter.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedType.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedType.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedType.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/annotated/MDRAnnotatedTypeFactoryImpl.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.plugins.annotated;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.kernel.webbeans.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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansConfigureAction.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansConfigureAction.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansConfigureAction.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.plugins.dependency;
+
+import org.jboss.kernel.plugins.dependency.ConfigureAction;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * ConfigureAction that handles both MC style configuration and WebBeans configuration
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBeansConfigureAction extends ConfigureAction
+{
+   @Override
+   protected void installActionInternal(KernelControllerContext context) throws Throwable
+   {
+      super.installActionInternal(context);
+
+      if (context instanceof WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WebBeansKernelControllerContext");
+      
+      WebBeansInjector<?> injector = ((WebBeansKernelControllerContext)context).getWebBeansInjector();
+      if (injector != null)
+         injector.inject();
+   }
+
+   @Override
+   protected void uninstallActionInternal(KernelControllerContext context)
+   {
+      super.uninstallActionInternal(context);
+      
+      if (context instanceof WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WebBeansKernelControllerContext");
+
+      WebBeansInjector<?> injector = ((WebBeansKernelControllerContext)context).getWebBeansInjector();
+      if (injector != null)
+         injector.unconfigure();
+   }
+}
\ No newline at end of file

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerContextActions.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerContextActions.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerContextActions.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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 WebBeansControllerContextActions extends KernelControllerContextActions
+{
+   private static final WebBeansControllerContextActions INSTANCE;
+   static
+   {
+      Map<ControllerState, ControllerContextAction> actions = new HashMap<ControllerState, ControllerContextAction>();
+      
+      actions.put(ControllerState.PRE_INSTALL, new PreInstallAction());
+      actions.put(ControllerState.DESCRIBED, new WebBeansDescribeAction());
+      actions.put(ControllerState.INSTANTIATED, new WebBeansInstantiateAction());
+      actions.put(WebBeansPostConstructAction.STATE, new WebBeansPostConstructAction());
+      actions.put(ControllerState.CONFIGURED, new WebBeansConfigureAction());
+      actions.put(ControllerState.CREATE, new CreateDestroyLifecycleAction());
+      actions.put(WebBeansPreDestroyAction.STATE, new WebBeansPreDestroyAction());
+      actions.put(ControllerState.START, new StartStopLifecycleAction());
+      actions.put(WebBeansRegisterWebBeanAction.STATE, new WebBeansRegisterWebBeanAction());
+      actions.put(ControllerState.INSTALLED, new InstallAction());
+      INSTANCE = new WebBeansControllerContextActions(actions);
+   }
+   
+   protected WebBeansControllerContextActions(Map<ControllerState, ControllerContextAction> actions)
+   {
+      // FIXME WebBeansControllerContextActions constructor
+      super(actions);
+   }
+   
+   public static WebBeansControllerContextActions getInstance()
+   {
+      return INSTANCE;
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerInitializer.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerInitializer.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansControllerInitializer.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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 WebBeansControllerInitializer
+{
+   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(WebBeansPostConstructAction.STATE, ControllerState.CONFIGURED);
+         controller.addState(WebBeansPreDestroyAction.STATE, ControllerState.START);
+         controller.addState(WebBeansRegisterWebBeanAction.STATE, ControllerState.INSTALLED);
+      }
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansDescribeAction.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansDescribeAction.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansDescribeAction.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.plugins.dependency;
+
+import org.jboss.kernel.plugins.dependency.DescribeAction;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * DescribeAction that looks for webbeans interaction
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBeansDescribeAction extends DescribeAction
+{
+   
+   @Override
+   protected void applyAnnotations(KernelControllerContext context) throws Throwable
+   {
+      if (context instanceof WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+      
+      super.applyAnnotations(context);
+      
+      @SuppressWarnings("unchecked")
+      WebBeansInjector<?> webBeansInjector = new WebBeansInjector((WebBeansKernelControllerContext)context, context.getBeanInfo().getClassInfo().getType());
+      webBeansInjector.describe();
+   }
+
+   @Override
+   protected void cleanAnnotations(KernelControllerContext context)
+   {
+      super.cleanAnnotations(context);
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInjector.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInjector.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInjector.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,332 @@
+/*
+* 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.webbeans.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.ScopeType;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.BindingType;
+import javax.enterprise.inject.Policy;
+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 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.webbeans.plugins.metadata.WebBeansDependencyMetaData;
+import org.jboss.kernel.webbeans.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 WebBeansInjector<T> 
+{
+   final static Logger log = Logger.getLogger(WebBeansInjector.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
+    */
+   WebBeansKernelControllerContext 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 createInWebBeans;
+
+   /**
+    * 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
+    */
+   WebBeansInjector(WebBeansKernelControllerContext 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()
+   {
+      Set<Annotation> annotations = type.getAnnotations();
+      for (Annotation annotation : annotations)
+      {
+         for (Annotation meta : annotation.annotationType().getAnnotations())
+         {
+            Class<? extends Annotation> metaType = meta.annotationType();
+            if (metaType == Policy.class || metaType == BindingType.class || metaType == Stereotype.class || metaType == ScopeType.class)
+            {
+               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 createInWebBeans()
+   {
+      return createInWebBeans;
+   }
+
+   /**
+    * 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 WebBeansDependencyMetaData 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.setWebBeansInjector(this);
+            BeanMetaData metaData = context.getBeanMetaData();
+            for (InjectionPoint injectionPoint : it.getInjectionPoints())
+            {
+               BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(metaData);
+               
+               DependencyMetaData dependency = new WebBeansDependencyMetaData(injectionPoint);
+               if (!containsDependency(dependency))
+               {
+                  builder.addDependency(dependency);
+                  
+                  dependency.describeVisit(annotationsVisitor);
+                  dependency.initialVisit(annotationsVisitor);
+               }
+               
+               if (injectionPoint.getMember() instanceof Constructor)
+               {
+                  createInWebBeans = 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 (!createInWebBeans)
+         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;
+      }
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInstantiateAction.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInstantiateAction.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansInstantiateAction.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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 WebBeansInstantiateAction extends InstantiateAction
+{
+   @Override
+   protected void installActionInternal(KernelControllerContext context) throws Throwable
+   {
+      if (context instanceof WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+      
+      WebBeansInjector<?> injector = ((WebBeansKernelControllerContext)context).getWebBeansInjector();
+      if (injector != null && injector.createInWebBeans())
+         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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansKernelControllerContext.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansKernelControllerContext.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansKernelControllerContext.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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 WebBeansKernelControllerContext extends AbstractKernelControllerContext
+{
+   WebBeansInjector<?> 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 WebBeansKernelControllerContext(BeanInfo info, BeanMetaData metaData, Object target, BeanManager manager)
+   {
+      super(info, metaData, WebBeansControllerContextActions.getInstance(), target);
+      if (manager == null)
+         throw new IllegalArgumentException("Null manager");
+      this.manager = manager;
+   }
+
+   @Override
+   public void setController(Controller controller)
+   {
+      WebBeansControllerInitializer.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 setWebBeansInjector(WebBeansInjector<?> webBeansInjector)
+   {
+      this.webBeansInjector = webBeansInjector;
+   }
+   
+   /**
+    * Gets the web beans injector
+    * 
+    * @return the web beans injector 
+    */
+   WebBeansInjector<?> getWebBeansInjector()
+   {
+      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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPostConstructAction.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPostConstructAction.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPostConstructAction.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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 WebBeansPostConstructAction 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 WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WebBeansKernelControllerContext");
+
+      WebBeansInjector<?> injector = ((WebBeansKernelControllerContext)context).getWebBeansInjector();
+      if (injector != null)
+         injector.postConstruct(context.getTarget());
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPreDestroyAction.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPreDestroyAction.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansPreDestroyAction.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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 WebBeansPreDestroyAction 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 WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WebBeansKernelControllerContext");
+
+      WebBeansInjector<?> injector = ((WebBeansKernelControllerContext)context).getWebBeansInjector();
+      if (injector != null)
+         injector.preDestroy(context.getTarget());
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansRegisterWebBeanAction.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansRegisterWebBeanAction.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/dependency/WebBeansRegisterWebBeanAction.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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.webbeans.plugins.webbeans.WebBeansFromMcRegistry;
+
+/**
+ * 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 WebBeansRegisterWebBeanAction extends KernelControllerContextAction
+{
+   final static ControllerState STATE = new ControllerState("REGISTER_WEB_BEAN");
+   
+   @Override
+   protected void installActionInternal(KernelControllerContext context) throws Throwable
+   {
+      if (context instanceof WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+
+      WebBeansFromMcRegistry.registerBean((WebBeansKernelControllerContext)context);
+   }
+
+   @Override
+   protected void uninstallActionInternal(KernelControllerContext context)
+   {
+      if (context instanceof WebBeansKernelControllerContext == false)
+         throw new IllegalArgumentException("context is not a WabBeansKernelControllerContext");
+
+      WebBeansFromMcRegistry.unregisterBean((WebBeansKernelControllerContext)context);
+   }
+
+   protected Class<? extends KernelControllerContextAware> getActionAwareInterface()
+   {
+      return InstantiateKernelControllerContextAware.class;
+   }
+   
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/metadata/WebBeansDependencyMetaData.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/metadata/WebBeansDependencyMetaData.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/metadata/WebBeansDependencyMetaData.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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.webbeans.plugins.dependency.WebBeansKernelControllerContext;
+
+/**
+ * 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 WebBeansDependencyMetaData 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 WebBeansKernelControllerContext 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 WebBeansDependencyMetaData(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 WebBeansKernelControllerContext == false)
+         throw new IllegalStateException("Context is not a WebBeansKernelControllerContext " + context.getName());
+      this.context = (WebBeansKernelControllerContext)context;
+      
+      visitor.addDependency(new WebBeansDependencyItem(context.getName()));
+   }
+
+   @Override
+   protected int getHashCode()
+   {
+      int i = 17;
+      i = 31 * i + injectionPoint.getMember().hashCode();
+      for (Annotation ann : injectionPoint.getBindings())
+      {
+         i = 31 * i + ann.hashCode();
+      }
+      return i;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof WebBeansDependencyMetaData == false)
+         return false;
+      return equals(injectionPoint.getMember(), ((WebBeansDependencyMetaData)obj).injectionPoint.getMember()) &&
+         equals(injectionPoint.getBindings(), ((WebBeansDependencyMetaData)obj).injectionPoint.getBindings());
+   }
+
+   /**
+    * DependencyItem representing a web beans injection point 
+    */
+   private class WebBeansDependencyItem extends AbstractDependencyItem
+   {
+      public WebBeansDependencyItem(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/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/BeanImpl.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/BeanImpl.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/BeanImpl.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,142 @@
+/*
+* 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.webbeans.plugins.webbeans;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.beanutils.BeanDescriber;
+
+/**
+ * Implementation of the bean interface for MC beans that have an explicit binding
+ * annotation sothey can be registered in web beans beanmanager
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanImpl<T> implements Bean<T>
+{
+   
+   /**
+    * The name of the bean in MC
+    */
+   private final String name;
+   
+   /**
+    * The instance
+    */
+   private final T instance;
+      
+   /**
+    * Any ScopeType annotation
+    */
+   Class<? extends Annotation> scopeType;
+   
+   Bean<T> delegate;
+   
+   /**
+    * @param name the MC name of the MC bean represented by this BeanImpl
+    * @param name manager the bean manager
+    * @param type the annotated type of the bean
+    * @param the bean instance
+    */
+   public BeanImpl(String name, BeanManager manager, AnnotatedType<T> type, T instance)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      if (manager == null)
+         throw new IllegalArgumentException("Null manager");
+      if (type == null)
+         throw new IllegalArgumentException("Null type");
+      if (instance == null)
+         throw new IllegalArgumentException("Null instance");
+      
+      this.name = name;
+      this.instance = instance;
+      
+      delegate = BeanDescriber.describeBean(type, manager);
+   }
+
+   public Class<?> getBeanClass()
+   {
+      return delegate.getBeanClass();
+   }
+
+   public Set<Annotation> getBindings()
+   {
+      return delegate.getBindings();
+   }
+
+   public Set<InjectionPoint> getInjectionPoints()
+   {
+      return delegate.getInjectionPoints();
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public Class<? extends Annotation> getScopeType()
+   {
+      return delegate.getScopeType();
+   }
+
+   public Set<Class<? extends Annotation>> getStereotypes()
+   {
+      return delegate.getStereotypes();
+   }
+
+   public Set<Type> getTypes()
+   {
+      return delegate.getTypes();
+   }
+
+   public boolean isNullable()
+   {
+      return false;
+   }
+
+   public boolean isPolicy()
+   {
+      return delegate.isPolicy();
+   }
+
+   public T create(CreationalContext<T> creationalContext)
+   {
+      creationalContext.push(instance);
+      return instance;
+   }
+
+   public void destroy(T instance, CreationalContext<T> creationalContext)
+   {
+      creationalContext.release();
+   }
+   
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/McAfterBeanDiscoveryObserver.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/McAfterBeanDiscoveryObserver.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/McAfterBeanDiscoveryObserver.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.plugins.webbeans;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+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 AfterBeanDiscovery afterBeanDiscovery)
+   {
+      for (Bean<?> bean : WebBeansFromMcRegistry.getBeans())
+      {   
+         afterBeanDiscovery.addBean(bean);
+      }
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/WebBeansFromMcRegistry.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/WebBeansFromMcRegistry.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/plugins/webbeans/WebBeansFromMcRegistry.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,82 @@
+/*
+* 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.webbeans.plugins.webbeans;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.kernel.webbeans.plugins.dependency.WebBeansKernelControllerContext;
+
+/**
+ * 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 WebBeansFromMcRegistry
+{
+   //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, Bean<?>> beansByContext = new ConcurrentHashMap<Object, Bean<?>>();
+   
+   /**
+    * 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(WebBeansKernelControllerContext context)
+   {
+      AnnotatedType<?> type = context.getAnnotatedType();
+      if (type != null)
+      {
+         Bean<?> bean = new BeanImpl<Object>((String)context.getName(), context.getManager(), (AnnotatedType<Object>)type, context.getTarget());
+         beansByContext.put(context, bean);
+      }
+   }
+   
+   /**
+    * Unregister an mc context as a web bean
+    * 
+    * @param context the context to register in web beans
+    */
+   public static void unregisterBean(WebBeansKernelControllerContext context)
+   {
+      beansByContext.remove(context);
+   }
+   
+   /**
+    * Get a copy of all the MC beans that should be registered as web beans
+    */
+   public static Collection<Bean<?>> getBeans()
+   {
+      return new ArrayList<Bean<?>>(beansByContext.values());
+   }
+   
+}

Added: projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/spi/annotated/MDRAnnotatedTypeFactory.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/spi/annotated/MDRAnnotatedTypeFactory.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/main/java/org/jboss/kernel/webbeans/spi/annotated/MDRAnnotatedTypeFactory.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.spi.annotated;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.kernel.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AbstractWebBeansMcTest.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AbstractWebBeansMcTest.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AbstractWebBeansMcTest.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans;
+
+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.webbeans.plugins.dependency.WebBeansKernelControllerContext;
+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 AbstractWebBeansMcTest 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 AbstractWebBeansMcTest(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 WebBeansMcTestDelegate(clazz, autodeployMcBeans, autodeployWbClasses);
+   }
+   
+   /**
+    * Get the delegate
+    *
+    * @return the delegate
+    */
+   protected WebBeansMcTestDelegate getDelegate()
+   {
+      return (WebBeansMcTestDelegate)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 deployWebBeans(Class<?>...webBeansClasses) throws Exception
+   {
+      getDelegate().deployWebBeans(webBeansClasses);
+   }
+   
+   /**
+    * Deploys the web beans classes
+    *
+    * @param extension package in which to search for a file named {@link WebBeansMcTestDelegate#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 deployWebBeans(Package extension, Class<?>...webBeansClasses) throws Exception
+   {
+      getDelegate().deployWebBeans(extension, webBeansClasses);
+   }
+   
+   /**
+    * Undeploys the web beans classes if some were deployed
+    * 
+    * @throws Exception if an error happened during deployment
+    */
+   protected void undeployWebBeans() throws Exception
+   {
+      getDelegate().undeployWebBeans();
+   }
+   
+   /**
+    * Create a WebBeansKernelControllerContext and deploy it into the microcontainer
+    * 
+    * @param beanMetaData the bean metadata to deploy
+    * @return the WebBeansKernelControllerContext
+    * @throws Exception if an error happened during deployment
+    */
+   protected WebBeansKernelControllerContext 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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AutoDeployMcBeans.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AutoDeployMcBeans.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/AutoDeployMcBeans.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans;
+
+/**
+ * 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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansMcTestDelegate.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansMcTestDelegate.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansMcTestDelegate.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,338 @@
+/*
+* 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.webbeans;
+
+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.webbeans.plugins.dependency.WebBeansKernelControllerContext;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.webbeans.mock.MockEELifecycle;
+
+/**
+ * Delegate for the webbeans-int test framework 
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBeansMcTestDelegate 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
+    */
+   MockEELifecycle bootstrapLifecycle;
+   
+   /**
+    * Contains the web beans deployment (either done automatically if autodeployWbClasses is set, or by calling deployWebBeans() manually)
+    */
+   MockEELifecycle lifecycle;
+   
+   /**
+    * 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 WebBeansMcTestDelegate(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)
+         deployWebBeans(autodeployWbClasses);
+      
+      if (autoDeployMcBeans == AutoDeployMcBeans.AFTER)
+         deploy();
+   }
+
+   @Override
+   public void tearDown() throws Exception
+   {
+      undeployWebBeans();
+      
+      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 deployWebBeans(Class<?>...classes) throws Exception
+   {
+      deployWebBeans(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 deployWebBeans(Package extension, Class<?>...classes) throws Exception
+   {
+      deployWebBeans(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 MockEELifecycle deployWebBeans(boolean isForBootstrap, Package extension, Class<?>...classes) throws Exception
+   {
+      copyExtensions(extension);
+      
+      MockEELifecycle lifecycle = new MockEELifecycle();
+      lifecycle.getDeployment().getArchive().setBeanClasses(Arrays.asList(classes));
+      lifecycle.initialize();
+      lifecycle.beginApplication();
+      lifecycle.beginSession();
+      lifecycle.beginRequest();
+      
+      if (!isForBootstrap)
+      {
+         this.lifecycle = lifecycle;
+      }
+      return lifecycle;
+   }
+
+   /**
+    * Undeploys the webbeans deployed if {@link #lifecycle} is set
+    */
+   protected void undeployWebBeans() throws Exception
+   {
+      lifecycle = null;
+      if (lifecycle != null)
+      {
+         lifecycle.endRequest();
+         lifecycle.endSession();
+         lifecycle.endApplication();
+         lifecycle = null;
+      }
+      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)
+      {
+         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 WebBeansKernelControllerContext and deploy it into the microcontainer
+    * 
+    * @param beanMetaData the bean metadata to deploy
+    * @return the WebBeansKernelControllerContext
+    * @throws Exception if an error happened during deployment
+    */
+   protected WebBeansKernelControllerContext deploy(BeanMetaData beanMetaData) throws Exception
+   {
+      KernelController controller = kernel.getController();
+      log.debug("Deploying " + beanMetaData);
+      try
+      {
+         WebBeansKernelControllerContext context = new WebBeansKernelControllerContext(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 #lifecycle}, or a 'bootstrap' bean manager as 
+    * described in {@link #bootstrapLifecycle}
+    */
+   protected BeanManager getCurrentManager() throws Exception
+   {
+      if (lifecycle != null)
+         return getCurrentManager(lifecycle);
+      else if (bootstrapLifecycle == null)
+         bootstrapLifecycle = deployWebBeans(true, null);
+
+      return getCurrentManager(bootstrapLifecycle);
+   }
+   
+   private BeanManager getCurrentManager(MockEELifecycle lifecycle)
+   {
+      return lifecycle.getBootstrap().getManager(lifecycle.getDeployment().getArchive());
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansTestSuite.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansTestSuite.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/WebBeansTestSuite.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.kernel.webbeans.annotated.AnnotatedTypeTestCase;
+import org.jboss.test.kernel.webbeans.beanwrapper.test.BeanImplementationTestCase;
+import org.jboss.test.kernel.webbeans.mctowb.test.InjectMcBeansInWebBeansTestCase;
+import org.jboss.test.kernel.webbeans.wbtomc.test.InjectWebBeansInMcBeansTestCase;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBeansTestSuite extends TestSuite
+{
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("MC/Web Beans Tests");
+
+      suite.addTest(AnnotatedTypeTestCase.suite());
+      suite.addTest(BeanImplementationTestCase.suite());
+      suite.addTest(InjectWebBeansInMcBeansTestCase.suite());
+      suite.addTest(InjectMcBeansInWebBeansTestCase.suite());
+      
+      return suite;
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedTypeTestCase.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedTypeTestCase.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/AnnotatedTypeTestCase.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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.webbeans.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.webbeans.AbstractWebBeansMcTest;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotatedTypeTestCase extends AbstractWebBeansMcTest
+{
+   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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Child.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Child.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Child.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/NotAnnotatedBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/NotAnnotatedBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/NotAnnotatedBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Parent.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Parent.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Parent.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test1.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test1.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test1.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test2.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test2.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test2.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test3.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test3.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/annotated/Test3.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/Thing.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/Thing.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/Thing.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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.enterprise.inject.BindingType;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at BindingType
+ at Target({METHOD, FIELD, PARAMETER, TYPE})
+public @interface Thing 
+{
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingTarget.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingTarget.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/support/ThingTarget.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.beanwrapper.support;
+
+import javax.enterprise.inject.Initializer;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThingTarget 
+{
+   @Thing ThingBean field; 
+   
+   Thing notInjected;
+   
+   @Initializer
+   public ThingTarget(@Thing ThingBean bean)
+   {
+      
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/test/BeanImplementationTestCase.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/test/BeanImplementationTestCase.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/beanwrapper/test/BeanImplementationTestCase.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,210 @@
+/*
+* 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.webbeans.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.Current;
+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.kernel.webbeans.plugins.webbeans.BeanImpl;
+import org.jboss.test.kernel.webbeans.AbstractWebBeansMcTest;
+import org.jboss.test.kernel.webbeans.beanwrapper.support.Thing;
+import org.jboss.test.kernel.webbeans.beanwrapper.support.ThingBean;
+import org.jboss.test.kernel.webbeans.beanwrapper.support.ThingTarget;
+
+/**
+ * Tests the Bean
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanImplementationTestCase extends AbstractWebBeansMcTest
+{
+   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(Current.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(Current.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 policy, 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);
+      }
+      
+      Bean<T> impl = new BeanImpl<T>(name, getCurrentManager(), type, instance);
+      assertEquals(name, impl.getName());
+      assertEquals(policy, impl.isPolicy());
+      assertBindings(impl.getBindings(), bindings);
+      assertEquals(scopeType, impl.getScopeType());      
+
+      InjectionTarget<T> target = getCurrentManager().createInjectionTarget(getCurrentManager().createAnnotatedType((Class<T>)instance.getClass()));
+      assertEquals(target.getInjectionPoints(), impl.getInjectionPoints());
+      return impl;
+   }
+   
+   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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/TestObserver.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/TestObserver.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/TestObserver.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.mctowb.support.artifact1;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+import org.jboss.kernel.webbeans.plugins.webbeans.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 AfterBeanDiscovery afterBeanDiscovery)
+   {
+      super.observe(afterBeanDiscovery);
+      invoked = true;
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/TestMcAfterBeanDiscoveryObserver.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/TestMcAfterBeanDiscoveryObserver.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/TestMcAfterBeanDiscoveryObserver.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.mctowb.support.artifact2;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+
+import org.jboss.kernel.webbeans.plugins.webbeans.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 AfterBeanDiscovery afterBeanDiscovery)
+   {
+      super.observe(afterBeanDiscovery);
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingConstructor.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingConstructor.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingConstructor.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.mctowb.support.artifact2;
+
+import javax.enterprise.inject.Initializer;
+
+import org.jboss.test.kernel.webbeans.mctowb.support.mc.Thing;
+import org.jboss.test.kernel.webbeans.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;
+   
+   @Initializer
+   public ThingConstructor(@Thing ThingBean thing)
+   {
+      this.thing = thing;
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingField.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingField.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/ThingField.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,36 @@
+/*
+* 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.webbeans.mctowb.support.artifact2;
+
+import org.jboss.test.kernel.webbeans.mctowb.support.mc.Thing;
+import org.jboss.test.kernel.webbeans.mctowb.support.mc.ThingBean;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThingField
+{
+   @Thing 
+   public ThingBean thing;
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/Thing.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/Thing.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/Thing.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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.enterprise.inject.BindingType;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at BindingType
+ at Target({METHOD, FIELD, PARAMETER, TYPE})
+public @interface Thing 
+{
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/ThingBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/ThingBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/support/mc/ThingBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/test/InjectMcBeansInWebBeansTestCase.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/test/InjectMcBeansInWebBeansTestCase.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/mctowb/test/InjectMcBeansInWebBeansTestCase.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,115 @@
+/*
+* 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.webbeans.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.webbeans.plugins.dependency.WebBeansKernelControllerContext;
+import org.jboss.test.kernel.webbeans.AbstractWebBeansMcTest;
+import org.jboss.test.kernel.webbeans.mctowb.support.artifact1.TestObserver;
+import org.jboss.test.kernel.webbeans.mctowb.support.artifact2.TestMcAfterBeanDiscoveryObserver;
+import org.jboss.test.kernel.webbeans.mctowb.support.artifact2.ThingConstructor;
+import org.jboss.test.kernel.webbeans.mctowb.support.artifact2.ThingField;
+import org.jboss.test.kernel.webbeans.mctowb.support.mc.ThingBean;
+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 InjectMcBeansInWebBeansTestCase extends AbstractWebBeansMcTest
+{
+   public InjectMcBeansInWebBeansTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return new TestSuite(InjectMcBeansInWebBeansTestCase.class);
+   }
+   
+   public void testMcAfterBeanDiscoveryInvokerCalled() throws Exception
+   {
+      TestObserver.invoked = false;
+      try
+      {
+         deployWebBeans(TestObserver.class.getPackage(), TestObserver.class);
+         assertTrue(TestObserver.invoked);
+      }
+      finally
+      {
+         undeployWebBeans();
+      }
+   }
+   
+   public void testInjectMcBeanIntoField() throws Exception
+   {
+      WebBeansKernelControllerContext context = deploy(createBeanMetaData("thing", ThingBean.class));
+      try
+      {
+         ThingBean thing = assertBean("thing", ThingBean.class);
+         deployWebBeans(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
+      {
+         undeployWebBeans();
+         undeploy(context);
+      }
+   }
+
+   
+   public void testInjectMcBeanIntoConstructor() throws Exception
+   {
+      WebBeansKernelControllerContext context = deploy(createBeanMetaData("thing", ThingBean.class));
+      try
+      {
+         ThingBean thing = assertBean("thing", ThingBean.class);
+         deployWebBeans(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
+      {
+         undeployWebBeans();
+         undeploy(context);
+      }
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/Bean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/Bean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/Bean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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.enterprise.inject.BindingType;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at BindingType
+ at Target({METHOD, FIELD, PARAMETER, TYPE})
+public @interface Bean {
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/FailedBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/FailedBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/FailedBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.support;
+
+import javax.enterprise.inject.Current;
+
+import org.jboss.test.kernel.webbeans.wbtomc.test.WebBean;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class FailedBean
+{
+   @Current @Bean WebBean bean;
+
+   public WebBean getBean()
+   {
+      return bean;
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesConstructorBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesConstructorBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesConstructorBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.support;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+
+import org.jboss.test.kernel.webbeans.wbtomc.test.WebBean;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MissingDependenciesConstructorBean
+{
+   @Initializer
+   public MissingDependenciesConstructorBean(@Current @Bean WebBean bean)
+   {
+      
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesFieldBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesFieldBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/support/MissingDependenciesFieldBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,36 @@
+/*
+* 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.webbeans.wbtomc.support;
+
+import javax.enterprise.inject.Current;
+
+import org.jboss.test.kernel.webbeans.wbtomc.test.WebBean;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MissingDependenciesFieldBean
+{
+   @Current @Bean WebBean bean;
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanConstructor.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanConstructor.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanConstructor.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExternalBeanConstructor
+{
+   WebBean bean;
+   
+   WebBean nonAnnotated;
+   
+   @Initializer
+   public ExternalBeanConstructor(@Current WebBean bean)
+   {
+      this.bean = bean;
+   }
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanField.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanField.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanField.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExternalBeanField
+{
+   @Current WebBean bean;
+   
+   WebBean nonAnnotated;
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanMixed.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanMixed.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/ExternalBeanMixed.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExternalBeanMixed
+{
+   @Current WebBean fieldBean;
+   
+   WebBean nonAnnotated;
+
+   WebBean constructorBean;
+   
+   @Initializer
+   public ExternalBeanMixed(@Current WebBean bean)
+   {
+      this.constructorBean = bean;
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/InjectWebBeansInMcBeansTestCase.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/InjectWebBeansInMcBeansTestCase.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/InjectWebBeansInMcBeansTestCase.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1,395 @@
+/*
+* 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.webbeans.wbtomc.test;
+
+import java.util.Collections;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+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.webbeans.plugins.dependency.WebBeansKernelControllerContext;
+import org.jboss.test.kernel.webbeans.AbstractWebBeansMcTest;
+import org.jboss.test.kernel.webbeans.wbtomc.support.FailedBean;
+import org.jboss.test.kernel.webbeans.wbtomc.support.MissingDependenciesConstructorBean;
+import org.jboss.test.kernel.webbeans.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 InjectWebBeansInMcBeansTestCase extends AbstractWebBeansMcTest
+{
+   static
+   {
+      autodeployWbClasses = new Class[] {WebBean.class};
+   }
+   
+   public InjectWebBeansInMcBeansTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return new TestSuite(InjectWebBeansInMcBeansTestCase.class);
+   }
+   
+   public void testInjectFromWebBeansToExternalFieldObject() 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 testInjectFromWebBeansToExternalFieldObjectCreatedByProducer() 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 testInjectFromWebBeansToExternalConstructorObject() 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 testInjectFromWebBeansToExternalMixedObject() 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 testFailedInjectFromWebBeansToExternalObject() 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 testInjectFromWebBeansToMcInitializer() throws Exception
+   {
+      WebBeansKernelControllerContext 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 testInjectFromWebBeansToMcField() throws Exception
+   {
+      WebBeansKernelControllerContext 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 testInjectFromWebBeansToMcSetter() throws Exception
+//   {
+//      WebBeansKernelControllerContext 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 testInjectFromWebBeansToMcMcConstructorNoParams() throws Exception
+   {
+      WebBeansKernelControllerContext 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 testInjectFromWebBeansToMcMcConstructorWithParams() throws Exception
+   {
+      WebBeansKernelControllerContext contextSimple = deploy(createBeanMetaData("Simple", Simple.class));
+      
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("McBean", McBeanMcConstructor.class.getName());
+      builder.addConstructorParameter(Simple.class.getName(), builder.createInject("Simple"));
+      WebBeansKernelControllerContext  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
+   {
+      WebBeansKernelControllerContext 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
+   {
+      WebBeansKernelControllerContext 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
+   {
+      WebBeansKernelControllerContext 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
+   {
+      WebBeansKernelControllerContext 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("@" + Initializer.class.getName());
+      ctor.setAnnotations(Collections.singleton(initializer));
+      AbstractParameterMetaData param = new AbstractParameterMetaData(WebBean.class.getName(), (String)null);
+      AnnotationMetaData current = new AbstractAnnotationMetaData("@" + Current.class.getName());
+      param.setAnnotations(Collections.singleton(current));
+      ctor.setParameters(Collections.singletonList((ParameterMetaData)param));
+      metaData.setConstructor(ctor);
+      
+      AbstractPropertyMetaData property = new AbstractPropertyMetaData("bean", (String)null);
+      property.setAnnotations(Collections.singleton(current));
+      metaData.addProperty(property);
+      
+      WebBeansKernelControllerContext 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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBean
+{
+   WebBean beanFromConstructor;
+   
+   @Current
+   WebBean bean;
+   
+   WebBean nonInject;
+   
+   @Initializer
+   public McBean(@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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanAnnotationsFromMetaData.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanAnnotationsFromMetaData.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanAnnotationsFromMetaData.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanInitializerMethod.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanInitializerMethod.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanInitializerMethod.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanInitializerMethod
+{
+   WebBean bean;
+   
+   WebBean nonInject;
+   
+   @Initializer
+   public void initializerMethod(@Current WebBean bean)
+   {
+      this.bean = bean;
+   }
+
+   public WebBean getBean()
+   {
+      return bean;
+   }
+
+   public WebBean getNonInject()
+   {
+      return nonInject;
+   }
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanMcConstructor.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanMcConstructor.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanMcConstructor.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.test.kernel.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanMcConstructor
+{
+   @Current
+   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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWebBeanSetter.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWebBeanSetter.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWebBeanSetter.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+
+/**
+ * 
+ * @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;
+   }
+
+   @Current
+   public void setBean(WebBean bean)
+   {
+      this.bean = bean;
+   }
+   
+   public WebBean getNonInject()
+   {
+      return nonInject;
+   }
+}   

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/McBeanWithPostConstructAndPreDestroy.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class McBeanWithPostConstructAndPreDestroy
+{
+   @Current
+   WebBean bean;
+   
+   boolean postConstructCalled;
+   
+   boolean preDestroyCalled;
+   
+   @Initializer
+   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/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/Simple.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/Simple.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/Simple.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Simple
+{
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBean.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBean.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBean.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBean
+{
+
+}

Added: projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBeanConsumer.java
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBeanConsumer.java	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/java/org/jboss/test/kernel/webbeans/wbtomc/test/WebBeanConsumer.java	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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.webbeans.wbtomc.test;
+
+import javax.enterprise.inject.Current;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBeanConsumer
+{
+   @Current
+   WebBean bean;
+
+   public WebBean getBean()
+   {
+      return bean;
+   }
+}


Property changes on: projects/kernel/trunk/webbeans-int/src/test/resources/META-INF/services
___________________________________________________________________
Name: svn:ignore
   + javax.enterprise.inject.spi.Extension


Added: projects/kernel/trunk/webbeans-int/src/test/resources/META-INF/services/placeholder.txt
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/resources/META-INF/services/placeholder.txt	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/resources/META-INF/services/placeholder.txt	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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/webbeans-int/src/test/resources/log4j.properties
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/resources/log4j.properties	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/resources/log4j.properties	2009-08-27 16:42:14 UTC (rev 92878)
@@ -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/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/javax.enterprise.inject.spi.Extension
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/javax.enterprise.inject.spi.Extension	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact1/javax.enterprise.inject.spi.Extension	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1 @@
+org.jboss.test.kernel.webbeans.mctowb.support.artifact1.TestObserver
\ No newline at end of file

Added: projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/javax.enterprise.inject.spi.Extension
===================================================================
--- projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/javax.enterprise.inject.spi.Extension	                        (rev 0)
+++ projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/test/kernel/webbeans/mctowb/support/artifact2/javax.enterprise.inject.spi.Extension	2009-08-27 16:42:14 UTC (rev 92878)
@@ -0,0 +1 @@
+org.jboss.test.kernel.webbeans.mctowb.support.artifact2.TestMcAfterBeanDiscoveryObserver
\ No newline at end of file

Added: projects/kernel/trunk/webbeans-int/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
===================================================================




More information about the jboss-cvs-commits mailing list