[jboss-cvs] JBossAS SVN: r72491 - in projects/microcontainer/trunk/kernel/src: main/org/jboss/kernel/plugins/annotations and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 21 10:28:26 EDT 2008
Author: alesj
Date: 2008-04-21 10:28:26 -0400 (Mon, 21 Apr 2008)
New Revision: 72491
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsAnnotationPluginFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsFieldInjectionAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsMatcher.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsPropertyInjectionAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupply.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupplyAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Blue.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Green.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBDemander.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBSupplier.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Red.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/AnnotationsMatchingTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/WBTestSuite.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AbstractRunAnnotationsTest.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/SetDemandTransformer.java
Log:
Initial WebBeans kind of injection.
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -36,4 +36,12 @@
* @return true if we match the other param, false otherwise
*/
boolean match(Object other);
+
+ /**
+ * Do we need an exact match.
+ * No match or single match is acceptable.
+ *
+ * @return true if matcher accepts only exact matches
+ */
+ boolean needExactMatch();
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -31,6 +31,11 @@
return other != null && internalMatch(other);
}
+ public boolean needExactMatch()
+ {
+ return false;
+ }
+
/**
* Do internal match.
*
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -22,9 +22,7 @@
package org.jboss.kernel.plugins.annotations;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.Set;
import org.jboss.reflect.spi.AnnotatedInfo;
@@ -37,14 +35,13 @@
*/
public abstract class AbstractAdaptersAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends AbstractAnnotationPlugin<T, C>
{
- protected List<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters;
+ protected Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters;
- protected AbstractAdaptersAnnotationPlugin(Class<C> annotation, Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected AbstractAdaptersAnnotationPlugin(Class<C> annotation, Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(annotation);
- this.adapters = new ArrayList<Annotation2ValueMetaDataAdapter<? extends Annotation>>();
- if (adapters == null || adapters.length == 0)
- throw new IllegalArgumentException("Annotation adapters are empty!");
- this.adapters.addAll(Arrays.asList(adapters));
+ if (adapters == null)
+ throw new IllegalArgumentException("Null annotation adapters.");
+ this.adapters = adapters;
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
import org.jboss.beans.metadata.plugins.builder.MutableParameterizedMetaData;
@@ -51,7 +52,7 @@
*/
public abstract class AbstractParameterAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation, P extends MutableParameterizedMetaData> extends AbstractAdaptersAnnotationPlugin<T, C>
{
- protected AbstractParameterAnnotationPlugin(Class<C> annotation, Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected AbstractParameterAnnotationPlugin(Class<C> annotation, Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(annotation, adapters);
}
@@ -163,12 +164,10 @@
ValueMetaData value = null;
for(Annotation2ValueMetaDataAdapter adapter : adapters)
{
- // todo - match multiple annotations?
Annotation adapterAnnotation = mdr.getAnnotation(adapter.getAnnotation());
if (adapterAnnotation != null)
{
- value = adapter.createValueMetaData(adapterAnnotation);
- break;
+ value = adapter.createValueMetaData(adapterAnnotation, value);
}
}
if (value == null)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -44,7 +44,8 @@
* Create ValueMetaData instance.
*
* @param annotation the annotation instance
+ * @param previousValue previous value
* @return new ValueMetaData instance
*/
- ValueMetaData createValueMetaData(C annotation);
+ ValueMetaData createValueMetaData(C annotation, ValueMetaData previousValue);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -22,6 +22,8 @@
package org.jboss.kernel.plugins.annotations;
import java.lang.annotation.Annotation;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
/**
* Basic bean annotation handler.
@@ -32,23 +34,14 @@
{
public static BasicBeanAnnotationAdapter INSTANCE = new BasicBeanAnnotationAdapter();
+ /** The parameter annotation adapters */
+ private Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters;
+
protected BasicBeanAnnotationAdapter()
{
// -- adapters
- @SuppressWarnings("unchecked")
- Annotation2ValueMetaDataAdapter<? extends Annotation>[] adapters = new Annotation2ValueMetaDataAdapter[]{
- InjectAnnotationPlugin.INSTANCE,
- StringValueAnnotationPlugin.INSTANCE,
- ValueFactoryAnnotationPlugin.INSTANCE,
- ThisValueAnnotationPlugin.INSTANCE,
- NullValueAnnotationPlugin.INSTANCE,
- JavaBeanValueAnnotationPlugin.INSTANCE,
- CollectionValueAnnotationPlugin.INSTANCE,
- ListValueAnnotationPlugin.INSTANCE,
- SetValueAnnotationPlugin.INSTANCE,
- ArrayValueAnnotationPlugin.INSTANCE,
- MapValueAnnotationPlugin.INSTANCE,
- };
+ adapters = new CopyOnWriteArraySet<Annotation2ValueMetaDataAdapter<? extends Annotation>>();
+
// -- plugins
// class
addAnnotationPlugin(AliasesAnnotationPlugin.INSTANCE);
@@ -100,4 +93,43 @@
addAnnotationPlugin(InstallFieldCallbackAnnotationPlugin.INSTANCE);
addAnnotationPlugin(UninstallFieldCallbackAnnotationPlugin.INSTANCE);
}
+
+ @SuppressWarnings("unchecked")
+ public void addAnnotationPlugin(AnnotationPlugin<?, ?> plugin)
+ {
+ super.addAnnotationPlugin(plugin);
+ if (plugin instanceof Annotation2ValueMetaDataAdapter)
+ addAnnotation2ValueMetaDataAdapter((Annotation2ValueMetaDataAdapter<? extends Annotation>)plugin);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void removeAnnotationPlugin(AnnotationPlugin<?, ?> plugin)
+ {
+ if (plugin instanceof Annotation2ValueMetaDataAdapter)
+ removeAnnotation2ValueMetaDataAdapter((Annotation2ValueMetaDataAdapter<? extends Annotation>)plugin);
+ super.removeAnnotationPlugin(plugin);
+ }
+
+ /**
+ * Add Annotation2ValueMetaDataAdapter adapter.
+ *
+ * @param adapter the Annotation2ValueMetaDataAdapter adapter
+ */
+ public void addAnnotation2ValueMetaDataAdapter(Annotation2ValueMetaDataAdapter<? extends Annotation> adapter)
+ {
+ if (adapter == null)
+ throw new IllegalArgumentException("Null Annotation2ValueMetaDataAdapter");
+ adapters.add(adapter);
+ }
+
+ /**
+ * Remove Annotation2ValueMetaDataAdapter adapter.
+ *
+ * @param adapter the Annotation2ValueMetaDataAdapter adapter
+ */
+ public void removeAnnotation2ValueMetaDataAdapter(Annotation2ValueMetaDataAdapter<? extends Annotation> adapter)
+ {
+ if (adapter != null)
+ adapters.remove(adapter);
+ }
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -22,6 +22,8 @@
package org.jboss.kernel.plugins.annotations;
import java.lang.annotation.Annotation;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
/**
* Basic bean metadata annotation handler.
@@ -32,24 +34,14 @@
{
public static BasicBeanMetaDataAnnotationAdapter INSTANCE = new BasicBeanMetaDataAnnotationAdapter();
+ /** The parameter annotation adapters */
+ private Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters;
+
protected BasicBeanMetaDataAnnotationAdapter()
{
// -- adapters
- @SuppressWarnings("unchecked")
- Annotation2ValueMetaDataAdapter<? extends Annotation>[] adapters = new Annotation2ValueMetaDataAdapter[]{
- InjectAnnotationPlugin.INSTANCE,
- StringValueAnnotationPlugin.INSTANCE,
- ValueFactoryAnnotationPlugin.INSTANCE,
- ThisValueAnnotationPlugin.INSTANCE,
- NullValueAnnotationPlugin.INSTANCE,
- JavaBeanValueAnnotationPlugin.INSTANCE,
- CollectionValueAnnotationPlugin.INSTANCE,
- ListValueAnnotationPlugin.INSTANCE,
- SetValueAnnotationPlugin.INSTANCE,
- ArrayValueAnnotationPlugin.INSTANCE,
- MapValueAnnotationPlugin.INSTANCE,
- };
- // -- plugins
+ adapters = new CopyOnWriteArraySet<Annotation2ValueMetaDataAdapter<? extends Annotation>>();
+
// class
addAnnotationPlugin(AliasMetaDataAnnotationPlugin.INSTANCE);
addAnnotationPlugin(DemandsAnnotationPlugin.INSTANCE);
@@ -90,4 +82,43 @@
addAnnotationPlugin(InstallFieldCallbackAnnotationPlugin.INSTANCE);
addAnnotationPlugin(UninstallFieldCallbackAnnotationPlugin.INSTANCE);
}
+
+ @SuppressWarnings("unchecked")
+ public void addAnnotationPlugin(AnnotationPlugin<?, ?> plugin)
+ {
+ super.addAnnotationPlugin(plugin);
+ if (plugin instanceof Annotation2ValueMetaDataAdapter)
+ addAnnotation2ValueMetaDataAdapter((Annotation2ValueMetaDataAdapter<? extends Annotation>)plugin);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void removeAnnotationPlugin(AnnotationPlugin<?, ?> plugin)
+ {
+ if (plugin instanceof Annotation2ValueMetaDataAdapter)
+ removeAnnotation2ValueMetaDataAdapter((Annotation2ValueMetaDataAdapter<? extends Annotation>)plugin);
+ super.removeAnnotationPlugin(plugin);
+ }
+
+ /**
+ * Add Annotation2ValueMetaDataAdapter adapter.
+ *
+ * @param adapter the Annotation2ValueMetaDataAdapter adapter
+ */
+ public void addAnnotation2ValueMetaDataAdapter(Annotation2ValueMetaDataAdapter<? extends Annotation> adapter)
+ {
+ if (adapter == null)
+ throw new IllegalArgumentException("Null Annotation2ValueMetaDataAdapter");
+ adapters.add(adapter);
+ }
+
+ /**
+ * Remove Annotation2ValueMetaDataAdapter adapter.
+ *
+ * @param adapter the Annotation2ValueMetaDataAdapter adapter
+ */
+ public void removeAnnotation2ValueMetaDataAdapter(Annotation2ValueMetaDataAdapter<? extends Annotation> adapter)
+ {
+ if (adapter != null)
+ adapters.remove(adapter);
+ }
}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import org.jboss.beans.metadata.api.annotations.Factory;
import org.jboss.beans.metadata.api.annotations.Value;
@@ -44,7 +45,7 @@
*/
public class ClassFactoryAnnotationPlugin extends AbstractAdaptersAnnotationPlugin<ClassInfo, Factory>
{
- protected ClassFactoryAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected ClassFactoryAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(Factory.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -24,6 +24,7 @@
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.util.List;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
@@ -40,7 +41,7 @@
*/
public class ConstructorParameterAnnotationPlugin extends AbstractParameterAnnotationPlugin<ConstructorInfo, Constructor, AbstractConstructorMetaData>
{
- protected ConstructorParameterAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected ConstructorParameterAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(Constructor.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -29,6 +29,7 @@
import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.metadata.spi.MetaData;
@@ -63,4 +64,17 @@
context.setBeanInfo(null);
return Collections.singletonList(constructor);
}
+
+ public ValueMetaData createValueMetaData(C annotation, ValueMetaData previousValue)
+ {
+ return createValueMetaData(annotation);
+ }
+
+ /**
+ * Create the value metadata from annotation.
+ *
+ * @param annotation the annotation
+ * @return new value metadata
+ */
+ protected abstract ValueMetaData createValueMetaData(C annotation);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -22,6 +22,7 @@
package org.jboss.kernel.plugins.annotations;
import java.lang.annotation.Annotation;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
@@ -35,7 +36,7 @@
*/
public class CreateLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Create>
{
- protected CreateLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected CreateLifecycleAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(Create.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -22,6 +22,7 @@
package org.jboss.kernel.plugins.annotations;
import java.lang.annotation.Annotation;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
@@ -35,7 +36,7 @@
*/
public class DestroyLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Destroy>
{
- protected DestroyLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected DestroyLifecycleAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(Destroy.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -25,6 +25,7 @@
import java.lang.annotation.ElementType;
import java.util.List;
import java.util.Collections;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
@@ -41,7 +42,7 @@
*/
public class FactoryMethodAnnotationPlugin extends AbstractParameterAnnotationPlugin<MethodInfo, FactoryMethod, AbstractConstructorMetaData>
{
- public FactoryMethodAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ public FactoryMethodAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(FactoryMethod.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectableMemberAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -57,7 +57,14 @@
*/
protected abstract String getName(T info);
- protected boolean isMetaDataAlreadyPresent(T info, C annotation, BeanMetaData beanMetaData)
+ /**
+ * Find matching property metadata.
+ *
+ * @param info the property info
+ * @param beanMetaData the bean metadata
+ * @return matching property metadata or null
+ */
+ protected PropertyMetaData findPropertyMetaData(T info, BeanMetaData beanMetaData)
{
Set<PropertyMetaData> properties = beanMetaData.getProperties();
if (properties != null && properties.isEmpty() == false)
@@ -65,12 +72,29 @@
for(PropertyMetaData pmd : properties)
{
if (pmd.getName().equals(getName(info)))
- return true;
+ return pmd;
}
}
- return false;
+ return null;
}
+ protected boolean isMetaDataAlreadyPresent(T info, C annotation, BeanMetaData beanMetaData)
+ {
+ PropertyMetaData pmd = findPropertyMetaData(info, beanMetaData);
+ return isMetaDataComplete(pmd);
+ }
+
+ /**
+ * Is property metadata complete.
+ *
+ * @param pmd the property meta data
+ * @return true if metadata is complete
+ */
+ protected boolean isMetaDataComplete(PropertyMetaData pmd)
+ {
+ return (pmd != null);
+ }
+
protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, C annotation, BeanMetaData beanMetaData) throws Throwable
{
Set<PropertyMetaData> properties = getProperties(beanMetaData);
@@ -120,7 +144,7 @@
if (properties == null)
{
properties = new HashSet<PropertyMetaData>();
- AbstractBeanMetaData bean = (AbstractBeanMetaData)beanMetaData;
+ AbstractBeanMetaData bean = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
bean.setProperties(properties);
}
return properties;
@@ -135,6 +159,18 @@
*/
protected ValueMetaData createValueMetaData(T info, C annotation)
{
+ return createValueMetaData(annotation, null);
+ }
+
+ /**
+ * Create value meta data.
+ *
+ * @param annotation the annotation
+ * @param previousValue previous value
+ * @return value meta data
+ */
+ public ValueMetaData createValueMetaData(C annotation, ValueMetaData previousValue)
+ {
return createValueMetaData(annotation);
}
@@ -146,6 +182,6 @@
*/
public ValueMetaData createValueMetaData(C annotation)
{
- throw new IllegalArgumentException("Missing createValueMetaData(" + annotation + ") implementation!");
+ throw new IllegalArgumentException("Missing createValueMetaData(" + annotation + ") implementation: " + toString());
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -24,6 +24,7 @@
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.ArrayList;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
@@ -40,7 +41,7 @@
*/
public class InstallMethodParameterAnnotationPlugin extends InstallationParameterAnnotationPlugin<InstallMethod>
{
- protected InstallMethodParameterAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected InstallMethodParameterAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(InstallMethod.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -25,6 +25,7 @@
import java.lang.annotation.ElementType;
import java.util.List;
import java.util.Collections;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
@@ -44,7 +45,7 @@
*/
public abstract class InstallationParameterAnnotationPlugin<C extends Annotation> extends AbstractParameterAnnotationPlugin<MethodInfo, C, AbstractInstallMetaData>
{
- protected InstallationParameterAnnotationPlugin(Class<C> annotation, Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected InstallationParameterAnnotationPlugin(Class<C> annotation, Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(annotation, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -25,6 +25,7 @@
import java.lang.annotation.ElementType;
import java.util.List;
import java.util.Collections;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
@@ -41,7 +42,7 @@
*/
public abstract class LifecycleParameterAnnotationPlugin<C extends Annotation> extends AbstractParameterAnnotationPlugin<MethodInfo, C, AbstractLifecycleMetaData>
{
- protected LifecycleParameterAnnotationPlugin(Class<C> annotation, Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected LifecycleParameterAnnotationPlugin(Class<C> annotation, Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(annotation, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -22,6 +22,7 @@
package org.jboss.kernel.plugins.annotations;
import java.lang.annotation.Annotation;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
@@ -35,7 +36,7 @@
*/
public class StartLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Start>
{
- protected StartLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected StartLifecycleAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(Start.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -22,6 +22,7 @@
package org.jboss.kernel.plugins.annotations;
import java.lang.annotation.Annotation;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
@@ -35,7 +36,7 @@
*/
public class StopLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Stop>
{
- protected StopLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected StopLifecycleAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(Stop.class, adapters);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -24,6 +24,7 @@
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
@@ -40,7 +41,7 @@
*/
public class UninstallMethodParameterAnnotationPlugin extends InstallationParameterAnnotationPlugin<UninstallMethod>
{
- protected UninstallMethodParameterAnnotationPlugin(Annotation2ValueMetaDataAdapter<? extends Annotation>... adapters)
+ protected UninstallMethodParameterAnnotationPlugin(Set<Annotation2ValueMetaDataAdapter<? extends Annotation>> adapters)
{
super(UninstallMethod.class, adapters);
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsAnnotationPluginFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsAnnotationPluginFactory.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsAnnotationPluginFactory.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.annotations.wb;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.kernel.plugins.annotations.AnnotationPlugin;
+
+/**
+ * Annotations plugin factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsAnnotationPluginFactory
+{
+ /**
+ * Create class plugin.
+ *
+ * @param clazz the annotation class
+ * @return new annotations supply plugin
+ */
+ public static AnnotationPlugin createClassPlugin(Class<? extends Annotation> clazz)
+ {
+ return new AnnotationsSupplyAnnotationPlugin(clazz);
+ }
+
+ /**
+ * Create injection plugin.
+ *
+ * @param clazz the annotation class
+ * @return new annotations injection plugin
+ */
+ public static AnnotationPlugin createPropertyInjectionPlugin(Class<? extends Annotation> clazz)
+ {
+ return new AnnotationsPropertyInjectionAnnotationPlugin(clazz);
+ }
+
+ /**
+ * Create injection plugin.
+ *
+ * @param clazz the annotation class
+ * @return new annotations injection plugin
+ */
+ public static AnnotationPlugin createFieldInjectionPlugin(Class<? extends Annotation> clazz)
+ {
+ return new AnnotationsFieldInjectionAnnotationPlugin(clazz);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsFieldInjectionAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsFieldInjectionAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsFieldInjectionAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.annotations.wb;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.kernel.plugins.annotations.FieldAnnotationPlugin;
+
+/**
+ * Generic annotations injection metadata value creator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsFieldInjectionAnnotationPlugin extends FieldAnnotationPlugin<Annotation>
+{
+ @SuppressWarnings("unchecked")
+ public AnnotationsFieldInjectionAnnotationPlugin(Class annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isMetaDataComplete(PropertyMetaData pmd)
+ {
+ if (pmd == null)
+ return false;
+
+ ValueMetaData value = pmd.getValue();
+ Object underlyingValue = value.getUnderlyingValue();
+ return (underlyingValue instanceof AnnotationsMatcher == false);
+ }
+
+ public ValueMetaData createValueMetaData(Annotation annotation, ValueMetaData previousValue)
+ {
+ if (previousValue == null)
+ return new AbstractDependencyValueMetaData(new AnnotationsMatcher(annotation));
+
+ Object underlyingValue = previousValue.getUnderlyingValue();
+ if (underlyingValue instanceof AnnotationsMatcher)
+ {
+ AnnotationsMatcher am = (AnnotationsMatcher)underlyingValue;
+ am.addAnnotation(annotation);
+ }
+ else
+ {
+ log.info("Ignoring custom annotation, previous value is not AnnotationsMatcher: " + previousValue);
+ }
+ return previousValue;
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsMatcher.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsMatcher.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.annotations.wb;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.kernel.api.dependency.ClassMatcher;
+
+/**
+ * Annotations matcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsMatcher extends ClassMatcher<AnnotationsSupply> implements Serializable
+{
+ private static final long serialVersionUID = 1l;
+
+ private Set<Annotation> annotations = new HashSet<Annotation>();
+ private int size;
+
+ public AnnotationsMatcher(Annotation annotation)
+ {
+ super(AnnotationsSupply.class);
+ addAnnotation(annotation);
+ }
+
+ /**
+ * Add the annotation.
+ *
+ * @param annotation the annotation
+ */
+ public void addAnnotation(Annotation annotation)
+ {
+ annotations.add(annotation);
+ size = annotations.size();
+ }
+
+ protected boolean matchByType(AnnotationsSupply other)
+ {
+ Set<Annotation> otherAnnotations = other.getAnnotations();
+ if (otherAnnotations.size() >= size)
+ {
+ otherAnnotations = new HashSet<Annotation>(otherAnnotations);
+ otherAnnotations.retainAll(annotations);
+ return (otherAnnotations.size() == size);
+ }
+ return false;
+ }
+
+ public boolean needExactMatch()
+ {
+ return true;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsPropertyInjectionAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsPropertyInjectionAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsPropertyInjectionAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,96 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.annotations.wb;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.kernel.plugins.annotations.PropertyAnnotationPlugin;
+
+/**
+ * Generic annotations injection metadata value creator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsPropertyInjectionAnnotationPlugin extends PropertyAnnotationPlugin<Annotation>
+{
+ @SuppressWarnings("unchecked")
+ public AnnotationsPropertyInjectionAnnotationPlugin(Class annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isMetaDataComplete(PropertyMetaData pmd)
+ {
+ if (pmd == null)
+ return false;
+
+ ValueMetaData value = pmd.getValue();
+ Object underlyingValue = value.getUnderlyingValue();
+ return (underlyingValue instanceof AnnotationsMatcher == false);
+ }
+
+ protected PropertyMetaData getPropertyMetaData(PropertyInfo info, Annotation annotation, BeanMetaData beanMetaData)
+ {
+ PropertyMetaData pmd = findPropertyMetaData(info, beanMetaData);
+ if (pmd != null)
+ {
+ ValueMetaData value = pmd.getValue();
+ Object underlyingValue = value.getUnderlyingValue();
+ if (underlyingValue instanceof AnnotationsMatcher == false)
+ throw new IllegalArgumentException("Should not be here: " + toString());
+
+ AnnotationsMatcher am = (AnnotationsMatcher)underlyingValue;
+ am.addAnnotation(annotation);
+ }
+ else
+ {
+ ValueMetaData value = createValueMetaData(annotation, null);
+ pmd = new AbstractPropertyMetaData(getName(info), value);
+ }
+
+ return pmd;
+ }
+
+ public ValueMetaData createValueMetaData(Annotation annotation, ValueMetaData previousValue)
+ {
+ if (previousValue == null)
+ return new AbstractDependencyValueMetaData(new AnnotationsMatcher(annotation));
+
+ Object underlyingValue = previousValue.getUnderlyingValue();
+ if (underlyingValue instanceof AnnotationsMatcher)
+ {
+ AnnotationsMatcher am = (AnnotationsMatcher)underlyingValue;
+ am.addAnnotation(annotation);
+ }
+ else
+ {
+ log.info("Ignoring custom annotation, previous value is not AnnotationsMatcher: " + previousValue);
+ }
+ return previousValue;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupply.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupply.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupply.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.annotations.wb;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Annotation supply.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsSupply implements Serializable
+{
+ private static final long serialVersionUID = 1l;
+
+ private Set<Annotation> annotations = new HashSet<Annotation>();
+
+ public AnnotationsSupply(Annotation annotation)
+ {
+ addAnnotation(annotation);
+ }
+
+ /**
+ * Add the annotation.
+ *
+ * @param annotation the annotation
+ */
+ public void addAnnotation(Annotation annotation)
+ {
+ annotations.add(annotation);
+ }
+
+ /**
+ * Get the annotations.
+ *
+ * @return the annotations
+ */
+ public Set<Annotation> getAnnotations()
+ {
+ return annotations;
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupplyAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupplyAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/wb/AnnotationsSupplyAnnotationPlugin.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.annotations.wb;
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.kernel.plugins.annotations.ClassAnnotationPlugin;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.reflect.spi.ClassInfo;
+
+/**
+ * Generic annotations supply metadata value creator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsSupplyAnnotationPlugin extends ClassAnnotationPlugin<Annotation>
+{
+ @SuppressWarnings("unchecked")
+ public AnnotationsSupplyAnnotationPlugin(Class annotation)
+ {
+ super(annotation);
+ }
+
+ /**
+ * Find the annotations supply.
+ *
+ * @param supplies the supplies
+ * @return matcher supply or null if not found
+ */
+ protected AnnotationsSupply findAnnotationsSupply(Set<SupplyMetaData> supplies)
+ {
+ for(SupplyMetaData smd : supplies)
+ {
+ final Object supply = smd.getSupply();
+ if (supply instanceof AnnotationsSupply)
+ {
+ return (AnnotationsSupply) supply;
+ }
+ }
+ return null;
+ }
+
+ protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, MetaData retrieval, Annotation annotation, BeanMetaData beanMetaData) throws Throwable
+ {
+ Set<SupplyMetaData> supplies = beanMetaData.getSupplies();
+ if (supplies == null)
+ {
+ AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
+ supplies = new HashSet<SupplyMetaData>();
+ abmd.setSupplies(supplies);
+ return applyAnnotationsSupply(annotation, supplies);
+ }
+ AnnotationsSupply as = findAnnotationsSupply(supplies);
+ if (as == null)
+ return applyAnnotationsSupply(annotation, supplies);
+ else
+ {
+ as.addAnnotation(annotation);
+ return null;
+ }
+ }
+
+ /**
+ * Apply annotations supply.
+ *
+ * @param annotation the annotation
+ * @param supplies the supplies
+ * @return new supply
+ */
+ protected List<? extends MetaDataVisitorNode> applyAnnotationsSupply(Annotation annotation, Set<SupplyMetaData> supplies)
+ {
+ SupplyMetaData supply = new AbstractSupplyMetaData(new AnnotationsSupply(annotation));
+ supplies.add(supply);
+ return Collections.singletonList(supply);
+ }
+}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -121,12 +121,23 @@
*/
protected List<KernelControllerContext> matchSupplies(Matcher matcher)
{
+ List<KernelControllerContext> list = null;
for(Map.Entry<Object, List<KernelControllerContext>> entry : suppliers.entrySet())
{
if (matcher.match(entry.getKey()))
- return entry.getValue();
+ {
+ if (matcher.needExactMatch() == false)
+ return entry.getValue();
+ else
+ {
+ if (list != null)
+ throw new IllegalArgumentException("Matcher " + matcher + " only takes exact match, but found second matching supplier.");
+ else
+ list = entry.getValue();
+ }
+ }
}
- return null;
+ return list;
}
public ControllerContext getContext(Object name, ControllerState state)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -48,6 +48,11 @@
return JBossObject.equals(value, other);
}
+ public boolean needExactMatch()
+ {
+ return false;
+ }
+
public String toString()
{
return value != null ? value.toString() : "<null>";
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Blue.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Blue.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Blue.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotations.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface Blue
+{
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Green.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Green.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Green.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotations.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface Green
+{
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBDemander.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBDemander.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBDemander.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,79 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotations.support;
+
+import org.jboss.beans.metadata.api.annotations.Constructor;
+import org.jboss.beans.metadata.api.annotations.InstallMethod;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class RGBDemander
+{
+ @Red @Green private RGBSupplier rg;
+ private RGBSupplier rb;
+ private RGBSupplier gb;
+ private RGBSupplier rgb;
+
+ @Constructor
+ public RGBDemander(@Green @Blue RGBSupplier gb)
+ {
+ this.gb = gb;
+ }
+
+ public RGBSupplier getRb()
+ {
+ return rb;
+ }
+
+ @Red @Blue
+ public void setRb(RGBSupplier rb)
+ {
+ this.rb = rb;
+ }
+
+ public RGBSupplier getGb()
+ {
+ return gb;
+ }
+
+ public void setGb(RGBSupplier gb)
+ {
+ this.gb = gb;
+ }
+
+ @InstallMethod
+ public void install(@Red @Green @Blue RGBSupplier rgb)
+ {
+ this.rgb = rgb;
+ }
+
+ public RGBSupplier getRgb()
+ {
+ return rgb;
+ }
+
+ public RGBSupplier getRg()
+ {
+ return rg;
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBSupplier.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBSupplier.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/RGBSupplier.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotations.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Red
+ at Green
+ at Blue
+public class RGBSupplier
+{
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Red.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Red.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/Red.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotations.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+public @interface Red
+{
+}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AbstractRunAnnotationsTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AbstractRunAnnotationsTest.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AbstractRunAnnotationsTest.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -86,7 +86,7 @@
protected void runAnnotationsOnClass(Class<?> clazz, BeanAccessMode mode) throws Throwable
{
- runAnnotations(clazz, null);
+ runAnnotations(clazz, null, mode);
}
protected <T> void runAnnotations(Class<T> clazz, T target) throws Throwable
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -21,13 +21,14 @@
*/
package org.jboss.test.kernel.annotations.test;
+import junit.framework.Test;
import junit.framework.TestSuite;
-import junit.framework.Test;
import junit.textui.TestRunner;
+import org.jboss.test.kernel.annotations.test.factory.AnnotationFactoryTestSuite;
+import org.jboss.test.kernel.annotations.test.field.AnnotationFieldTestSuite;
+import org.jboss.test.kernel.annotations.test.inheritance.AnnotationsInheritanceTestSuite;
import org.jboss.test.kernel.annotations.test.override.AnnotationsOverrideTestSuite;
-import org.jboss.test.kernel.annotations.test.inheritance.AnnotationsInheritanceTestSuite;
-import org.jboss.test.kernel.annotations.test.field.AnnotationFieldTestSuite;
-import org.jboss.test.kernel.annotations.test.factory.AnnotationFactoryTestSuite;
+import org.jboss.test.kernel.annotations.test.wb.WBTestSuite;
/**
* Annotations tests.
@@ -50,6 +51,7 @@
suite.addTest(AnnotationsInheritanceTestSuite.suite());
suite.addTest(AnnotationFieldTestSuite.suite());
suite.addTest(AnnotationFactoryTestSuite.suite());
+ suite.addTest(WBTestSuite.suite());
return suite;
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/AnnotationsMatchingTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/AnnotationsMatchingTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/AnnotationsMatchingTestCase.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotations.test.wb;
+
+import junit.framework.Test;
+import org.jboss.kernel.plugins.annotations.AnnotationPlugin;
+import org.jboss.kernel.plugins.annotations.BasicBeanAnnotationAdapter;
+import org.jboss.kernel.plugins.annotations.BeanAnnotationAdapter;
+import org.jboss.kernel.plugins.annotations.wb.AnnotationsAnnotationPluginFactory;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.kernel.annotations.support.Blue;
+import org.jboss.test.kernel.annotations.support.Green;
+import org.jboss.test.kernel.annotations.support.Red;
+import org.jboss.test.kernel.annotations.support.RGBSupplier;
+import org.jboss.test.kernel.annotations.support.RGBDemander;
+import org.jboss.test.kernel.annotations.test.AbstractBeanAnnotationAdapterTest;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.info.spi.BeanAccessMode;
+
+/**
+ * WB annotations matching tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsMatchingTestCase extends AbstractBeanAnnotationAdapterTest
+{
+ public AnnotationsMatchingTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(AnnotationsMatchingTestCase.class);
+ }
+
+ protected BeanAnnotationAdapter getBeanAnnotationAdapterClass()
+ {
+ BasicBeanAnnotationAdapter basic = BasicBeanAnnotationAdapter.INSTANCE;
+
+ // injection
+ AnnotationPlugin redInjection = AnnotationsAnnotationPluginFactory.createPropertyInjectionPlugin(Red.class);
+ basic.addAnnotationPlugin(redInjection);
+ redInjection = AnnotationsAnnotationPluginFactory.createFieldInjectionPlugin(Red.class);
+ basic.addAnnotationPlugin(redInjection);
+
+ AnnotationPlugin greenInjection = AnnotationsAnnotationPluginFactory.createPropertyInjectionPlugin(Green.class);
+ basic.addAnnotationPlugin(greenInjection);
+ greenInjection = AnnotationsAnnotationPluginFactory.createFieldInjectionPlugin(Green.class);
+ basic.addAnnotationPlugin(greenInjection);
+
+ AnnotationPlugin blueInjection = AnnotationsAnnotationPluginFactory.createPropertyInjectionPlugin(Blue.class);
+ basic.addAnnotationPlugin(blueInjection);
+ blueInjection = AnnotationsAnnotationPluginFactory.createFieldInjectionPlugin(Blue.class);
+ basic.addAnnotationPlugin(blueInjection);
+
+ // class
+ AnnotationPlugin redSupply = AnnotationsAnnotationPluginFactory.createClassPlugin(Red.class);
+ basic.addAnnotationPlugin(redSupply);
+ AnnotationPlugin greenSupply = AnnotationsAnnotationPluginFactory.createClassPlugin(Green.class);
+ basic.addAnnotationPlugin(greenSupply);
+ AnnotationPlugin blueSupply = AnnotationsAnnotationPluginFactory.createClassPlugin(Blue.class);
+ basic.addAnnotationPlugin(blueSupply);
+
+ return basic;
+ }
+
+ public void testAnnotationsInjection() throws Throwable
+ {
+ KernelController controller = getController();
+ controller.install(new AbstractBeanMetaData("supplier", RGBSupplier.class.getName()));
+
+ runAnnotationsOnClass(RGBDemander.class, BeanAccessMode.ALL);
+ }
+
+ protected void doTestAfterInstall(Object target)
+ {
+ RGBDemander demander = (RGBDemander)target;
+ assertNotNull(demander.getRg());
+ assertNotNull(demander.getGb());
+ assertNotNull(demander.getRb());
+ assertNotNull(demander.getRgb());
+ }
+}
\ No newline at end of file
Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/WBTestSuite.java (from rev 72459, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/field/AnnotationFieldTestSuite.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/WBTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/wb/WBTestSuite.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotations.test.wb;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * WB annotations tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WBTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("WB Tests");
+
+ suite.addTest(AnnotationsMatchingTestCase.suite());
+
+ return suite;
+ }
+}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/SetDemandTransformer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/SetDemandTransformer.java 2008-04-21 13:45:29 UTC (rev 72490)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/SetDemandTransformer.java 2008-04-21 14:28:26 UTC (rev 72491)
@@ -54,5 +54,10 @@
{
return set.contains(other);
}
+
+ public boolean needExactMatch()
+ {
+ return false;
+ }
}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list