[jboss-cvs] JBossAS SVN: r62540 - in projects/microcontainer/trunk/kernel/src: main/org/jboss/beans/metadata/plugins/annotations and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 25 09:22:46 EDT 2007
Author: alesj
Date: 2007-04-25 09:22:46 -0400 (Wed, 25 Apr 2007)
New Revision: 62540
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/CallbackCreatorUtil.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/AnnotationDependencyBuilder.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackDependencyBuilderListItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactoryAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackInfo.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallCallbackDependencyBuilderListItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallCallbackDependencyBuilderListItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractAttributeInfo.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AttributeInfo.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/BasicCollectionCallbackItemFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreator.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreatorCallbackItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MethodAttributeInfo.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PropertyAttributeInfo.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationAdditionCallbackTestObjectImpl.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCardinalityCallbackTestObjectImpl.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCollectionCallbackTestObjectImpl.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObjectImpl.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java
Removed:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InjectFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/DependencyFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/BadCallbackTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
Log:
Annotation callback handling.
Fixed CollectionCallback[Factory].
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -31,13 +31,8 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.kernel.plugins.config.Configurator;
import org.jboss.kernel.plugins.dependency.CallbackDependencyItem;
-import org.jboss.kernel.plugins.dependency.ClassAttributeCallbackItem;
-import org.jboss.kernel.plugins.dependency.ClassSingleCallbackItem;
-import org.jboss.kernel.plugins.dependency.CollectionCallbackItemFactory;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
import org.jboss.util.JBossStringBuilder;
/**
@@ -158,22 +153,6 @@
*/
protected abstract void addCallback(MetaDataVisitor visitor, CallbackItem callback);
- @SuppressWarnings("unchecked")
- protected CallbackItem createCollectionCallback(TypeInfo info, KernelControllerContext context, String attribute)
- {
- if (info instanceof ClassInfo && ((ClassInfo)info).getActualTypeArguments() != null)
- {
- ClassInfo ci = (ClassInfo)info;
- TypeInfo[] typeInfos = ci.getActualTypeArguments();
- if (typeInfos.length != 1)
- throw new IllegalArgumentException("Illegal size of actual type arguments: " + info);
- Class clazz = typeInfos[0].getType();
- return CollectionCallbackItemFactory.createCollectionCallbackItem(info.getType(), clazz, whenRequired, dependentState, cardinality, context, attribute);
- }
- else
- throw new IllegalArgumentException("Unable to determine collection element class type: " + this);
- }
-
public void describeVisit(MetaDataVisitor vistor)
{
try
@@ -184,35 +163,17 @@
{
ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData());
PropertyInfo pi = Configurator.resolveProperty(log.isTraceEnabled(), context.getBeanInfo(), cl, property, signature);
-
- TypeInfo info;
- if (pi.getSetter() != null)
- info = pi.getSetter().getParameterTypes()[0];
- else
- throw new IllegalArgumentException("No setter for property: " + pi);
-
- if (info.isCollection())
- callback = createCollectionCallback(info, context, property);
- else
- callback = new ClassAttributeCallbackItem(info.getType(), whenRequired, dependentState, cardinality, context, property);
+ callback = CallbackCreatorUtil.createCallback(context, pi, whenRequired, dependentState, cardinality);
}
else if (methodName != null)
{
MethodInfo mi = Configurator.findMethodInfo(getClassInfo(context), methodName, new String[]{signature});
- // signature matches one parameter
- TypeInfo info = mi.getParameterTypes()[0];
- if (info.isCollection())
- {
- callback = createCollectionCallback(info, context, methodName);
- }
- else
- {
- Class clazz = info.getType();
- callback = new ClassSingleCallbackItem(clazz, whenRequired, dependentState, cardinality, context, methodName, clazz.getName());
- }
+ callback = CallbackCreatorUtil.createCallback(context, mi, whenRequired, dependentState, cardinality);
}
else
throw new IllegalArgumentException("Illegal usage - not property or method:" + this);
+
+ // add callback
addCallback(vistor, callback);
// demand name is Class in this case
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/CallbackCreatorUtil.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/CallbackCreatorUtil.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/CallbackCreatorUtil.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,195 @@
+/*
+* 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.beans.metadata.plugins;
+
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.dependency.AttributeInfo;
+import org.jboss.kernel.plugins.dependency.BasicCollectionCallbackItemFactory;
+import org.jboss.kernel.plugins.dependency.ClassAttributeCallbackItem;
+import org.jboss.kernel.plugins.dependency.ClassSingleCallbackItem;
+import org.jboss.kernel.plugins.dependency.CollectionCallbackItemFactory;
+import org.jboss.kernel.plugins.dependency.MethodAttributeInfo;
+import org.jboss.kernel.plugins.dependency.PropertyAttributeInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.logging.Logger;
+import org.jboss.reflect.plugins.introspection.ReflectionUtils;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * CallbackItem creator util.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CallbackCreatorUtil
+{
+ protected static Logger log;
+ protected static CollectionCallbackItemFactory factory;
+
+ // layz log
+ protected static Logger getLog()
+ {
+ if (log == null)
+ log = Logger.getLogger(CallbackCreatorUtil.class);
+ return log;
+ }
+
+ /**
+ * Create collection callback item.
+ *
+ * @param info type info
+ * @param context owner context
+ * @param whenRequired when required state
+ * @param attribute attribute
+ * @param dependentState dependent state
+ * @param cardinality cardinality
+ * @return collection callback item
+ */
+ @SuppressWarnings("unchecked")
+ private static CallbackItem<Class> createCollectionCallback(
+ TypeInfo info,
+ KernelControllerContext context,
+ AttributeInfo attribute,
+ ControllerState whenRequired,
+ ControllerState dependentState,
+ Cardinality cardinality)
+ {
+ if (info instanceof ClassInfo && ((ClassInfo)info).getActualTypeArguments() != null)
+ {
+ ClassInfo ci = (ClassInfo)info;
+ TypeInfo[] typeInfos = ci.getActualTypeArguments();
+ if (typeInfos.length != 1)
+ throw new IllegalArgumentException("Illegal size of actual type arguments: " + info);
+ Class clazz = typeInfos[0].getType();
+ return getCollectionFactory().createCollectionCallbackItem(info.getType(), clazz, whenRequired, dependentState, cardinality, context, attribute);
+ }
+ else
+ throw new IllegalArgumentException("Unable to determine collection element class type: " + info);
+ }
+
+ /**
+ * Create callback item from AttrbuteInfo.
+ *
+ * @param context owner context
+ * @param ai attribute info
+ * @param whenRequired when required state
+ * @param dependentState dependent state
+ * @param cardinality cardinality
+ * @return callback item
+ */
+ public static CallbackItem<Class> createCallback(
+ KernelControllerContext context,
+ AttributeInfo ai,
+ ControllerState whenRequired,
+ ControllerState dependentState,
+ Cardinality cardinality)
+ {
+ if (ai.isValid() == false)
+ throw new IllegalArgumentException("Not a valid attribute info: " + ai);
+
+ TypeInfo info = ai.getType();
+ if (info.isCollection())
+ return createCollectionCallback(info, context, ai, whenRequired, dependentState, cardinality);
+ else if (ai.isProperty())
+ return new ClassAttributeCallbackItem(info.getType(), whenRequired, dependentState, cardinality, context, ai.getName());
+ else
+ {
+ Class clazz = info.getType();
+ return new ClassSingleCallbackItem(clazz, whenRequired, dependentState, cardinality, context, ai.getName(), clazz.getName());
+ }
+ }
+
+ /**
+ * Create callback item from PropertyInfo.
+ *
+ * @param context owner context
+ * @param pi property info
+ * @param whenRequired when required state
+ * @param dependentState dependent state
+ * @param cardinality cardinality
+ * @return callback item
+ */
+ public static CallbackItem<Class> createCallback(
+ KernelControllerContext context,
+ PropertyInfo pi,
+ ControllerState whenRequired,
+ ControllerState dependentState,
+ Cardinality cardinality)
+ {
+ return createCallback(context, new PropertyAttributeInfo(pi), whenRequired, dependentState, cardinality);
+ }
+
+ /**
+ * Create callback item from MethodInfo.
+ *
+ * @param context owner context
+ * @param mi method info
+ * @param whenRequired when required state
+ * @param dependentState dependent state
+ * @param cardinality cardinality
+ * @return callback item
+ */
+ public static CallbackItem<Class> createCallback(
+ KernelControllerContext context,
+ MethodInfo mi,
+ ControllerState whenRequired,
+ ControllerState dependentState,
+ Cardinality cardinality)
+ {
+ return createCallback(context, new MethodAttributeInfo(mi), whenRequired, dependentState, cardinality);
+ }
+
+ public static CollectionCallbackItemFactory getCollectionFactory()
+ {
+ if (factory == null)
+ {
+ try
+ {
+ FactoryLookup lookup = new FactoryLookup();
+ String factoryClassName = AccessController.doPrivileged(lookup);
+ return (CollectionCallbackItemFactory)ReflectionUtils.newInstance(factoryClassName);
+ }
+ catch (Throwable t)
+ {
+ getLog().warn("Exception while creating CollectionCallbackItemFactory, using basic one instead.", t);
+ factory = new BasicCollectionCallbackItemFactory();
+ }
+ }
+ return factory;
+ }
+
+ private static class FactoryLookup implements PrivilegedExceptionAction<String>
+ {
+ public String run() throws Exception
+ {
+ return System.getProperty("org.jboss.dependency.collectionCallbackItemFactory", BasicCollectionCallbackItemFactory.class.getName());
+ }
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/AnnotationDependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/AnnotationDependencyBuilder.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/AnnotationDependencyBuilder.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -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.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.annotations.DependencyFactory;
+import org.jboss.beans.metadata.spi.annotations.DependencyFactoryLookup;
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.classadapter.spi.DependencyBuilder;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Create dependencies from annotations.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationDependencyBuilder implements DependencyBuilder
+{
+ protected static Class[] expectedAnnotations =
+ {
+ Callback.class,
+ Install.class,
+ Uninstall.class
+ };
+
+ @SuppressWarnings("unchecked")
+ protected Class<? extends Annotation>[] getExpectedAnnotations()
+ {
+ return expectedAnnotations;
+ }
+
+ public List<DependencyBuilderListItem> getDependencies(ClassAdapter classAdapter, MetaData metaData)
+ {
+ ClassInfo classInfo = classAdapter.getClassInfo();
+ if (classInfo != null)
+ {
+ List<DependencyBuilderListItem> list = new ArrayList<DependencyBuilderListItem>();
+ MethodInfo[] methods = classInfo.getDeclaredMethods();
+ if (methods != null)
+ {
+ for(MethodInfo mi : methods)
+ {
+ for(Class<? extends Annotation> annotation : getExpectedAnnotations())
+ {
+ checkAnnotation(mi, annotation, list);
+ }
+ }
+ }
+ return list;
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void checkAnnotation(MethodInfo mi, Class<? extends Annotation> annotation, List<DependencyBuilderListItem> list)
+ {
+ Annotation callback = mi.getUnderlyingAnnotation(annotation);
+ if (callback != null)
+ {
+ DependencyFactoryLookup dfl = callback.annotationType().getAnnotation(DependencyFactoryLookup.class);
+ if (dfl == null)
+ throw new IllegalArgumentException("Illegal annotation type - no DependencyFactoryLookup meta data.");
+ DependencyFactory df = createDependencyFactory(dfl);
+ list.add(df.createDependency(callback, mi));
+ }
+ }
+
+ protected DependencyFactory createDependencyFactory(DependencyFactoryLookup dfl)
+ {
+ try
+ {
+ return dfl.value().newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new Error("Cannot create DependencyFactory: " + e);
+ }
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackDependencyBuilderListItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackDependencyBuilderListItem.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackDependencyBuilderListItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,93 @@
+/*
+* 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.beans.metadata.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.CallbackCreatorUtil;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.kernel.plugins.dependency.AttributeInfo;
+import org.jboss.kernel.plugins.dependency.CallbackDependencyItem;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Callback dependency list item from Callback info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CallbackDependencyBuilderListItem extends JBossObject implements DependencyBuilderListItem<KernelControllerContext>
+{
+ protected CallbackInfo info;
+ protected AttributeInfo attribute;
+
+ protected CallbackDependencyBuilderListItem(CallbackInfo info, AttributeInfo attribute)
+ {
+ if (info == null)
+ throw new IllegalArgumentException("Null callback info!");
+ if (attribute == null)
+ throw new IllegalArgumentException("Null attribute info!");
+ this.info = info;
+ this.attribute = attribute;
+ }
+
+ public void addDependency(KernelControllerContext ctx)
+ {
+ CallbackItem<Class> callback = createCallbackItem(ctx);
+ if (callback != null)
+ {
+ DependencyInfo dependencyInfo = ctx.getDependencyInfo();
+ addCallback(dependencyInfo, callback);
+ if (info.getCardinality() != null)
+ {
+ CallbackDependencyItem item = new CallbackDependencyItem(ctx.getName(), callback.getIDependOn(), info.getWhenRequired(), info.getDependentState(), info.getCardinality());
+ dependencyInfo.addIDependOn(item);
+ }
+ }
+ }
+
+ /**
+ * Create callback item from attribute info.
+ *
+ * @param ctx current context
+ * @return callback item
+ */
+ protected CallbackItem<Class> createCallbackItem(KernelControllerContext ctx)
+ {
+ return CallbackCreatorUtil.createCallback(ctx, attribute, info.getWhenRequired(), info.getDependentState(), info.getCardinality());
+ }
+
+ /**
+ * Add install or uninstall callback item.
+ *
+ * @param dependencyInfo dependency info
+ * @param callback callback item
+ */
+ protected abstract void addCallback(DependencyInfo dependencyInfo, CallbackItem<Class> callback);
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("callback=").append(info);
+ buffer.append("attribute=").append(attribute);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactory.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactory.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -21,19 +21,26 @@
*/
package org.jboss.beans.metadata.plugins.annotations;
+import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.beans.metadata.spi.annotations.DependencyFactory;
import org.jboss.classadapter.spi.DependencyBuilderListItem;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.MethodInfo;
/**
* Create dependency list item from Callback info.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class CallbackFactory implements DependencyFactory<Callback>
+public class CallbackFactory extends CallbackFactoryAdapter implements DependencyFactory<Callback>
{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Callback annotation)
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Callback annotation, MethodInfo method)
{
- return null; // todo
+ return getDependency(new CallbackInfo(annotation), method);
}
+
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Callback annotation, PropertyInfo property)
+ {
+ return getDependency(new CallbackInfo(annotation), property);
+ }
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactoryAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactoryAdapter.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactoryAdapter.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,56 @@
+/*
+* 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.beans.metadata.plugins.annotations;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
+import org.jboss.kernel.plugins.dependency.AttributeInfo;
+import org.jboss.kernel.plugins.dependency.MethodAttributeInfo;
+import org.jboss.kernel.plugins.dependency.PropertyAttributeInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Create dependency list item from Callback info holder - via adapter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CallbackFactoryAdapter
+{
+ protected DependencyBuilderListItem<KernelControllerContext> getDependency(CallbackInfo info, MethodInfo method)
+ {
+ return getDependency(info, new MethodAttributeInfo(method));
+ }
+
+ protected DependencyBuilderListItem<KernelControllerContext> getDependency(CallbackInfo info, PropertyInfo property)
+ {
+ return getDependency(info, new PropertyAttributeInfo(property));
+ }
+
+ protected DependencyBuilderListItem<KernelControllerContext> getDependency(CallbackInfo info, AttributeInfo attribute)
+ {
+ if (info.isInstallPhase())
+ return new InstallCallbackDependencyBuilderListItem(info, attribute);
+ else
+ return new UninstallCallbackDependencyBuilderListItem(info, attribute);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackInfo.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackInfo.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackInfo.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,130 @@
+/*
+* 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.beans.metadata.plugins.annotations;
+
+import java.io.Serializable;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Callback info holder.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+class CallbackInfo extends JBossObject implements Serializable
+{
+ /* The cardinality */
+ protected Cardinality cardinality;
+
+ /* When required state */
+ protected ControllerState whenRequired;
+
+ /* Dependent state */
+ protected ControllerState dependentState;
+
+ /* Is install phase */
+ protected boolean isInstallPhase;
+
+ CallbackInfo(Callback callback)
+ {
+ this(callback.cardinality(), callback.whenRequired(), callback.dependentState(), CallbackType.INSTALL.equals(callback.type()));
+ }
+
+ CallbackInfo(Install callback)
+ {
+ this(callback.cardinality(), callback.whenRequired(), callback.dependentState(), true);
+ }
+
+ CallbackInfo(Uninstall callback)
+ {
+ this(callback.cardinality(), callback.whenRequired(), callback.dependentState(), false);
+ }
+
+ private CallbackInfo(String cardinality, String whenRequired, String dependentState, boolean isInstallPhase)
+ {
+ this(
+ cardinality == null || cardinality.length() == 0 ? null : Cardinality.toCardinality(cardinality),
+ new ControllerState(whenRequired),
+ new ControllerState(dependentState),
+ isInstallPhase
+ );
+ }
+
+ private CallbackInfo(Cardinality cardinality, ControllerState whenRequired, ControllerState dependentState, boolean isInstallPhase)
+ {
+ this.cardinality = cardinality;
+ this.whenRequired = whenRequired;
+ this.dependentState = dependentState;
+ this.isInstallPhase = isInstallPhase;
+ }
+
+ /**
+ * Get the cardinality.
+ *
+ * @return cardinality
+ */
+ public Cardinality getCardinality()
+ {
+ return cardinality;
+ }
+
+ /**
+ * Get when required state.
+ *
+ * @return when required state
+ */
+ public ControllerState getWhenRequired()
+ {
+ return whenRequired;
+ }
+
+ /**
+ * Get dependent state.
+ *
+ * @return dependent state
+ */
+ public ControllerState getDependentState()
+ {
+ return dependentState;
+ }
+
+ /**
+ * Is install or uninstall.
+ *
+ * @return true for install, false for uninstall
+ */
+ public boolean isInstallPhase()
+ {
+ return isInstallPhase;
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("isInstallPhase=").append(isInstallPhase);
+ buffer.append(" cardinality=").append(cardinality);
+ buffer.append(" whenRequired=").append(whenRequired);
+ buffer.append(" dependentState=").append(dependentState);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InjectFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InjectFactory.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InjectFactory.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -21,9 +21,11 @@
*/
package org.jboss.beans.metadata.plugins.annotations;
+import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.beans.metadata.spi.annotations.DependencyFactory;
import org.jboss.classadapter.spi.DependencyBuilderListItem;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.MethodInfo;
/**
* Create injection dependency.
@@ -32,8 +34,13 @@
*/
public class InjectFactory implements DependencyFactory<Inject>
{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Inject annotation)
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Inject annotation, MethodInfo method)
{
- return null; // todo
+ return null;
}
+
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Inject annotation, PropertyInfo property)
+ {
+ return null;
+ }
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallCallbackDependencyBuilderListItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallCallbackDependencyBuilderListItem.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallCallbackDependencyBuilderListItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,44 @@
+/*
+* 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.beans.metadata.plugins.annotations;
+
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.kernel.plugins.dependency.AttributeInfo;
+
+/**
+ * Install callback dependency list item from Callback info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstallCallbackDependencyBuilderListItem extends CallbackDependencyBuilderListItem
+{
+ public InstallCallbackDependencyBuilderListItem(CallbackInfo info, AttributeInfo attribute)
+ {
+ super(info, attribute);
+ }
+
+ protected void addCallback(DependencyInfo dependencyInfo, CallbackItem<Class> callback)
+ {
+ dependencyInfo.addInstallItem(callback);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallFactory.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallFactory.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -21,19 +21,26 @@
*/
package org.jboss.beans.metadata.plugins.annotations;
+import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.beans.metadata.spi.annotations.DependencyFactory;
import org.jboss.classadapter.spi.DependencyBuilderListItem;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.MethodInfo;
/**
* Create dependency list item from Install info.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class InstallFactory implements DependencyFactory<Install>
+public class InstallFactory extends CallbackFactoryAdapter implements DependencyFactory<Install>
{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Install annotation)
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Install annotation, MethodInfo method)
{
- return null; // todo
+ return getDependency(new CallbackInfo(annotation), method);
}
+
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Install annotation, PropertyInfo property)
+ {
+ return getDependency(new CallbackInfo(annotation), property);
+ }
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallCallbackDependencyBuilderListItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallCallbackDependencyBuilderListItem.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallCallbackDependencyBuilderListItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,44 @@
+/*
+* 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.beans.metadata.plugins.annotations;
+
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.kernel.plugins.dependency.AttributeInfo;
+
+/**
+ * Install callback dependency list item from Callback info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class UninstallCallbackDependencyBuilderListItem extends CallbackDependencyBuilderListItem
+{
+ public UninstallCallbackDependencyBuilderListItem(CallbackInfo info, AttributeInfo attribute)
+ {
+ super(info, attribute);
+ }
+
+ protected void addCallback(DependencyInfo dependencyInfo, CallbackItem<Class> callback)
+ {
+ dependencyInfo.addUninstallItem(callback);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallFactory.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallFactory.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -21,19 +21,26 @@
*/
package org.jboss.beans.metadata.plugins.annotations;
+import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.beans.metadata.spi.annotations.DependencyFactory;
import org.jboss.classadapter.spi.DependencyBuilderListItem;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.MethodInfo;
/**
* Create dependency list item from Uninstall info.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class UninstallFactory implements DependencyFactory<Uninstall>
+public class UninstallFactory extends CallbackFactoryAdapter implements DependencyFactory<Uninstall>
{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Uninstall annotation)
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Uninstall annotation, MethodInfo method)
{
- return null; // todo
+ return getDependency(new CallbackInfo(annotation), method);
}
+
+ public DependencyBuilderListItem<KernelControllerContext> createDependency(Uninstall annotation, PropertyInfo property)
+ {
+ return getDependency(new CallbackInfo(annotation), property);
+ }
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/DependencyFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/DependencyFactory.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/DependencyFactory.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -23,21 +23,34 @@
import java.lang.annotation.Annotation;
+import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.classadapter.spi.DependencyBuilderListItem;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.MethodInfo;
/**
* Dependecy factory contract.
- *
+ *
+ * @param <T> expected annotation type
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
public interface DependencyFactory<T extends Annotation>
{
/**
- * Create dependency builder item.
+ * Create dependency builder item from method.
*
* @param annotation current annotation
+ * @param method current method
* @return dependency builder item
*/
- DependencyBuilderListItem<KernelControllerContext> createDependency(T annotation);
+ DependencyBuilderListItem<KernelControllerContext> createDependency(T annotation, MethodInfo method);
+
+ /**
+ * Create dependency builder item from property.
+ *
+ * @param annotation current annotation
+ * @param property current property
+ * @return dependency builder item
+ */
+ DependencyBuilderListItem<KernelControllerContext> createDependency(T annotation, PropertyInfo property);
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractAttributeInfo.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractAttributeInfo.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractAttributeInfo.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,53 @@
+/*
+* 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.dependency;
+
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Abstract attribute info.
+ *
+ * @param <T> expected info type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractAttributeInfo<T> extends JBossObject implements AttributeInfo
+{
+ protected T info;
+
+ public AbstractAttributeInfo(T info)
+ {
+ if (info == null)
+ throw new IllegalArgumentException("Null info argument!");
+ this.info = info;
+ }
+
+ public boolean isValid()
+ {
+ return (getType() != null);
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("info=").append(info);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AttributeInfo.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AttributeInfo.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AttributeInfo.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,60 @@
+/*
+* 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.dependency;
+
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * PropertyInfo or MethodInfo abstraction.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface AttributeInfo
+{
+ /**
+ * Is property.
+ *
+ * @return true for PropertyInfo, false otherwise
+ */
+ boolean isProperty();
+
+ /**
+ * Get the name.
+ *
+ * @return attribute name
+ */
+ String getName();
+
+ /**
+ * Get attribute type.
+ *
+ * @return type info
+ */
+ TypeInfo getType();
+
+ /**
+ * Is valid.
+ *
+ * @return true if valid, false otherwise
+ */
+ boolean isValid();
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/BasicCollectionCallbackItemFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/BasicCollectionCallbackItemFactory.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/BasicCollectionCallbackItemFactory.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,70 @@
+/*
+* 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.dependency;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * Basic collection callback item factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BasicCollectionCallbackItemFactory implements CollectionCallbackItemFactory
+{
+ public CollectionCallbackItem createCollectionCallbackItem(
+ Class<? extends Collection> parameterClass,
+ Class name,
+ InvokeDispatchContext context,
+ AttributeInfo attribute)
+ {
+ return createCollectionCallbackItem(parameterClass, name, null, null, null, context, attribute);
+ }
+
+ public CollectionCallbackItem createCollectionCallbackItem(
+ Class<? extends Collection> parameterClass,
+ Class name,
+ ControllerState whenRequired,
+ ControllerState dependentState,
+ Cardinality cardinality,
+ InvokeDispatchContext context,
+ AttributeInfo attribute)
+ {
+ if (parameterClass == null)
+ throw new IllegalArgumentException("Null parameter class!");
+
+ if (parameterClass.isAssignableFrom(ArrayList.class))
+ return new ListCallbackItem(name, whenRequired, dependentState, cardinality, context, attribute);
+ else if (parameterClass.isAssignableFrom(HashSet.class))
+ return new SetCallbackItem(name, whenRequired, dependentState, cardinality, context, attribute);
+ else if (parameterClass.isAssignableFrom(LinkedList.class))
+ return new QueueCallbackItem(name, whenRequired, dependentState, cardinality, context, attribute);
+ else
+ throw new IllegalArgumentException("No matching callback impl for parameter type: " + parameterClass);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -24,10 +24,12 @@
import java.util.Collection;
import java.util.Set;
+import org.jboss.dependency.plugins.OwnerCallbackItem;
import org.jboss.dependency.spi.Cardinality;
import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
@@ -38,16 +40,23 @@
* @param <T> expected collection type
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public abstract class CollectionCallbackItem<T extends Collection<Object>> extends ClassAttributeCallbackItem
+public abstract class CollectionCallbackItem<T extends Collection<Object>> extends OwnerCallbackItem<Class, InvokeDispatchContext>
{
- public CollectionCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
+ protected Cardinality cardinality;
+ protected AttributeInfo attribute;
+
+ public CollectionCallbackItem(Class name, InvokeDispatchContext owner, AttributeInfo attribute)
{
- super(name, owner, attribute);
+ this(name, null, null, null, owner, attribute);
}
- public CollectionCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, String attribute)
+ public CollectionCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, AttributeInfo attribute)
{
- super(name, whenRequired, dependentState, cardinality, context, attribute);
+ super(name, whenRequired, dependentState, context);
+ if (attribute == null)
+ throw new IllegalArgumentException("Null attribute!");
+ this.attribute = attribute;
+ this.cardinality = cardinality;
}
/**
@@ -84,6 +93,22 @@
throw new IllegalArgumentException("Cannot execute Collection call back - controller not KernelController instance.");
}
+ protected void execute(T holder) throws Throwable
+ {
+ if (attribute.isProperty())
+ owner.set(attribute.getName(), holder);
+ else
+ owner.invoke(attribute.getName(), new Object[]{holder}, new String[]{attribute.getType().getName()});
+ }
+
+ protected DependencyItem createDependencyItem(ControllerContext owner)
+ {
+ if (cardinality != null)
+ return new CallbackDependencyItem(owner.getName(), getIDependOn(), whenRequired, dependentState, cardinality);
+ else
+ return null;
+ }
+
public void ownerCallback(Controller controller, boolean isInstallPhase) throws Throwable
{
execute(fillHolder(controller));
@@ -97,4 +122,5 @@
execute(holder);
addDependency(controller, context, isInstallPhase);
}
+
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -21,10 +21,7 @@
*/
package org.jboss.kernel.plugins.dependency;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
import org.jboss.dependency.spi.Cardinality;
import org.jboss.dependency.spi.ControllerState;
@@ -35,7 +32,7 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class CollectionCallbackItemFactory
+public interface CollectionCallbackItemFactory
{
/**
* Create collection callback item for parameter class.
@@ -46,14 +43,11 @@
* @param attribute the attribute
* @return new exact collection callback item
*/
- public static CollectionCallbackItem createCollectionCallbackItem(
+ CollectionCallbackItem createCollectionCallbackItem(
Class<? extends Collection> parameterClass,
Class name,
InvokeDispatchContext context,
- String attribute)
- {
- return createCollectionCallbackItem(parameterClass, name, null, null, null, context, attribute);
- }
+ AttributeInfo attribute);
/**
* Create collection callback item for parameter class.
@@ -67,25 +61,12 @@
* @param attribute the attribute
* @return new exact collection callback item
*/
- public static CollectionCallbackItem createCollectionCallbackItem(
+ CollectionCallbackItem createCollectionCallbackItem(
Class<? extends Collection> parameterClass,
Class name,
ControllerState whenRequired,
ControllerState dependentState,
Cardinality cardinality,
InvokeDispatchContext context,
- String attribute)
- {
- if (parameterClass == null)
- throw new IllegalArgumentException("Null parameter class!");
-
- if (parameterClass.isAssignableFrom(ArrayList.class))
- return new ListCallbackItem(name, whenRequired, dependentState, cardinality, context, attribute);
- else if (parameterClass.isAssignableFrom(HashSet.class))
- return new SetCallbackItem(name, whenRequired, dependentState, cardinality, context, attribute);
- else if (parameterClass.isAssignableFrom(LinkedList.class))
- return new QueueCallbackItem(name, whenRequired, dependentState, cardinality, context, attribute);
- else
- throw new IllegalArgumentException("No matching callback impl for parameter type: " + parameterClass);
- }
+ AttributeInfo attribute);
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreator.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreator.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreator.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -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.dependency;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+
+/**
+ * Collection creator.
+ */
+public interface CollectionCreator<T extends Collection<Object>>
+{
+ /**
+ * Create new Collection instance.
+ *
+ * @return collection
+ */
+ T createCollection();
+
+ public CollectionCreator<List<Object>> LIST = new CollectionCreator<List<Object>>()
+ {
+ public List<Object> createCollection()
+ {
+ return new ArrayList<Object>();
+ }
+ };
+
+ public CollectionCreator<Set<Object>> SET = new CollectionCreator<Set<Object>>()
+ {
+ public Set<Object> createCollection()
+ {
+ return new HashSet<Object>();
+ }
+ };
+
+ public CollectionCreator<Queue<Object>> QUEUE = new CollectionCreator<Queue<Object>>()
+ {
+ public Queue<Object> createCollection()
+ {
+ return new LinkedList<Object>();
+ }
+ };
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreatorCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreatorCallbackItem.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCreatorCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,58 @@
+/*
+* 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.dependency;
+
+import java.util.Collection;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * Collection callback item using CollectionCreator.
+ *
+ * @param <T> expected collection type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CollectionCreatorCallbackItem<T extends Collection<Object>> extends CollectionCallbackItem<T>
+{
+ protected CollectionCreator<T> creator;
+
+ public CollectionCreatorCallbackItem(CollectionCreator<T> creator, Class name, InvokeDispatchContext owner, AttributeInfo attribute)
+ {
+ this(creator, name, null, null, null, owner, attribute);
+ }
+
+ public CollectionCreatorCallbackItem(CollectionCreator<T> creator, Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, AttributeInfo attribute)
+ {
+ super(name, whenRequired, dependentState, cardinality, context, attribute);
+ if (creator == null)
+ throw new IllegalArgumentException("Null creator!");
+ this.creator = creator;
+ }
+
+ protected T getCollectionParameterHolder()
+ {
+ return creator.createCollection();
+ }
+
+}
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -1,52 +0,0 @@
-/*
-* 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.dependency;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.dependency.spi.Cardinality;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
-
-/**
- * List callback item.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class ListCallbackItem extends CollectionCallbackItem<List<Object>>
-{
- public ListCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
- {
- super(name, owner, attribute);
- }
-
- public ListCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, String attribute)
- {
- super(name, whenRequired, dependentState, cardinality, context, attribute);
- }
-
- protected List<Object> getCollectionParameterHolder()
- {
- return new ArrayList<Object>();
- }
-}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,46 @@
+/*
+* 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.dependency;
+
+import java.util.List;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * List collection callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ListCallbackItem extends CollectionCreatorCallbackItem<List<Object>>
+{
+ public ListCallbackItem(Class name, InvokeDispatchContext owner, AttributeInfo attribute)
+ {
+ super(CollectionCreator.LIST, name, owner, attribute);
+ }
+
+ public ListCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, AttributeInfo attribute)
+ {
+ super(CollectionCreator.LIST, name, whenRequired, dependentState, cardinality, context, attribute);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MethodAttributeInfo.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MethodAttributeInfo.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MethodAttributeInfo.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,56 @@
+/*
+* 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.dependency;
+
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * Method attribute info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MethodAttributeInfo extends AbstractAttributeInfo<MethodInfo>
+{
+ public MethodAttributeInfo(MethodInfo methodInfo)
+ {
+ super(methodInfo);
+ }
+
+ public boolean isProperty()
+ {
+ return false;
+ }
+
+ public String getName()
+ {
+ return info.getName();
+ }
+
+ public TypeInfo getType()
+ {
+ TypeInfo[] typeInfos = info.getParameterTypes();
+ if (typeInfos == null || typeInfos.length != 1)
+ throw new IllegalArgumentException("Null or illegal length parameter types: " + info);
+ return typeInfos[0];
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PropertyAttributeInfo.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PropertyAttributeInfo.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PropertyAttributeInfo.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,58 @@
+/*
+* 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.dependency;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * Property attribute info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyAttributeInfo extends AbstractAttributeInfo<PropertyInfo>
+{
+ public PropertyAttributeInfo(PropertyInfo propertyInfo)
+ {
+ super(propertyInfo);
+ }
+
+ public boolean isProperty()
+ {
+ return true;
+ }
+
+ public String getName()
+ {
+ return info.getName();
+ }
+
+ public TypeInfo getType()
+ {
+ return info.getType();
+ }
+
+ public boolean isValid()
+ {
+ return (info.getSetter() != null && super.isValid());
+ }
+}
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -1,52 +0,0 @@
-/*
-* 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.dependency;
-
-import java.util.LinkedList;
-import java.util.Queue;
-
-import org.jboss.dependency.spi.Cardinality;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
-
-/**
- * Queue callback item.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class QueueCallbackItem extends CollectionCallbackItem<Queue<Object>>
-{
- public QueueCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
- {
- super(name, owner, attribute);
- }
-
- public QueueCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, String attribute)
- {
- super(name, whenRequired, dependentState, cardinality, context, attribute);
- }
-
- protected Queue<Object> getCollectionParameterHolder()
- {
- return new LinkedList<Object>();
- }
-}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,46 @@
+/*
+* 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.dependency;
+
+import java.util.Queue;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * Queue collection callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class QueueCallbackItem extends CollectionCreatorCallbackItem<Queue<Object>>
+{
+ public QueueCallbackItem(Class name, InvokeDispatchContext owner, AttributeInfo attribute)
+ {
+ super(CollectionCreator.QUEUE, name, owner, attribute);
+ }
+
+ public QueueCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, AttributeInfo attribute)
+ {
+ super(CollectionCreator.QUEUE, name, whenRequired, dependentState, cardinality, context, attribute);
+ }
+}
Deleted: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -1,52 +0,0 @@
-/*
-* 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.dependency;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.dependency.spi.Cardinality;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
-
-/**
- * Set callback item.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class SetCallbackItem extends CollectionCallbackItem<Set<Object>>
-{
- public SetCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
- {
- super(name, owner, attribute);
- }
-
- public SetCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, String attribute)
- {
- super(name, whenRequired, dependentState, cardinality, context, attribute);
- }
-
- protected Set<Object> getCollectionParameterHolder()
- {
- return new HashSet<Object>();
- }
-}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,46 @@
+/*
+* 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.dependency;
+
+import java.util.Set;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * Set collection callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SetCallbackItem extends CollectionCreatorCallbackItem<Set<Object>>
+{
+ public SetCallbackItem(Class name, InvokeDispatchContext owner, AttributeInfo attribute)
+ {
+ super(CollectionCreator.SET, name, owner, attribute);
+ }
+
+ public SetCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, AttributeInfo attribute)
+ {
+ super(CollectionCreator.SET, name, whenRequired, dependentState, cardinality, context, attribute);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.xml 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.AnnotationAdditionCallbackTestObjectImpl" />
+
+ <bean name="tester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+ <bean name="tester2" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+ <bean name="tester3" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml 2007-04-25 13:22:46 UTC (rev 62540)
@@ -4,7 +4,7 @@
xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObject">
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObjectImpl">
<incallback method="addTesterInterface"/>
<uncallback method="removeTesterInterface"/>
</bean>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.xml 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.AnnotationCardinalityCallbackTestObjectImpl" />
+
+ <bean name="tester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+ <bean name="tester2" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+ <bean name="tester3" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml 2007-04-25 13:22:46 UTC (rev 62540)
@@ -4,7 +4,7 @@
xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObject">
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObjectImpl">
<incallback property="testerInterfaces" cardinality="2..n" whenRequired="Create"/>
<uncallback property="testerInterfaces"/>
</bean>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.xml 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.AnnotationCollectionCallbackTestObjectImpl" />
+
+ <bean name="tester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+ <bean name="tester2" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+ <bean name="tester3" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml 2007-04-25 13:22:46 UTC (rev 62540)
@@ -4,7 +4,7 @@
xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObject">
+ <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObjectImpl">
<incallback property="testerInterfaces"/>
<uncallback property="testerInterfaces"/>
</bean>
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationAdditionCallbackTestObjectImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationAdditionCallbackTestObjectImpl.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationAdditionCallbackTestObjectImpl.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,70 @@
+/*
+* 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.inject.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Callback;
+import org.jboss.beans.metadata.plugins.annotations.CallbackType;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AnnotationAdditionCallbackTestObjectImpl implements CallbackTestObject
+{
+ private Set<TesterInterface> testerInterfaces;
+
+ protected void init()
+ {
+ if (testerInterfaces == null)
+ {
+ testerInterfaces = new HashSet<TesterInterface>();
+ }
+ }
+
+ @Callback(type = CallbackType.INSTALL)
+ public void addTesterInterface(TesterInterface tester)
+ {
+ init();
+ testerInterfaces.add(tester);
+ }
+
+ @Callback(type = CallbackType.UNINSTALL)
+ public void removeTesterInterface(TesterInterface tester)
+ {
+ init();
+ testerInterfaces.remove(tester);
+ if (testerInterfaces.isEmpty())
+ testerInterfaces = null;
+ }
+
+ public Set<TesterInterface> getTesterInterfaces()
+ {
+ return testerInterfaces;
+ }
+
+ public void setTesterInterfaces(Set<TesterInterface> testerInterfaces)
+ {
+ this.testerInterfaces = testerInterfaces;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCardinalityCallbackTestObjectImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCardinalityCallbackTestObjectImpl.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCardinalityCallbackTestObjectImpl.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,47 @@
+/*
+* 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.inject.support;
+
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Install;
+import org.jboss.beans.metadata.plugins.annotations.Uninstall;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AnnotationCardinalityCallbackTestObjectImpl implements CallbackTestObject
+{
+ private Set<TesterInterface> testerInterfaces;
+
+ public Set<TesterInterface> getTesterInterfaces()
+ {
+ return testerInterfaces;
+ }
+
+ @Install(cardinality = "2..10", whenRequired = "Create")
+ @Uninstall
+ public void setTesterInterfaces(Set<TesterInterface> testerInterfaces)
+ {
+ this.testerInterfaces = testerInterfaces;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCollectionCallbackTestObjectImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCollectionCallbackTestObjectImpl.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/AnnotationCollectionCallbackTestObjectImpl.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,47 @@
+/*
+* 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.inject.support;
+
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Install;
+import org.jboss.beans.metadata.plugins.annotations.Uninstall;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AnnotationCollectionCallbackTestObjectImpl implements CallbackTestObject
+{
+ private Set<TesterInterface> testerInterfaces;
+
+ public Set<TesterInterface> getTesterInterfaces()
+ {
+ return testerInterfaces;
+ }
+
+ @Install
+ @Uninstall
+ public void setTesterInterfaces(Set<TesterInterface> testerInterfaces)
+ {
+ this.testerInterfaces = testerInterfaces;
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/BadCallbackTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/BadCallbackTestObject.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/BadCallbackTestObject.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -26,7 +26,7 @@
/**
* @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
*/
-public class BadCallbackTestObject extends CallbackTestObject
+public class BadCallbackTestObject extends CallbackTestObjectImpl
{
public void setTesterInterfaces(Set<TesterInterface> testerInterfaces)
{
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -21,45 +21,14 @@
*/
package org.jboss.test.kernel.inject.support;
-import java.util.HashSet;
import java.util.Set;
/**
* @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
*/
-public class CallbackTestObject
+public interface CallbackTestObject
{
- private Set<TesterInterface> testerInterfaces;
+ Set<TesterInterface> getTesterInterfaces();
- protected void init()
- {
- if (testerInterfaces == null)
- {
- testerInterfaces = new HashSet<TesterInterface>();
- }
- }
-
- public void addTesterInterface(TesterInterface tester)
- {
- init();
- testerInterfaces.add(tester);
- }
-
- public void removeTesterInterface(TesterInterface tester)
- {
- init();
- testerInterfaces.remove(tester);
- if (testerInterfaces.isEmpty())
- testerInterfaces = null;
- }
-
- public Set<TesterInterface> getTesterInterfaces()
- {
- return testerInterfaces;
- }
-
- public void setTesterInterfaces(Set<TesterInterface> testerInterfaces)
- {
- this.testerInterfaces = testerInterfaces;
- }
+ void setTesterInterfaces(Set<TesterInterface> testerInterfaces);
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObjectImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObjectImpl.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObjectImpl.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,65 @@
+/*
+* 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.inject.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CallbackTestObjectImpl implements CallbackTestObject
+{
+ private Set<TesterInterface> testerInterfaces;
+
+ protected void init()
+ {
+ if (testerInterfaces == null)
+ {
+ testerInterfaces = new HashSet<TesterInterface>();
+ }
+ }
+
+ public void addTesterInterface(TesterInterface tester)
+ {
+ init();
+ testerInterfaces.add(tester);
+ }
+
+ public void removeTesterInterface(TesterInterface tester)
+ {
+ init();
+ testerInterfaces.remove(tester);
+ if (testerInterfaces.isEmpty())
+ testerInterfaces = null;
+ }
+
+ public Set<TesterInterface> getTesterInterfaces()
+ {
+ return testerInterfaces;
+ }
+
+ public void setTesterInterfaces(Set<TesterInterface> testerInterfaces)
+ {
+ this.testerInterfaces = testerInterfaces;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionAnnotationCallbackTestCase.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -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.inject.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.inject.support.CallbackTestObject;
+
+/**
+ * Callback tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AdditionAnnotationCallbackTestCase extends SimpleCallbackTestCase
+{
+ public AdditionAnnotationCallbackTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(AdditionAnnotationCallbackTestCase.class);
+ }
+
+ protected void afterInstall(CallbackTestObject testObject)
+ {
+ assertNull(testObject.getTesterInterfaces());
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityAnnotationCallbackTestCase.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -0,0 +1,43 @@
+/*
+* 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.inject.test;
+
+import junit.framework.Test;
+
+/**
+ * Cardinality tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CardinalityAnnotationCallbackTestCase extends CardinalityCallbackTestCase
+{
+ public CardinalityAnnotationCallbackTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(CardinalityAnnotationCallbackTestCase.class);
+ }
+
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -50,26 +50,33 @@
assertNull(context.getTarget());
assertEquals(ControllerState.NOT_INSTALLED, context.getState());
+ // move conetxt to change - triggering callback addition + cardinality dependency
change(context, ControllerState.CREATE);
CallbackTestObject injectee = (CallbackTestObject)context.getTarget();
assertNotNull(injectee);
assertNull(injectee.getTesterInterfaces());
+ // install 1st - cardinality dependency not yet satisfied
KernelControllerContext tester1 = getControllerContext("tester1", ControllerState.NOT_INSTALLED);
assertNotNull(tester1);
change(tester1, ControllerState.INSTALLED);
assertNull(injectee.getTesterInterfaces());
+ // install 1st - cardinality dependency now satisfied
KernelControllerContext tester2 = getControllerContext("tester2", ControllerState.NOT_INSTALLED);
assertNotNull(tester2);
change(tester2, ControllerState.INSTALLED);
+ // can be moved to installed
change(context, ControllerState.INSTALLED);
+ assertEquals(ControllerState.INSTALLED, context.getState());
+ // collection should be there
assertNotNull(injectee.getTesterInterfaces());
assertEquals(2, injectee.getTesterInterfaces().size());
+ // add another tester, should be injected as well
KernelControllerContext tester3 = getControllerContext("tester3", ControllerState.NOT_INSTALLED);
assertNotNull(tester3);
change(tester3, ControllerState.INSTALLED);
@@ -77,10 +84,13 @@
assertNotNull(injectee.getTesterInterfaces());
assertEquals(3, injectee.getTesterInterfaces().size());
+ // remove one of the first one added
change(tester1, ControllerState.NOT_INSTALLED);
assertEquals(2, injectee.getTesterInterfaces().size());
assertEquals(ControllerState.INSTALLED, context.getState());
+ // remove the one that was added after cardinality dependency was already resolved
+ // now the cardinality dependency should uninstall main context - since cardinality is out of range
change(tester3, ControllerState.NOT_INSTALLED);
assertEquals(ControllerState.CONFIGURED, context.getState());
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -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.inject.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.inject.support.CallbackTestObject;
+
+/**
+ * Callback tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CollectionAnnotationCallbackTestCase extends SimpleCallbackTestCase
+{
+ public CollectionAnnotationCallbackTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(CollectionAnnotationCallbackTestCase.class);
+ }
+
+ protected void afterInstall(CallbackTestObject testObject)
+ {
+ assertTrue(testObject.getTesterInterfaces().isEmpty());
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java 2007-04-25 11:52:28 UTC (rev 62539)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java 2007-04-25 13:22:46 UTC (rev 62540)
@@ -50,6 +50,11 @@
suite.addTest(CollectionCallbackTestCase.suite());
suite.addTest(CardinalityCallbackTestCase.suite());
suite.addTest(BadCardinalityCallbackTestCase.suite());
+/*
+ suite.addTest(AdditionAnnotationCallbackTestCase.suite());
+ suite.addTest(CollectionAnnotationCallbackTestCase.suite());
+ suite.addTest(CardinalityAnnotationCallbackTestCase.suite());
+*/
return suite;
}
More information about the jboss-cvs-commits
mailing list