[jboss-cvs] JBossAS SVN: r82047 - in projects/microcontainer/trunk/kernel/src: main/java/org/jboss/beans/metadata/spi/builder and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 4 10:36:53 EST 2008
Author: alesj
Date: 2008-12-04 10:36:53 -0500 (Thu, 04 Dec 2008)
New Revision: 82047
Modified:
projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/BeanMetaDataBuilderTestCase.java
Log:
[JBMICROCONT-401]; add contextual inject.
Modified: projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java 2008-12-04 14:34:36 UTC (rev 82046)
+++ projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java 2008-12-04 15:36:53 UTC (rev 82047)
@@ -32,6 +32,7 @@
import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.beans.metadata.api.model.AutowireType;
+import org.jboss.beans.metadata.api.model.InjectOption;
import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
import org.jboss.beans.metadata.plugins.AbstractArrayMetaData;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
@@ -53,6 +54,7 @@
import org.jboss.beans.metadata.plugins.DirectAnnotationMetaData;
import org.jboss.beans.metadata.plugins.StringValueMetaData;
import org.jboss.beans.metadata.plugins.ThisValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
import org.jboss.beans.metadata.spi.AnnotationMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
@@ -1002,6 +1004,30 @@
return result;
}
+ /**
+ * Create abstract dependency metadata.
+ *
+ * @return abstract dependency value metadata
+ */
+ protected AbstractInjectionValueMetaData createAbstractInjectionValueMetaData()
+ {
+ return new AbstractInjectionValueMetaData();
+ }
+
+ public ValueMetaData createContextualInject(ControllerState whenRequired, ControllerState dependentState, AutowireType autowire, InjectOption option)
+ {
+ AbstractInjectionValueMetaData result = createAbstractInjectionValueMetaData();
+ if (whenRequired != null)
+ result.setWhenRequiredState(whenRequired);
+ if (dependentState != null)
+ result.setDependentState(dependentState);
+ if (autowire != null)
+ result.setInjectionType(autowire);
+ if (option != null)
+ result.setInjectionOption(option);
+ return result;
+ }
+
@SuppressWarnings("unchecked")
public Collection<ValueMetaData> createCollection(String collectionType, String elementType)
{
Modified: projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java 2008-12-04 14:34:36 UTC (rev 82046)
+++ projects/microcontainer/trunk/kernel/src/main/java/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java 2008-12-04 15:36:53 UTC (rev 82047)
@@ -30,6 +30,7 @@
import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.beans.metadata.api.model.AutowireType;
+import org.jboss.beans.metadata.api.model.InjectOption;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
import org.jboss.beans.metadata.spi.BeanMetaData;
@@ -1611,8 +1612,41 @@
* @return the injection
*/
public abstract ValueMetaData createInject(Object bean, String property, ControllerState whenRequired, ControllerState dependentState);
-
+
/**
+ * Create contextual injection.
+ *
+ * @return the contextual injection
+ */
+ public ValueMetaData createContextualInject()
+ {
+ return createContextualInject(null, null);
+ }
+
+ /**
+ * Create contextual injection.
+ *
+ * @param whenRequired when the injection is required
+ * @param dependentState the state of the injected bean
+ * @return the contextual injection
+ */
+ public ValueMetaData createContextualInject(ControllerState whenRequired, ControllerState dependentState)
+ {
+ return createContextualInject(whenRequired, dependentState, null, null);
+ }
+
+ /**
+ * Create contextual injection.
+ *
+ * @param whenRequired when the injection is required
+ * @param dependentState the state of the injected bean
+ * @param autowire the autowire type
+ * @param option the inject option
+ * @return the contextual injection
+ */
+ public abstract ValueMetaData createContextualInject(ControllerState whenRequired, ControllerState dependentState, AutowireType autowire, InjectOption option);
+
+ /**
* Create a new collection
*
* @return the collection
Modified: projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/BeanMetaDataBuilderTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/BeanMetaDataBuilderTestCase.java 2008-12-04 14:34:36 UTC (rev 82046)
+++ projects/microcontainer/trunk/kernel/src/test/java/org/jboss/test/kernel/config/test/BeanMetaDataBuilderTestCase.java 2008-12-04 15:36:53 UTC (rev 82047)
@@ -43,6 +43,7 @@
import org.jboss.beans.metadata.spi.RelatedClassMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.beans.metadata.spi.LifecycleMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.dependency.spi.Cardinality;
import org.jboss.dependency.spi.ControllerContext;
@@ -911,4 +912,18 @@
assertNotNull(lmd);
assertTrue(lmd.isIgnored());
}
+
+ public void testContextualInjection() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("test");
+ builder.addPropertyMetaData("ci", builder.createContextualInject());
+ BeanMetaData bmd = builder.getBeanMetaData();
+ Set<PropertyMetaData> properties = bmd.getProperties();
+ assertNotNull(properties);
+ assertEquals(1, properties.size());
+ PropertyMetaData pmd = properties.iterator().next();
+ ValueMetaData vmd = pmd.getValue();
+ assertNotNull(vmd);
+ assertNull(vmd.getUnderlyingValue());
+ }
}
More information about the jboss-cvs-commits
mailing list