[jboss-cvs] JBossAS SVN: r64323 - in projects/microcontainer/trunk: dependency/src/main/org/jboss/dependency/plugins and 16 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 27 08:57:03 EDT 2007
Author: alesj
Date: 2007-07-27 08:57:03 -0400 (Fri, 27 Jul 2007)
New Revision: 64323
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Aliases.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Constructor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Create.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Demands.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Depends.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Destroy.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FactoryMethod.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FromContext.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallMethod.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/NullValue.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Start.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Stop.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/StringValue.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Supplys.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ThisValue.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallMethod.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ValueFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FieldAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/NullValueAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAware.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StringValueAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ThisValueAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/MyDeployer.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestConstructorBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java
Removed:
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/CallbackFactory.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/InjectFactory.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/InstallFactory.java
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/UninstallFactory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/OwnerCallbackItem.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Callback.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Inject.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Install.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Uninstall.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/CreateDestroyLifecycleAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/StartStopLifecycleAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/AnnotatedLifecycleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/IgnoredAnnotatedLifecycleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/MixedLifecycleBean.java
Log:
Initial annotations handling.
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -170,7 +170,29 @@
}
}
}
-
+
+ if (annotated instanceof Method)
+ {
+ if (signature instanceof MethodParametersSignature)
+ {
+ Method method = (Method)annotated;
+ Annotation[][] paramAnnotations = method.getParameterAnnotations();
+ MethodParametersSignature sig = (MethodParametersSignature) signature;
+ return new SimpleMetaDataLoader(paramAnnotations[sig.getParam()]);
+ }
+ }
+
+ if (annotated instanceof Constructor)
+ {
+ if (signature instanceof MethodParametersSignature)
+ {
+ Constructor constructor = (Constructor)annotated;
+ Annotation[][] paramAnnotations = constructor.getParameterAnnotations();
+ MethodParametersSignature sig = (MethodParametersSignature) signature;
+ return new SimpleMetaDataLoader(paramAnnotations[sig.getParam()]);
+ }
+ }
+
return null;
}
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -39,19 +39,23 @@
protected T name;
protected ControllerState whenRequired = ControllerState.CONFIGURED;
protected ControllerState dependentState = ControllerState.INSTALLED;
+ protected String attributeName;
protected AbstractCallbackItem(T name)
{
this.name = name;
}
- protected AbstractCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState)
+ protected AbstractCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState, String attributeName)
{
this.name = name;
if (whenRequired != null)
this.whenRequired = whenRequired;
if (dependentState != null)
this.dependentState = dependentState;
+ if (attributeName == null)
+ throw new IllegalArgumentException("Null attribute name!");
+ this.attributeName = attributeName;
}
public void ownerCallback(Controller controller, boolean isInstallPhase) throws Throwable
@@ -89,6 +93,11 @@
return dependentState;
}
+ public String getAttributeName()
+ {
+ return attributeName;
+ }
+
public void toShortString(JBossStringBuilder buffer)
{
buffer.append("name=").append(name);
@@ -99,5 +108,6 @@
buffer.append("name=").append(name);
buffer.append(" whenRequired=").append(whenRequired);
buffer.append(" dependentState=").append(dependentState);
+ buffer.append(" attributeName=").append(attributeName);
}
}
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -24,7 +24,6 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
-import org.jboss.util.JBossStringBuilder;
/**
* Attribute callback item.
@@ -34,8 +33,6 @@
*/
public class AttributeCallbackItem<T> extends OwnerCallbackItem<T, AttributeDispatchContext>
{
- protected String attribute;
-
public AttributeCallbackItem(T name, AttributeDispatchContext owner, String attribute)
{
this(name, null, null, owner, attribute);
@@ -43,25 +40,16 @@
public AttributeCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState, AttributeDispatchContext owner, String attribute)
{
- super(name, whenRequired, dependentState, owner);
- if (attribute == null)
- throw new IllegalArgumentException("Null attribute!");
- this.attribute = attribute;
+ super(name, whenRequired, dependentState, attribute, owner);
}
protected void execute(Object target) throws Throwable
{
- owner.set(attribute, target);
+ owner.set(getAttributeName(), target);
}
protected void changeCallback(ControllerContext context, boolean isInstallPhase) throws Throwable
{
execute(context.getTarget());
}
-
- protected void toString(JBossStringBuilder buffer)
- {
- super.toString(buffer);
- buffer.append(" attribute=").append(attribute);
- }
}
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/OwnerCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/OwnerCallbackItem.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/OwnerCallbackItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -38,14 +38,14 @@
{
protected C owner;
- protected OwnerCallbackItem(T name, C owner)
+ protected OwnerCallbackItem(T name, String attributeName, C owner)
{
- this(name, null, null, owner);
+ this(name, null, null, attributeName, owner);
}
- protected OwnerCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState, C owner)
+ protected OwnerCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState, String attributeName, C owner)
{
- super(name, whenRequired, dependentState);
+ super(name, whenRequired, dependentState, attributeName);
if (owner == null)
throw new IllegalArgumentException("Null owner!");
this.owner = owner;
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -34,7 +34,6 @@
*/
public class SingleCallbackItem<T> extends OwnerCallbackItem<T, InvokeDispatchContext>
{
- protected String method;
protected String signature;
public SingleCallbackItem(T name, InvokeDispatchContext owner, String method)
@@ -54,12 +53,7 @@
public SingleCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState, InvokeDispatchContext owner, String method, String signature)
{
- super(name, whenRequired, dependentState, owner);
- if (method == null)
- throw new IllegalArgumentException("Null method!");
-
- this.owner = owner;
- this.method = method;
+ super(name, whenRequired, dependentState, method, owner);
this.signature = signature;
}
@@ -70,7 +64,7 @@
{
if (signature == null)
signature = target.getClass().getName();
- owner.invoke(method, new Object[]{target}, new String[]{signature});
+ owner.invoke(getAttributeName(), new Object[]{target}, new String[]{signature});
}
else
log.warn("Null target, cannot invoke non-static method: " + this);
@@ -79,7 +73,6 @@
protected void toString(JBossStringBuilder buffer)
{
super.toString(buffer);
- buffer.append(" method=").append(method);
buffer.append(" signature=").append(signature);
}
}
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -54,6 +54,13 @@
ControllerState getDependentState();
/**
+ * Get the method/attribute/property name
+ *
+ * @return the name
+ */
+ String getAttributeName();
+
+ /**
* Execute callback when item added to controller.
*
* @param controller the controller
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-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -60,6 +60,12 @@
/** The signature */
protected String signature;
+ /** The property info */
+ protected transient PropertyInfo propertyInfo;
+
+ /** The method info */
+ protected transient MethodInfo methodInfo;
+
public AbstractCallbackMetaData()
{
setState(ControllerState.CONFIGURED);
@@ -145,6 +151,18 @@
return dependentState;
}
+ public void setPropertyInfo(PropertyInfo propertyInfo)
+ {
+ this.propertyInfo = propertyInfo;
+ this.property = propertyInfo.getName();
+ }
+
+ public void setMethodInfo(MethodInfo methodInfo)
+ {
+ this.methodInfo = methodInfo;
+ this.methodName = methodInfo.getName();
+ }
+
/**
* Add install / uninstrall callback.
*
@@ -161,14 +179,18 @@
CallbackItem callback;
if (property != null)
{
- ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData());
- PropertyInfo pi = Configurator.resolveProperty(log.isTraceEnabled(), context.getBeanInfo(), cl, property, signature);
- callback = CallbackCreatorUtil.createCallback(context, pi, whenRequired, dependentState, cardinality);
+ if (propertyInfo == null)
+ {
+ ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData());
+ propertyInfo = Configurator.resolveProperty(log.isTraceEnabled(), context.getBeanInfo(), cl, property, signature);
+ }
+ callback = CallbackCreatorUtil.createCallback(context, propertyInfo, whenRequired, dependentState, cardinality);
}
else if (methodName != null)
{
- MethodInfo mi = Configurator.findMethodInfo(getClassInfo(context), methodName, new String[]{signature});
- callback = CallbackCreatorUtil.createCallback(context, mi, whenRequired, dependentState, cardinality);
+ if (methodInfo == null)
+ methodInfo = Configurator.findMethodInfo(getClassInfo(context), methodName, new String[]{signature});
+ callback = CallbackCreatorUtil.createCallback(context, methodInfo, whenRequired, dependentState, cardinality);
}
else
throw new IllegalArgumentException("Illegal usage - not property or method:" + this);
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -45,7 +45,7 @@
public class AbstractDemandMetaData extends JBossObject
implements DemandMetaData, Serializable
{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2L;
/** The demand */
protected Object demand;
@@ -53,9 +53,6 @@
/** When the dependency is required */
protected ControllerState whenRequired = ControllerState.DESCRIBED;
- /** The dependency delegate */
- protected AbstractDependencyItem dependencyItem;
-
/**
* Create a new demand
*/
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Aliases.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Aliases.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Aliases.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,37 @@
+/*
+* 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.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE})
+public @interface Aliases
+{
+ String[] value();
+}
Deleted: 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 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/AnnotationDependencyBuilder.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,124 +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.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
- };
-
- /**
- * Get expected annotation classes.
- * Can be overridden for additional annotations.
- *
- * @return expected/supported annotation classes
- */
- @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;
- }
-
- /**
- * Check if annotation exists on method.
- *
- * @param mi method info
- * @param annotation annotation to check for
- * @param list existing dependency item list
- */
- @SuppressWarnings("unchecked")
- protected void checkAnnotation(MethodInfo mi, Class<? extends Annotation> annotation, List<DependencyBuilderListItem> list)
- {
- Annotation expected = mi.getUnderlyingAnnotation(annotation);
- if (expected != null)
- {
- DependencyFactoryLookup dfl = expected.annotationType().getAnnotation(DependencyFactoryLookup.class);
- if (dfl == null)
- throw new IllegalArgumentException("Illegal annotation type - no DependencyFactoryLookup meta data: " + expected);
- DependencyFactory df = createDependencyFactory(dfl);
- list.add(df.createDependency(expected, mi));
- }
- }
-
- /**
- * Create dependency factory from anntoation info.
- * Can be overridden for caching factory instances.
- *
- * @param dfl dependency factory lookup
- * @return dependecny factory instance
- */
- protected DependencyFactory createDependencyFactory(DependencyFactoryLookup dfl)
- {
- try
- {
- return dfl.value().newInstance();
- }
- catch (Exception e)
- {
- throw new Error("Cannot create DependencyFactory: " + dfl, e);
- }
- }
-}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Callback.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Callback.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Callback.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -26,14 +26,11 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.jboss.beans.metadata.spi.annotations.DependencyFactoryLookup;
-
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
- at DependencyFactoryLookup(CallbackFactory.class)
public @interface Callback
{
/**
Deleted: 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 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackDependencyBuilderListItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,93 +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.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);
- }
-}
Deleted: 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-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactory.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,46 +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.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 extends CallbackFactoryAdapter implements DependencyFactory<Callback>
-{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Callback annotation, MethodInfo method)
- {
- return getDependency(new CallbackInfo(annotation), method);
- }
-
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Callback annotation, PropertyInfo property)
- {
- return getDependency(new CallbackInfo(annotation), property);
- }
-}
Deleted: 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 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackFactoryAdapter.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,80 +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.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
-{
- /**
- * Create new dependency builder list item.
- * Install or uninstall phase item.
- *
- * @param info callback info
- * @param method method info
- * @return new dependency builder list item
- */
- protected DependencyBuilderListItem<KernelControllerContext> getDependency(CallbackInfo info, MethodInfo method)
- {
- return getDependency(info, new MethodAttributeInfo(method));
- }
-
- /**
- * Create new dependency builder list item.
- * Install or uninstall phase item.
- *
- * @param info callback info
- * @param property property info
- * @return new dependency builder list item
- */
- protected DependencyBuilderListItem<KernelControllerContext> getDependency(CallbackInfo info, PropertyInfo property)
- {
- return getDependency(info, new PropertyAttributeInfo(property));
- }
-
- /**
- * Create new dependency builder list item.
- * Install or uninstall phase item.
- *
- * @param info callback info
- * @param attribute attribute info
- * @return new dependency builder list item
- */
- protected DependencyBuilderListItem<KernelControllerContext> getDependency(CallbackInfo info, AttributeInfo attribute)
- {
- if (info.isInstallPhase())
- return new InstallCallbackDependencyBuilderListItem(info, attribute);
- else
- return new UninstallCallbackDependencyBuilderListItem(info, attribute);
- }
-}
Deleted: 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 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/CallbackInfo.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,133 +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.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 serialVersionUID */
- private static final long serialVersionUID = -2213756676713799799L;
-
- /* 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);
- }
-}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Constructor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Constructor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Constructor.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.CONSTRUCTOR})
+public @interface Constructor
+{
+}
Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Create.java (from rev 64312, projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/CreateLifecycle.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Create.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Create.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,21 @@
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD})
+public @interface Create
+{
+ /**
+ * Is this lifecycle callback ignored.
+ *
+ * @return ignored
+ */
+ boolean ignored() default false;
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Demands.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Demands.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Demands.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,37 @@
+/*
+* 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.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE})
+public @interface Demands
+{
+ String[] value();
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Depends.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Depends.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Depends.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,37 @@
+/*
+* 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.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE})
+public @interface Depends
+{
+ String[] value();
+}
Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Destroy.java (from rev 64312, projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/DestroyLifecycle.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Destroy.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Destroy.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,21 @@
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD})
+public @interface Destroy
+{
+ /**
+ * Is this lifecycle callback ignored.
+ *
+ * @return ignored
+ */
+ boolean ignored() default false;
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FactoryMethod.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FactoryMethod.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FactoryMethod.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD})
+public @interface FactoryMethod
+{
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FromContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FromContext.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/FromContext.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,52 @@
+/*
+* 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;
+
+/**
+ * FromContext.
+ * @see org.jboss.beans.metadata.plugins.FromContext
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public enum FromContext
+{
+ NONE("[blank]"),
+ NAME("name"),
+ ALIASES("aliases"),
+ METADATA("metadata"),
+ BEANINFO("beaninfo"),
+ SCOPE("scope"),
+ ID("id");
+
+ private String typeString;
+
+ FromContext(String optionString)
+ {
+ this.typeString = optionString;
+ }
+
+ public String toString()
+ {
+ return typeString;
+ }
+
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Inject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Inject.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Inject.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -26,8 +26,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.jboss.beans.metadata.spi.annotations.DependencyFactoryLookup;
-
/**
* Beans when injected by class type are by default changed to configured
* state - if not yet configured.
@@ -36,8 +34,7 @@
* @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
*/
@Retention(RetentionPolicy.RUNTIME)
- at Target({ElementType.METHOD, ElementType.TYPE})
- at DependencyFactoryLookup(InjectFactory.class)
+ at Target({ElementType.METHOD, ElementType.PARAMETER})
public @interface Inject
{
/**
@@ -58,11 +55,10 @@
/**
* Get when required.
- * Default is Describe.
*
* @return when required.
*/
- String whenRequired() default "Describe";
+ String whenRequired() default "";
/**
* Get dependent state.
@@ -88,4 +84,10 @@
*/
InjectOption option() default InjectOption.STRICT;
+ /**
+ * Get from context injection.
+ *
+ * @return from context type
+ */
+ FromContext fromContext() default FromContext.NONE;
}
Deleted: 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-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InjectFactory.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,46 +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.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.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class InjectFactory implements DependencyFactory<Inject>
-{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Inject annotation, MethodInfo method)
- {
- return null;
- }
-
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Inject annotation, PropertyInfo property)
- {
- return null;
- }
-}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Install.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Install.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Install.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -26,8 +26,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.jboss.beans.metadata.spi.annotations.DependencyFactoryLookup;
-
/**
* Install callback.
* @see org.jboss.beans.metadata.plugins.annotations.Callback
@@ -36,7 +34,6 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
- at DependencyFactoryLookup(InstallFactory.class)
public @interface Install
{
/**
Deleted: 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 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallCallbackDependencyBuilderListItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,44 +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.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);
- }
-}
Deleted: 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-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallFactory.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,46 +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.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 extends CallbackFactoryAdapter implements DependencyFactory<Install>
-{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Install annotation, MethodInfo method)
- {
- 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/InstallMethod.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallMethod.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/InstallMethod.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,39 @@
+/*
+* 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.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD})
+public @interface InstallMethod
+{
+ String bean() default "";
+
+ String dependantState() default "";
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/NullValue.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/NullValue.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/NullValue.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD, ElementType.PARAMETER})
+public @interface NullValue
+{
+}
Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Start.java (from rev 64312, projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/StartLifecycle.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Start.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Start.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,21 @@
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD})
+public @interface Start
+{
+ /**
+ * Is this lifecycle callback ignored.
+ *
+ * @return ignored
+ */
+ boolean ignored() default false;
+}
Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Stop.java (from rev 64312, projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/StopLifecycle.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Stop.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Stop.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,21 @@
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD})
+public @interface Stop
+{
+ /**
+ * Is this lifecycle callback ignored.
+ *
+ * @return ignored
+ */
+ boolean ignored() default false;
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/StringValue.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/StringValue.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/StringValue.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,39 @@
+/*
+* 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.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD, ElementType.PARAMETER})
+public @interface StringValue
+{
+ String value();
+
+ String type() default "";
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Supplys.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Supplys.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Supplys.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,37 @@
+/*
+* 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.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE})
+public @interface Supplys
+{
+ String[] value();
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ThisValue.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ThisValue.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ThisValue.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD, ElementType.PARAMETER})
+public @interface ThisValue
+{
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Uninstall.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Uninstall.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Uninstall.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -26,8 +26,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.jboss.beans.metadata.spi.annotations.DependencyFactoryLookup;
-
/**
* Uninstall callback.
* @see org.jboss.beans.metadata.plugins.annotations.Callback
@@ -36,7 +34,6 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
- at DependencyFactoryLookup(UninstallFactory.class)
public @interface Uninstall
{
/**
Deleted: 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 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallCallbackDependencyBuilderListItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,44 +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.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);
- }
-}
Deleted: 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-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallFactory.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -1,46 +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.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 extends CallbackFactoryAdapter implements DependencyFactory<Uninstall>
-{
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Uninstall annotation, MethodInfo method)
- {
- return getDependency(new CallbackInfo(annotation), method);
- }
-
- public DependencyBuilderListItem<KernelControllerContext> createDependency(Uninstall annotation, PropertyInfo property)
- {
- return getDependency(new CallbackInfo(annotation), property);
- }
-}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallMethod.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallMethod.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/UninstallMethod.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,39 @@
+/*
+* 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.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD})
+public @interface UninstallMethod
+{
+ String bean() default "";
+
+ String dependantState() default "";
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ValueFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ValueFactory.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/ValueFactory.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.beans.metadata.plugins.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD, ElementType.PARAMETER})
+public @interface ValueFactory
+{
+ String bean();
+
+ String method();
+
+ String parameter();
+
+ String defaultValue() default "";
+
+ String dependantState() default "Installed";
+
+ String whenRequiredState() default "Configured";
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,258 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.util.Stack;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.spi.retrieval.AnnotationItem;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.logging.Logger;
+
+/**
+ * @param <T> info type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> implements AnnotationPlugin<T, C>
+{
+ protected Logger log = Logger.getLogger(getClass());
+ private Class<C> annotation;
+ private Set<ElementType> types;
+
+ protected AbstractAnnotationPlugin(Class<C> annotation)
+ {
+ if (annotation == null)
+ throw new IllegalArgumentException("Null annotation!");
+ this.annotation = annotation;
+ this.types = new HashSet<ElementType>();
+ Target target = annotation.getAnnotation(Target.class);
+ if (target != null)
+ {
+ List<ElementType> list = Arrays.asList(target.value());
+ for(ElementType type : list)
+ {
+ if (isElementTypeSupported(type))
+ {
+ types.add(type);
+ }
+ else
+ log.warn("Unsupported type " + type + " on annotation " + annotation);
+ }
+ }
+ }
+
+ protected static boolean isAttributePresent(String value)
+ {
+ return value != null && value.length() > 0;
+ }
+
+ protected abstract boolean isElementTypeSupported(ElementType type);
+
+ public Set<ElementType> getSupportedTypes()
+ {
+ return Collections.unmodifiableSet(types);
+ }
+
+ public Class<C> getAnnotation()
+ {
+ return annotation;
+ }
+
+ protected boolean isMetaDataAlreadyPresent(T info, C annotation, KernelControllerContext context)
+ {
+ return isMetaDataAlreadyPresent(info, annotation, context.getBeanMetaData());
+ }
+
+ protected boolean isMetaDataAlreadyPresent(T info, C annotation, BeanMetaData beanMetaData)
+ {
+ return false;
+ }
+
+ protected void internalApplyAnnotation(T info, MetaDataRetrieval retrieval, C annotation, KernelControllerContext context) throws Throwable
+ {
+ internalApplyAnnotation(info, annotation, context);
+ }
+
+ protected void internalApplyAnnotation(T info, C annotation, KernelControllerContext context) throws Throwable
+ {
+ internalApplyAnnotation(info, annotation, context.getBeanMetaData());
+ }
+
+ protected void internalApplyAnnotation(T info, C annotation, BeanMetaData beanMetaData) throws Throwable
+ {
+ }
+
+ public final void applyAnnotation(T info, MetaDataRetrieval retrieval, KernelControllerContext context) throws Throwable
+ {
+ // todo - match multiple annotations?
+ AnnotationItem<C> item = retrieval.retrieveAnnotation(getAnnotation());
+ if (item == null || isMetaDataAlreadyPresent(info, item.getAnnotation(), context))
+ return;
+ internalApplyAnnotation(info, retrieval, item.getAnnotation(), context);
+ }
+
+ protected void executeVisit(KernelControllerContext context, MetaDataVisitorNode node)
+ {
+ MetaDataVisitor visitor = getMetaDataVisitor(context);
+ node.initialVisit(visitor);
+ node.describeVisit(visitor);
+ }
+
+ protected MetaDataVisitor getMetaDataVisitor(KernelControllerContext context)
+ {
+ return new PluginMetaDataVisitor(context);
+ }
+
+ protected class PluginMetaDataVisitor implements MetaDataVisitor
+ {
+ private ControllerState contextState = ControllerState.INSTANTIATED;
+ private KernelControllerContext context;
+ private Stack<MetaDataVisitorNode> visitorNodeStack;
+
+ public PluginMetaDataVisitor(KernelControllerContext context)
+ {
+ this.context = context;
+ this.visitorNodeStack = new Stack<MetaDataVisitorNode>();
+ // add bean meta data
+ this.visitorNodeStack.add(context.getBeanMetaData());
+ }
+
+ public KernelControllerContext getControllerContext()
+ {
+ return context;
+ }
+
+ public ControllerState getContextState()
+ {
+ return contextState;
+ }
+
+ public void setContextState(ControllerState contextState)
+ {
+ this.contextState = contextState;
+ }
+
+ public void addDependency(DependencyItem dependency)
+ {
+ context.getDependencyInfo().addIDependOn(dependency);
+ }
+
+ public void addInstallCallback(CallbackItem callback)
+ {
+ context.getDependencyInfo().addInstallItem(callback);
+ }
+
+ public void addUninstallCallback(CallbackItem callback)
+ {
+ context.getDependencyInfo().addUninstallItem(callback);
+ }
+
+ public void initialVisit(MetaDataVisitorNode node)
+ {
+ visitorNodeStack.push(node);
+ try
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Initial visit node " + node);
+
+ // Visit the children of this node
+ Iterator children = node.getChildren();
+ if (children != null)
+ {
+ ControllerState restoreState = contextState;
+ while (children.hasNext())
+ {
+ MetaDataVisitorNode child = (MetaDataVisitorNode) children.next();
+ try
+ {
+ child.initialVisit(this);
+ }
+ finally
+ {
+ contextState = restoreState;
+ }
+ }
+ }
+ }
+ finally
+ {
+ visitorNodeStack.pop();
+ }
+ }
+
+ public void describeVisit(MetaDataVisitorNode node)
+ {
+ visitorNodeStack.push(node);
+ try
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Describe visit node " + node);
+
+ // Visit the children of this node
+ Iterator children = node.getChildren();
+ if (children != null)
+ {
+ ControllerState restoreState = contextState;
+ while (children.hasNext())
+ {
+ MetaDataVisitorNode child = (MetaDataVisitorNode) children.next();
+ try
+ {
+ child.describeVisit(this);
+ }
+ finally
+ {
+ contextState = restoreState;
+ }
+ }
+ }
+ }
+ finally
+ {
+ visitorNodeStack.pop();
+ }
+ }
+
+ public Stack<MetaDataVisitorNode> visitorNodeStack()
+ {
+ return visitorNodeStack;
+ }
+ }
+}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,162 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.builder.MutableParameterizedMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.kernel.plugins.config.Configurator;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.spi.retrieval.AnnotationItem;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.signature.MethodParametersSignature;
+import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.reflect.spi.ParameterInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * @param <T> info type
+ * @param <C> annotation type
+ * @param <P> mutable parametrized type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractParameterAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation, P extends MutableParameterizedMetaData> extends AbstractAnnotationPlugin<T, C>
+{
+ protected List<Annotation2ValueMetaDataAdapter> adapters;
+
+ protected AbstractParameterAnnotationPlugin(Class<C> annotation, Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(annotation);
+ this.adapters = new ArrayList<Annotation2ValueMetaDataAdapter>();
+ if (adapters == null || adapters.length == 0)
+ throw new IllegalArgumentException("Annotation adapters are empty!");
+ this.adapters.addAll(Arrays.asList(adapters));
+ }
+
+ protected abstract boolean checkAnnotatedInfo(ElementType type);
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.PARAMETER == type || checkAnnotatedInfo(type);
+ }
+
+ protected abstract ParameterInfo[] getParameters(T info);
+
+ protected void handleParameterlessInfo(T info, C annotation, KernelControllerContext context)
+ {
+ handleParameterlessInfo(info, annotation, context.getBeanMetaData());
+ }
+
+ protected abstract void handleParameterlessInfo(T info, C annotation, BeanMetaData beanMetaData);
+
+ protected P createParametrizedMetaData(T info, C annotation, KernelControllerContext context)
+ {
+ return createParametrizedMetaData(info, annotation, context.getBeanMetaData());
+ }
+
+ protected P createParametrizedMetaData(T info, C annotation, BeanMetaData beanMetaData)
+ {
+ return createParametrizedMetaData(info, annotation);
+ }
+
+ protected P createParametrizedMetaData(T info, C annotation)
+ {
+ return createParametrizedMetaData(info);
+ }
+
+ protected P createParametrizedMetaData(T info)
+ {
+ throw new IllegalArgumentException("Should implement one of createParameterizedMetaData methods!");
+ }
+
+ protected void setParameterizedMetaData(P parameterizedMetaData, KernelControllerContext context)
+ {
+ setParameterizedMetaData(parameterizedMetaData, context.getBeanMetaData());
+ }
+
+ protected abstract void setParameterizedMetaData(P parameterizedMetaData, BeanMetaData beanMetaData);
+
+ @SuppressWarnings("unchecked")
+ protected void internalApplyAnnotation(T info, MetaDataRetrieval retrieval, C annotation, KernelControllerContext context) throws Throwable
+ {
+ ParameterInfo[] parameters = getParameters(info);
+ if (parameters == null || parameters.length == 0)
+ {
+ handleParameterlessInfo(info, annotation, context);
+ return;
+ }
+
+ TypeInfo[] typeInfos = new TypeInfo[parameters.length];
+ for(int i=0; i < parameters.length; i++)
+ typeInfos[i] = parameters[i].getParameterType();
+
+ List<ParameterMetaData> pmds = new ArrayList<ParameterMetaData>();
+ for(int i=0; i < parameters.length; i++)
+ {
+ ParameterInfo pi = parameters[i];
+ Signature pis = new MethodParametersSignature(
+ pi.getName(),
+ Configurator.getParameterTypes(log.isTraceEnabled(), typeInfos),
+ i
+ );
+ MetaDataRetrieval mdr = retrieval.getComponentMetaDataRetrieval(pis);
+ if (mdr != null)
+ {
+ ValueMetaData value = null;
+ for(Annotation2ValueMetaDataAdapter adapter : adapters)
+ {
+ // todo - match multiple annotations?
+ AnnotationItem item = mdr.retrieveAnnotation(adapter.getAnnotation());
+ if (item != null)
+ {
+ value = adapter.createValueMetaData(item.getAnnotation());
+ break;
+ }
+ }
+ if (value == null)
+ throw new IllegalArgumentException("No such Annotation2ValueMetaData adapter or no annotation on PropertyInfo: " + pi);
+ pmds.add(new AbstractParameterMetaData(pi.getParameterType().getName(), value));
+ }
+ else
+ {
+ throw new IllegalArgumentException("MetaDataRetrieval for parameter must exist: " + pi);
+ }
+ }
+ P parameterizedMetaData = createParametrizedMetaData(info, annotation, context);
+ setParameterizedMetaData(parameterizedMetaData, context);
+ parameterizedMetaData.setParameters(pmds);
+ if (parameterizedMetaData instanceof MetaDataVisitorNode == false)
+ throw new IllegalArgumentException("ParameterizedMetaData not MetaDataVisitor: " + parameterizedMetaData);
+ executeVisit(context, (MetaDataVisitorNode)parameterizedMetaData);
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.annotations;
+
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Aliases;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.dependency.spi.Controller;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AliasesAnnotationPlugin extends ClassAnnotationPlugin<Aliases>
+{
+ public AliasesAnnotationPlugin()
+ {
+ super(Aliases.class);
+ }
+
+ protected void internalApplyAnnotation(ClassInfo info, Aliases annotation, KernelControllerContext context) throws Throwable
+ {
+ BeanMetaData beanMetaData = context.getBeanMetaData();
+ Set<Object> aliases = beanMetaData.getAliases();
+ Controller controller = context.getController();
+ for(String alias : annotation.value())
+ {
+ if (aliases == null || aliases.contains(alias) == false)
+ {
+ // alias will get removed when original will be undeployed
+ controller.addAlias(alias, beanMetaData.getName());
+ }
+ }
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/Annotation2ValueMetaDataAdapter.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.beans.metadata.spi.ValueMetaData;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface Annotation2ValueMetaDataAdapter<C extends Annotation>
+{
+ Class<C> getAnnotation();
+
+ ValueMetaData createValueMetaData(C annotation);
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.util.Set;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.reflect.spi.AnnotatedInfo;
+
+/**
+ * @param <T> info type
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface AnnotationPlugin<T extends AnnotatedInfo, C extends Annotation>
+{
+ Class<C> getAnnotation();
+
+ Set<ElementType> getSupportedTypes();
+
+ void applyAnnotation(T info, MetaDataRetrieval retrieval, KernelControllerContext context) throws Throwable;
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,232 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.config.Configurator;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.signature.ConstructorSignature;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at SuppressWarnings("unchecked")
+public class BasicBeanAnnotationAdapter implements BeanAnnotationAdapter
+{
+ protected Logger log = Logger.getLogger(BasicBeanAnnotationAdapter.class);
+
+ protected Set<AnnotationPlugin> classAnnotationPlugins = new HashSet<AnnotationPlugin>();
+ protected Set<AnnotationPlugin> constructorAnnotationPlugins = new HashSet<AnnotationPlugin>();
+ protected Set<AnnotationPlugin> propertyAnnotationPlugins = new HashSet<AnnotationPlugin>();
+ protected Set<AnnotationPlugin> methodAnnotationPlugins = new HashSet<AnnotationPlugin>();
+ protected Set<AnnotationPlugin> fieldAnnotationPlugins = new HashSet<AnnotationPlugin>();
+
+ public BasicBeanAnnotationAdapter()
+ {
+ // -- adapters
+ Annotation2ValueMetaDataAdapter[] adapters = new Annotation2ValueMetaDataAdapter[]{
+ InjectAnnotationPlugin.INSTANCE,
+ StringValueAnnotationPlugin.INSTANCE,
+ ValueFactoryAnnotationPlugin.INSTANCE,
+ ThisValueAnnotationPlugin.INSTANCE,
+ NullValueAnnotationPlugin.INSTANCE,
+ };
+ // -- plugins
+ // class
+ addAnnotationPlugin(new AliasesAnnotationPlugin());
+ addAnnotationPlugin(new DemandsAnnotationPlugin());
+ addAnnotationPlugin(new DependsAnnotationPlugin());
+ addAnnotationPlugin(new SupplysAnnotationPlugin());
+ // constructor
+ addAnnotationPlugin(new ConstructorParameterAnnotationPlugin(adapters));
+ // property
+ addAnnotationPlugin(InjectAnnotationPlugin.INSTANCE);
+ addAnnotationPlugin(StringValueAnnotationPlugin.INSTANCE);
+ addAnnotationPlugin(ValueFactoryAnnotationPlugin.INSTANCE);
+ addAnnotationPlugin(ThisValueAnnotationPlugin.INSTANCE);
+ addAnnotationPlugin(NullValueAnnotationPlugin.INSTANCE);
+ addAnnotationPlugin(new PropertyInstallCallbackAnnotationPlugin());
+ addAnnotationPlugin(new PropertyUninstallCallbackAnnotationPlugin());
+ // method
+ addAnnotationPlugin(new FactoryMethodAnnotationPlugin(adapters));
+ addAnnotationPlugin(new CreateLifecycleAnnotationPlugin(adapters));
+ addAnnotationPlugin(new StartLifecycleAnnotationPlugin(adapters));
+ addAnnotationPlugin(new StopLifecycleAnnotationPlugin(adapters));
+ addAnnotationPlugin(new DestroyLifecycleAnnotationPlugin(adapters));
+ addAnnotationPlugin(new MethodInstallCallbackAnnotationPlugin());
+ addAnnotationPlugin(new MethodUninstallCallbackAnnotationPlugin());
+ addAnnotationPlugin(new InstallMethodParameterAnnotationPlugin(adapters));
+ addAnnotationPlugin(new UninstallMethodParameterAnnotationPlugin(adapters));
+ // field
+ }
+
+ protected void addAnnotationPlugin(AnnotationPlugin plugin)
+ {
+ Class<? extends Annotation> annotation = plugin.getAnnotation();
+ if (annotation.getAnnotation(Target.class) == null)
+ log.warn("Annotation " + annotation + " missing @Target annotation!");
+ if (annotation.getAnnotation(Retention.class) == null)
+ log.warn("Annotation " + annotation + " missing @Retention annotation!");
+
+ if (plugin.getSupportedTypes().contains(ElementType.TYPE))
+ {
+ classAnnotationPlugins.add(plugin);
+ }
+ if (plugin.getSupportedTypes().contains(ElementType.CONSTRUCTOR))
+ {
+ constructorAnnotationPlugins.add(plugin);
+ }
+ if (plugin.getSupportedTypes().contains(ElementType.METHOD))
+ {
+ if (plugin instanceof PropertyAware)
+ propertyAnnotationPlugins.add(plugin);
+ else
+ methodAnnotationPlugins.add(plugin);
+ }
+ if (plugin.getSupportedTypes().contains(ElementType.FIELD))
+ {
+ fieldAnnotationPlugins.add(plugin);
+ }
+ }
+
+ public void applyAnnotations(KernelControllerContext context) throws Throwable
+ {
+ Kernel kernel = context.getKernel();
+ KernelMetaDataRepository repository = kernel.getMetaDataRepository();
+ MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(context);
+
+ boolean trace = log.isTraceEnabled();
+ BeanInfo info = context.getBeanInfo();
+
+ // class
+ ClassInfo classInfo = info.getClassInfo();
+ for(AnnotationPlugin plugin : classAnnotationPlugins)
+ plugin.applyAnnotation(classInfo, retrieval, context);
+
+ // constructors
+ Set<ConstructorInfo> constructors = info.getConstructors();
+ if (constructors != null && constructors.isEmpty() == false)
+ {
+ for(ConstructorInfo ci : constructors)
+ {
+ Signature cis = new ConstructorSignature(Configurator.getParameterTypes(trace, ci.getParameterTypes()));
+ MetaDataRetrieval cmdr = retrieval.getComponentMetaDataRetrieval(cis);
+ if (cmdr != null)
+ {
+ for(AnnotationPlugin plugin : constructorAnnotationPlugins)
+ plugin.applyAnnotation(ci, cmdr, context);
+ }
+ }
+ }
+
+ // properties
+ Set<PropertyInfo> properties = info.getProperties();
+ if (properties != null && properties.isEmpty() == false)
+ {
+ for(PropertyInfo pi : properties)
+ {
+ MethodInfo setter = pi.getSetter();
+ if (setter != null)
+ {
+ Signature sis = new MethodSignature(setter.getName(), Configurator.getParameterTypes(trace, setter.getParameterTypes()));
+ MetaDataRetrieval cmdr = retrieval.getComponentMetaDataRetrieval(sis);
+ if (cmdr != null)
+ {
+ for(AnnotationPlugin plugin : propertyAnnotationPlugins)
+ plugin.applyAnnotation(pi, cmdr, context);
+ }
+ }
+ }
+ }
+
+ // methods
+ Set<MethodInfo> methods = info.getMethods();
+ if (methods != null && methods.isEmpty() == false)
+ {
+ for(MethodInfo mi : methods)
+ {
+ Signature mis = new MethodSignature(mi.getName(), Configurator.getParameterTypes(trace, mi.getParameterTypes()));
+ MetaDataRetrieval cmdr = retrieval.getComponentMetaDataRetrieval(mis);
+ if (cmdr != null)
+ {
+ for(AnnotationPlugin plugin : methodAnnotationPlugins)
+ plugin.applyAnnotation(mi, cmdr, context);
+ }
+ }
+ }
+
+ // static methods
+ MethodInfo[] staticMethods = classInfo.getDeclaredMethods();
+ if (staticMethods != null && staticMethods.length != 0)
+ {
+ for(MethodInfo smi : staticMethods)
+ {
+ if (smi.isStatic() && smi.isPublic())
+ {
+ Signature mis = new MethodSignature(smi.getName(), Configurator.getParameterTypes(trace, smi.getParameterTypes()));
+ MetaDataRetrieval cmdr = retrieval.getComponentMetaDataRetrieval(mis);
+ if (cmdr != null)
+ {
+ for(AnnotationPlugin plugin : methodAnnotationPlugins)
+ plugin.applyAnnotation(smi, cmdr, context);
+ }
+ }
+ }
+ }
+
+ // fields
+ FieldInfo[] fields = classInfo.getDeclaredFields();
+ if (fields != null && fields.length > 0)
+ {
+ for(FieldInfo fi : fields)
+ {
+ Signature fis = new FieldSignature(fi.getName());
+ MetaDataRetrieval cmdr = retrieval.getComponentMetaDataRetrieval(fis);
+ if (cmdr != null)
+ {
+ for(AnnotationPlugin plugin : fieldAnnotationPlugins)
+ plugin.applyAnnotation(fi, cmdr, context);
+ }
+ }
+ }
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapter.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapter.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface BeanAnnotationAdapter
+{
+ /**
+ * Apply the annotations.
+ *
+ * @param context the context
+ * @throws Throwable for any error
+ */
+ void applyAnnotations(KernelControllerContext context) throws Throwable;
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanAnnotationAdapterFactory
+{
+ private static final BeanAnnotationAdapter adapter = new BasicBeanAnnotationAdapter();
+
+ public static BeanAnnotationAdapter getBeanAnnotationAdapter()
+ {
+ return adapter;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,87 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.AnnotatedInfo;
+
+/**
+ * @param <T> info type
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CallbackAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends AbstractAnnotationPlugin<T, C>
+{
+ protected CallbackAnnotationPlugin(Class<C> annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.METHOD == type;
+ }
+
+ protected boolean isMetaDataAlreadyPresent(T info, C annotation, KernelControllerContext context)
+ {
+ DependencyInfo dependency = context.getDependencyInfo();
+ Set<CallbackItem> callbacks = getCallbacks(dependency);
+ if (callbacks != null && callbacks.isEmpty() == false)
+ {
+ for(CallbackItem ci : callbacks)
+ {
+ if (isNameEqual(info, ci.getAttributeName()))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected abstract boolean isNameEqual(T info, String attributeName);
+
+ protected abstract Set<CallbackItem> getCallbacks(DependencyInfo dependency);
+
+ protected void internalApplyAnnotation(T info, C annotation, KernelControllerContext context)
+ {
+ AbstractBeanMetaData beanMetaData = (AbstractBeanMetaData)context.getBeanMetaData();
+ List<CallbackMetaData> callbacks = getCallbacks(beanMetaData);
+ AbstractCallbackMetaData callback = createCallback(info, annotation);
+ callbacks.add(callback);
+ executeVisit(context, callback);
+ }
+
+ protected abstract AbstractCallbackMetaData createCallback(T info, C annotation);
+
+ protected abstract void applyInfo(AbstractCallbackMetaData callback, T info);
+
+ protected abstract List<CallbackMetaData> getCallbacks(AbstractBeanMetaData beanMetaData);
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+
+import org.jboss.reflect.spi.ClassInfo;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class ClassAnnotationPlugin<C extends Annotation> extends AbstractAnnotationPlugin<ClassInfo, C>
+{
+ protected ClassAnnotationPlugin(Class<C> annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.TYPE == type;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+
+import org.jboss.reflect.spi.ConstructorInfo;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class ConstructorAnnotationPlugin<C extends Annotation> extends AbstractAnnotationPlugin<ConstructorInfo, C>
+{
+ protected ConstructorAnnotationPlugin(Class<C> annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.CONSTRUCTOR == type;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorParameterAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.ElementType;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Constructor;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.ParameterInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ConstructorParameterAnnotationPlugin extends AbstractParameterAnnotationPlugin<ConstructorInfo, Constructor, AbstractConstructorMetaData>
+{
+ protected ConstructorParameterAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(Constructor.class, adapters);
+ }
+
+ protected boolean checkAnnotatedInfo(ElementType type)
+ {
+ return ElementType.CONSTRUCTOR == type;
+ }
+
+ protected boolean isMetaDataAlreadyPresent(ConstructorInfo info, Constructor annotation, BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getConstructor() != null;
+ }
+
+ protected ParameterInfo[] getParameters(ConstructorInfo info)
+ {
+ return info.getParameters();
+ }
+
+ protected void handleParameterlessInfo(ConstructorInfo info, Constructor annotation, BeanMetaData beanMetaData)
+ {
+ // do nothing, default will be used
+ }
+
+ protected AbstractConstructorMetaData createParametrizedMetaData(ConstructorInfo info)
+ {
+ return new AbstractConstructorMetaData();
+ }
+
+ protected void setParameterizedMetaData(AbstractConstructorMetaData parameterizedMetaData, BeanMetaData beanMetaData)
+ {
+ AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+ abmd.setConstructor(parameterizedMetaData);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CreateLifecycleAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Create;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CreateLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Create>
+{
+ protected CreateLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(Create.class, adapters);
+ }
+
+ protected boolean isLifecyclePresent(BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getCreate() != null;
+ }
+
+ protected void applyLifecycleAnnotation(AbstractLifecycleMetaData lifecycle, Create annotation)
+ {
+ lifecycle.setIgnored(annotation.ignored());
+ }
+
+ protected void setLifecycleMetaData(AbstractBeanMetaData beanMetaData, AbstractLifecycleMetaData lifecycle)
+ {
+ lifecycle.setType("create");
+ beanMetaData.setCreate(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.util.Set;
+import java.util.HashSet;
+
+import org.jboss.beans.metadata.plugins.annotations.Demands;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DemandsAnnotationPlugin extends ClassAnnotationPlugin<Demands>
+{
+ public DemandsAnnotationPlugin()
+ {
+ super(Demands.class);
+ }
+
+ protected void internalApplyAnnotation(ClassInfo info, Demands annotation, KernelControllerContext context)
+ {
+ BeanMetaData beanMetaData = context.getBeanMetaData();
+ Set<DemandMetaData> demands = beanMetaData.getDemands();
+ if (demands == null)
+ {
+ demands = new HashSet<DemandMetaData>();
+ ((AbstractBeanMetaData)beanMetaData).setDemands(demands);
+ }
+ MetaDataVisitor visitor = getMetaDataVisitor(context);
+ for(String demand : annotation.value())
+ {
+ AbstractDemandMetaData admd = new AbstractDemandMetaData(demand);
+ demands.add(admd);
+ admd.initialVisit(visitor);
+ admd.describeVisit(visitor);
+ }
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.util.Set;
+import java.util.HashSet;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Depends;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DependsAnnotationPlugin extends ClassAnnotationPlugin<Depends>
+{
+ public DependsAnnotationPlugin()
+ {
+ super(Depends.class);
+ }
+
+ protected void internalApplyAnnotation(ClassInfo info, Depends annotation, KernelControllerContext context)
+ {
+ BeanMetaData beanMetaData = context.getBeanMetaData();
+ Set<DependencyMetaData> dependencies = beanMetaData.getDepends();
+ if (dependencies == null)
+ {
+ dependencies = new HashSet<DependencyMetaData>();
+ ((AbstractBeanMetaData)beanMetaData).setDepends(dependencies);
+ }
+ MetaDataVisitor visitor = getMetaDataVisitor(context);
+ for(String depends : annotation.value())
+ {
+ AbstractDependencyMetaData dependency = new AbstractDependencyMetaData(depends);
+ dependencies.add(dependency);
+ dependency.initialVisit(visitor);
+ dependency.describeVisit(visitor);
+ }
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DestroyLifecycleAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Destroy;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DestroyLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Destroy>
+{
+ protected DestroyLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(Destroy.class, adapters);
+ }
+
+ protected boolean isLifecyclePresent(BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getDestroy() != null;
+ }
+
+ protected void applyLifecycleAnnotation(AbstractLifecycleMetaData lifecycle, Destroy annotation)
+ {
+ lifecycle.setIgnored(annotation.ignored());
+ }
+
+ protected void setLifecycleMetaData(AbstractBeanMetaData beanMetaData, AbstractLifecycleMetaData lifecycle)
+ {
+ lifecycle.setType("destroy");
+ beanMetaData.setDestroy(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.ElementType;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.annotations.FactoryMethod;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.ParameterInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryMethodAnnotationPlugin extends AbstractParameterAnnotationPlugin<MethodInfo, FactoryMethod, AbstractConstructorMetaData>
+{
+ public FactoryMethodAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(FactoryMethod.class, adapters);
+ }
+
+ protected boolean checkAnnotatedInfo(ElementType type)
+ {
+ return ElementType.METHOD == type;
+ }
+
+ protected boolean isMetaDataAlreadyPresent(MethodInfo info, FactoryMethod annotation, BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getConstructor() != null;
+ }
+
+ protected ParameterInfo[] getParameters(MethodInfo info)
+ {
+ return info.getParameters();
+ }
+
+ protected void handleParameterlessInfo(MethodInfo info, FactoryMethod annotation, BeanMetaData beanMetaData)
+ {
+ setParameterizedMetaData(createParametrizedMetaData(info, annotation, beanMetaData), beanMetaData);
+ }
+
+ protected AbstractConstructorMetaData createParametrizedMetaData(MethodInfo info, FactoryMethod annotation, BeanMetaData beanMetaData)
+ {
+ AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
+ constructor.setFactoryClass(beanMetaData.getBean());
+ constructor.setFactoryMethod(info.getName());
+ return constructor;
+ }
+
+ protected void setParameterizedMetaData(AbstractConstructorMetaData parameterizedMetaData, BeanMetaData beanMetaData)
+ {
+ AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+ abmd.setConstructor(parameterizedMetaData);
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FieldAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FieldAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FieldAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+
+import org.jboss.reflect.spi.FieldInfo;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class FieldAnnotationPlugin<C extends Annotation> extends AbstractAnnotationPlugin<FieldInfo, C>
+{
+ protected FieldAnnotationPlugin(Class<C> annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.FIELD == type;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.annotations;
+
+import org.jboss.beans.metadata.plugins.annotations.Inject;
+import org.jboss.beans.metadata.plugins.annotations.FromContext;
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.beans.metadata.plugins.InjectionOption;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.AutowireType;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InjectAnnotationPlugin extends PropertyAnnotationPlugin<Inject>
+{
+ static InjectAnnotationPlugin INSTANCE = new InjectAnnotationPlugin();
+
+ public InjectAnnotationPlugin()
+ {
+ super(Inject.class);
+ }
+
+ public ValueMetaData createValueMetaData(Inject annotation)
+ {
+ AbstractInjectionValueMetaData injection = new AbstractInjectionValueMetaData();
+ if (isAttributePresent(annotation.bean()))
+ injection.setValue(annotation.bean());
+ if (isAttributePresent(annotation.property()))
+ injection.setProperty(annotation.property());
+ injection.setDependentState(new ControllerState(annotation.dependentState()));
+ if (isAttributePresent(annotation.whenRequired()))
+ injection.setWhenRequiredState(new ControllerState(annotation.whenRequired()));
+ injection.setInjectionOption(InjectionOption.getInstance(annotation.option().toString()));
+ injection.setInjectionType(AutowireType.getInstance(annotation.type().toString()));
+ if (FromContext.NONE.equals(annotation.fromContext()) == false)
+ injection.setFromContext(org.jboss.beans.metadata.plugins.FromContext.getInstance(annotation.fromContext().toString()));
+ return injection;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.plugins.InstallCallbackMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Install;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.reflect.spi.AnnotatedInfo;
+
+/**
+ * @param <T> info type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class InstallCallbackAnnotationPlugin<T extends AnnotatedInfo> extends CallbackAnnotationPlugin<T, Install>
+{
+ protected InstallCallbackAnnotationPlugin()
+ {
+ super(Install.class);
+ }
+
+ protected Set<CallbackItem> getCallbacks(DependencyInfo dependency)
+ {
+ return dependency.getInstallItems();
+ }
+
+ protected AbstractCallbackMetaData createCallback(T info, Install annotation)
+ {
+ InstallCallbackMetaData callback = new InstallCallbackMetaData();
+ callback.setWhenRequired(new ControllerState(annotation.whenRequired()));
+ callback.setDependentState(new ControllerState(annotation.dependentState()));
+ if (isAttributePresent(annotation.cardinality()))
+ callback.setCardinality(Cardinality.fromString(annotation.cardinality()));
+ applyInfo(callback, info);
+ return callback;
+ }
+
+ protected List<CallbackMetaData> getCallbacks(AbstractBeanMetaData beanMetaData)
+ {
+ List<CallbackMetaData> callbacks = beanMetaData.getInstallCallbacks();
+ if (callbacks == null)
+ {
+ callbacks = new ArrayList<CallbackMetaData>();
+ beanMetaData.setInstallCallbacks(callbacks);
+ }
+ return callbacks;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,72 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.annotations.InstallMethod;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstallMethodParameterAnnotationPlugin extends InstallationParameterAnnotationPlugin<InstallMethod>
+{
+ protected InstallMethodParameterAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(InstallMethod.class, adapters);
+ }
+
+ protected List<InstallMetaData> getInstalls(BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getInstalls();
+ }
+
+ protected AbstractInstallMetaData createParametrizedMetaData(MethodInfo info, InstallMethod annotation)
+ {
+ AbstractInstallMetaData install = new AbstractInstallMetaData();
+ install.setMethodName(info.getName());
+ if (isAttributePresent(annotation.bean()))
+ install.setBean(annotation.bean());
+ if (isAttributePresent(annotation.dependantState()))
+ install.setDependentState(new ControllerState(annotation.dependantState()));
+ return install;
+ }
+
+ protected void setParameterizedMetaData(AbstractInstallMetaData parameterizedMetaData, BeanMetaData beanMetaData)
+ {
+ AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+ List<InstallMetaData> installs = beanMetaData.getInstalls();
+ if (installs == null)
+ {
+ installs = new ArrayList<InstallMetaData>();
+ abmd.setInstalls(installs);
+ }
+ installs.add(parameterizedMetaData);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.util.List;
+
+import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.ParameterInfo;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class InstallationParameterAnnotationPlugin<C extends Annotation> extends AbstractParameterAnnotationPlugin<MethodInfo, C, AbstractInstallMetaData>
+{
+ protected InstallationParameterAnnotationPlugin(Class<C> annotation, Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(annotation, adapters);
+ }
+
+ protected boolean checkAnnotatedInfo(ElementType type)
+ {
+ return ElementType.METHOD == type;
+ }
+
+ protected boolean isMetaDataAlreadyPresent(MethodInfo info, C annotation, BeanMetaData beanMetaData)
+ {
+ List<InstallMetaData> installs = getInstalls(beanMetaData);
+ if (installs != null && installs.isEmpty() == false)
+ {
+ for(InstallMetaData install : installs)
+ {
+ // cannot compare when bean is set
+ if (install.getBean() != null)
+ continue;
+ if (install.getMethodName().equals(info.getName()))
+ {
+ List<ParameterMetaData> parameters = install.getParameters();
+ ParameterInfo[] parameterInfos = info.getParameters();
+ if (parameters != null && parameterInfos != null && parameters.size() == parameterInfos.length)
+ return true;
+ if (parameters == null && parameterInfos != null && parameterInfos.length == 0)
+ return true;
+ if (parameters != null && parameters.size() == 0 && parameterInfos == null)
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected abstract List<InstallMetaData> getInstalls(BeanMetaData beanMetaData);
+
+ protected ParameterInfo[] getParameters(MethodInfo info)
+ {
+ return info.getParameters();
+ }
+
+ protected void handleParameterlessInfo(MethodInfo info, C annotation, BeanMetaData beanMetaData)
+ {
+ setParameterizedMetaData(createParametrizedMetaData(info, annotation), beanMetaData);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.ParameterInfo;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class LifecycleParameterAnnotationPlugin<C extends Annotation> extends AbstractParameterAnnotationPlugin<MethodInfo, C, AbstractLifecycleMetaData>
+{
+ protected LifecycleParameterAnnotationPlugin(Class<C> annotation, Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(annotation, adapters);
+ }
+
+ protected boolean checkAnnotatedInfo(ElementType type)
+ {
+ return ElementType.METHOD == type;
+ }
+
+ protected abstract boolean isLifecyclePresent(BeanMetaData beanMetaData);
+
+ protected AbstractLifecycleMetaData createLifecycleMetaData(String method, C annotation)
+ {
+ AbstractLifecycleMetaData lifecycle = new AbstractLifecycleMetaData(method);
+ applyLifecycleAnnotation(lifecycle, annotation);
+ return lifecycle;
+ }
+
+ protected abstract void applyLifecycleAnnotation(AbstractLifecycleMetaData lifecycle, C annotation);
+
+ protected abstract void setLifecycleMetaData(AbstractBeanMetaData beanMetaData, AbstractLifecycleMetaData lifecycle);
+
+ protected boolean isMetaDataAlreadyPresent(MethodInfo info, C annotation, BeanMetaData beanMetaData)
+ {
+ return isLifecyclePresent(beanMetaData);
+ }
+
+ protected ParameterInfo[] getParameters(MethodInfo info)
+ {
+ return info.getParameters();
+ }
+
+ protected void handleParameterlessInfo(MethodInfo info, C annotation, BeanMetaData beanMetaData)
+ {
+ AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+ setLifecycleMetaData(abmd, createLifecycleMetaData(info.getName(), annotation));
+ }
+
+ protected AbstractLifecycleMetaData createParametrizedMetaData(MethodInfo info, C annotation)
+ {
+ return createLifecycleMetaData(info.getName(), annotation);
+ }
+
+ protected void setParameterizedMetaData(AbstractLifecycleMetaData parameterizedMetaData, BeanMetaData beanMetaData)
+ {
+ AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+ setLifecycleMetaData(abmd, parameterizedMetaData);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class MethodAnnotationPlugin<C extends Annotation> extends AbstractAnnotationPlugin<MethodInfo, C>
+{
+ protected MethodAnnotationPlugin(Class<C> annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.METHOD == type;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.annotations;
+
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MethodInstallCallbackAnnotationPlugin extends InstallCallbackAnnotationPlugin<MethodInfo>
+{
+ public MethodInstallCallbackAnnotationPlugin()
+ {
+ super();
+ }
+
+ protected boolean isNameEqual(MethodInfo info, String attributeName)
+ {
+ return attributeName.equals(info.getName());
+ }
+
+ protected void applyInfo(AbstractCallbackMetaData callback, MethodInfo info)
+ {
+ callback.setMethodInfo(info);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.annotations;
+
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MethodUninstallCallbackAnnotationPlugin extends UninstallCallbackAnnotationPlugin<MethodInfo>
+{
+ public MethodUninstallCallbackAnnotationPlugin()
+ {
+ super();
+ }
+
+ protected boolean isNameEqual(MethodInfo info, String attributeName)
+ {
+ return attributeName.equals(info.getName());
+ }
+
+ protected void applyInfo(AbstractCallbackMetaData callback, MethodInfo info)
+ {
+ callback.setMethodInfo(info);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/NullValueAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/NullValueAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/NullValueAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.plugins.annotations.NullValue;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class NullValueAnnotationPlugin extends PropertyAnnotationPlugin<NullValue>
+{
+ static NullValueAnnotationPlugin INSTANCE = new NullValueAnnotationPlugin();
+
+ public NullValueAnnotationPlugin()
+ {
+ super(NullValue.class);
+ }
+
+ public ValueMetaData createValueMetaData(NullValue annotation)
+ {
+ return new AbstractValueMetaData();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class PropertyAnnotationPlugin<C extends Annotation> extends AbstractAnnotationPlugin<PropertyInfo, C>
+ implements PropertyAware, Annotation2ValueMetaDataAdapter<C>
+{
+ protected PropertyAnnotationPlugin(Class<C> annotation)
+ {
+ super(annotation);
+ }
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.METHOD == type || ElementType.PARAMETER == type;
+ }
+
+ protected boolean isMetaDataAlreadyPresent(PropertyInfo info, C annotation, BeanMetaData beanMetaData)
+ {
+ Set<PropertyMetaData> properties = beanMetaData.getProperties();
+ if (properties != null && properties.isEmpty() == false)
+ {
+ for(PropertyMetaData pmd : properties)
+ {
+ if (pmd.getName().equals(info.getName()))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void internalApplyAnnotation(PropertyInfo info, C annotation, KernelControllerContext context)
+ {
+ Set<PropertyMetaData> properties = getProperties(context);
+ PropertyMetaData property = getPropertyMetaData(info, annotation, context);
+ properties.add(property);
+ executeVisit(context, property);
+ }
+
+ protected PropertyMetaData getPropertyMetaData(PropertyInfo info, C annotation, KernelControllerContext context)
+ {
+ return getPropertyMetaData(info, annotation);
+ }
+
+ protected PropertyMetaData getPropertyMetaData(PropertyInfo info, C annotation)
+ {
+ ValueMetaData value = createValueMetaData(annotation);
+ return new AbstractPropertyMetaData(info.getName(), value);
+ }
+
+ protected Set<PropertyMetaData> getProperties(KernelControllerContext context)
+ {
+ BeanMetaData beanMetaData = context.getBeanMetaData();
+ Set<PropertyMetaData> properties = beanMetaData.getProperties();
+ if (properties == null)
+ {
+ properties = new HashSet<PropertyMetaData>();
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)beanMetaData;
+ bean.setProperties(properties);
+ }
+ return properties;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAware.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAware.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAware.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+
+/**
+ * Marker interface.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface PropertyAware
+{
+ void applyAnnotation(PropertyInfo info, MetaDataRetrieval retrieval, KernelControllerContext context) throws Throwable;
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.annotations;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyInstallCallbackAnnotationPlugin extends InstallCallbackAnnotationPlugin<PropertyInfo> implements PropertyAware
+{
+ public PropertyInstallCallbackAnnotationPlugin()
+ {
+ super();
+ }
+
+ protected boolean isNameEqual(PropertyInfo info, String attributeName)
+ {
+ return attributeName.equals(info.getName());
+ }
+
+ protected void applyInfo(AbstractCallbackMetaData callback, PropertyInfo info)
+ {
+ callback.setPropertyInfo(info);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.annotations;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyUninstallCallbackAnnotationPlugin extends UninstallCallbackAnnotationPlugin<PropertyInfo> implements PropertyAware
+{
+ public PropertyUninstallCallbackAnnotationPlugin()
+ {
+ super();
+ }
+
+ protected boolean isNameEqual(PropertyInfo info, String attributeName)
+ {
+ return attributeName.equals(info.getName());
+ }
+
+ protected void applyInfo(AbstractCallbackMetaData callback, PropertyInfo info)
+ {
+ callback.setPropertyInfo(info);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StartLifecycleAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Start;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class StartLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Start>
+{
+ protected StartLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(Start.class, adapters);
+ }
+
+ protected boolean isLifecyclePresent(BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getStart() != null;
+ }
+
+ protected void applyLifecycleAnnotation(AbstractLifecycleMetaData lifecycle, Start annotation)
+ {
+ lifecycle.setIgnored(annotation.ignored());
+ }
+
+ protected void setLifecycleMetaData(AbstractBeanMetaData beanMetaData, AbstractLifecycleMetaData lifecycle)
+ {
+ lifecycle.setType("start");
+ beanMetaData.setStart(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StopLifecycleAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Stop;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class StopLifecycleAnnotationPlugin extends LifecycleParameterAnnotationPlugin<Stop>
+{
+ protected StopLifecycleAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(Stop.class, adapters);
+ }
+
+ protected boolean isLifecyclePresent(BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getStop() != null;
+ }
+
+ protected void applyLifecycleAnnotation(AbstractLifecycleMetaData lifecycle, Stop annotation)
+ {
+ lifecycle.setIgnored(annotation.ignored());
+ }
+
+ protected void setLifecycleMetaData(AbstractBeanMetaData beanMetaData, AbstractLifecycleMetaData lifecycle)
+ {
+ lifecycle.setType("stop");
+ beanMetaData.setStop(lifecycle);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StringValueAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StringValueAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/StringValueAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class StringValueAnnotationPlugin extends PropertyAnnotationPlugin<StringValue>
+{
+ static StringValueAnnotationPlugin INSTANCE = new StringValueAnnotationPlugin();
+
+ public StringValueAnnotationPlugin()
+ {
+ super(StringValue.class);
+ }
+
+ public ValueMetaData createValueMetaData(StringValue annotation)
+ {
+ StringValueMetaData value = new StringValueMetaData(annotation.value());
+ if (isAttributePresent(annotation.type()))
+ value.setType(annotation.type());
+ return value;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.util.Set;
+import java.util.HashSet;
+
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Supplys;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.reflect.spi.ClassInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SupplysAnnotationPlugin extends ClassAnnotationPlugin<Supplys>
+{
+ public SupplysAnnotationPlugin()
+ {
+ super(Supplys.class);
+ }
+
+ protected void internalApplyAnnotation(ClassInfo info, Supplys annotation, BeanMetaData beanMetaData)
+ {
+ Set<SupplyMetaData> supplies = beanMetaData.getSupplies();
+ if (supplies == null)
+ {
+ supplies = new HashSet<SupplyMetaData>();
+ ((AbstractBeanMetaData)beanMetaData).setSupplies(supplies);
+ }
+ for(String supply : annotation.value())
+ {
+ supplies.add(new AbstractSupplyMetaData(supply));
+ }
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ThisValueAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ThisValueAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ThisValueAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.kernel.plugins.annotations;
+
+import org.jboss.beans.metadata.plugins.ThisValueMetaData;
+import org.jboss.beans.metadata.plugins.annotations.ThisValue;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ThisValueAnnotationPlugin extends PropertyAnnotationPlugin<ThisValue>
+{
+ static ThisValueAnnotationPlugin INSTANCE = new ThisValueAnnotationPlugin();
+
+ public ThisValueAnnotationPlugin()
+ {
+ super(ThisValue.class);
+ }
+
+ public ValueMetaData createValueMetaData(ThisValue annotation)
+ {
+ return new ThisValueMetaData();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.plugins.UninstallCallbackMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Uninstall;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.reflect.spi.AnnotatedInfo;
+
+/**
+ * @param <T> info type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class UninstallCallbackAnnotationPlugin<T extends AnnotatedInfo> extends CallbackAnnotationPlugin<T, Uninstall>
+{
+ protected UninstallCallbackAnnotationPlugin()
+ {
+ super(Uninstall.class);
+ }
+
+ protected Set<CallbackItem> getCallbacks(DependencyInfo dependency)
+ {
+ return dependency.getUninstallItems();
+ }
+
+ protected AbstractCallbackMetaData createCallback(T info, Uninstall annotation)
+ {
+ UninstallCallbackMetaData callback = new UninstallCallbackMetaData();
+ callback.setWhenRequired(new ControllerState(annotation.whenRequired()));
+ callback.setDependentState(new ControllerState(annotation.dependentState()));
+ if (isAttributePresent(annotation.cardinality()))
+ callback.setCardinality(Cardinality.fromString(annotation.cardinality()));
+ applyInfo(callback, info);
+ return callback;
+ }
+
+ protected List<CallbackMetaData> getCallbacks(AbstractBeanMetaData beanMetaData)
+ {
+ List<CallbackMetaData> callbacks = beanMetaData.getUninstallCallbacks();
+ if (callbacks == null)
+ {
+ callbacks = new ArrayList<CallbackMetaData>();
+ beanMetaData.setUninstallCallbacks(callbacks);
+ }
+ return callbacks;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,72 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.annotations;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
+import org.jboss.beans.metadata.plugins.annotations.UninstallMethod;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class UninstallMethodParameterAnnotationPlugin extends InstallationParameterAnnotationPlugin<UninstallMethod>
+{
+ protected UninstallMethodParameterAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(UninstallMethod.class, adapters);
+ }
+
+ protected List<InstallMetaData> getInstalls(BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getUninstalls();
+ }
+
+ protected AbstractInstallMetaData createParametrizedMetaData(MethodInfo info, UninstallMethod annotation)
+ {
+ AbstractInstallMetaData uninstall = new AbstractInstallMetaData();
+ uninstall.setMethodName(info.getName());
+ if (isAttributePresent(annotation.bean()))
+ uninstall.setBean(annotation.bean());
+ if (isAttributePresent(annotation.dependantState()))
+ uninstall.setDependentState(new ControllerState(annotation.dependantState()));
+ return uninstall;
+ }
+
+ protected void setParameterizedMetaData(AbstractInstallMetaData parameterizedMetaData, BeanMetaData beanMetaData)
+ {
+ AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+ List<InstallMetaData> uninstalls = beanMetaData.getUninstalls();
+ if (uninstalls == null)
+ {
+ uninstalls = new ArrayList<InstallMetaData>();
+ abmd.setUninstalls(uninstalls);
+ }
+ uninstalls.add(parameterizedMetaData);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryAnnotationPlugin.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.annotations;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.beans.metadata.plugins.annotations.ValueFactory;
+import org.jboss.beans.metadata.plugins.AbstractValueFactoryMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ValueFactoryAnnotationPlugin extends PropertyAnnotationPlugin<ValueFactory>
+{
+ static ValueFactoryAnnotationPlugin INSTANCE = new ValueFactoryAnnotationPlugin();
+
+ public ValueFactoryAnnotationPlugin()
+ {
+ super(ValueFactory.class);
+ }
+
+ public ValueMetaData createValueMetaData(ValueFactory annotation)
+ {
+ AbstractValueFactoryMetaData factory = new AbstractValueFactoryMetaData(annotation.bean(), annotation.method());
+ if (isAttributePresent(annotation.defaultValue()))
+ factory.setDefaultValue(annotation.defaultValue());
+ List<ParameterMetaData> parameters = new ArrayList<ParameterMetaData>();
+ parameters.add(new AbstractParameterMetaData(String.class.getName(), annotation.parameter()));
+ factory.setParameters(parameters);
+ factory.setDependentState(new ControllerState(annotation.dependantState()));
+ factory.setWhenRequiredState(new ControllerState(annotation.whenRequiredState()));
+ return factory;
+ }
+}
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-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -52,9 +52,7 @@
public CollectionCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality, InvokeDispatchContext context, AttributeInfo attribute)
{
- super(name, whenRequired, dependentState, context);
- if (attribute == null)
- throw new IllegalArgumentException("Null attribute!");
+ super(name, whenRequired, dependentState, attribute != null ? attribute.getName() : null, context);
this.attribute = attribute;
this.cardinality = cardinality;
}
@@ -99,9 +97,9 @@
protected void execute(T holder) throws Throwable
{
if (attribute.isProperty())
- owner.set(attribute.getName(), holder);
+ owner.set(getAttributeName(), holder);
else
- owner.invoke(attribute.getName(), new Object[]{holder}, new String[]{attribute.getType().getName()});
+ owner.invoke(getAttributeName(), new Object[]{holder}, new String[]{attribute.getType().getName()});
}
protected DependencyItem createDependencyItem(ControllerContext owner)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CreateDestroyLifecycleAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CreateDestroyLifecycleAction.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CreateDestroyLifecycleAction.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -23,8 +23,6 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.LifecycleMetaData;
-import org.jboss.beans.metadata.spi.annotations.CreateLifecycle;
-import org.jboss.beans.metadata.spi.annotations.DestroyLifecycle;
import org.jboss.kernel.spi.dependency.CreateKernelControllerContextAware;
import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
@@ -47,11 +45,6 @@
return "create";
}
- public String getInstallAnnotation()
- {
- return CreateLifecycle.class.getName();
- }
-
protected Class<? extends KernelControllerContextAware> getActionAwareInterface()
{
return CreateKernelControllerContextAware.class;
@@ -66,9 +59,4 @@
{
return "destroy";
}
-
- public String getUninstallAnnotation()
- {
- return DestroyLifecycle.class.getName();
- }
}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -28,6 +28,7 @@
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
+import org.jboss.kernel.plugins.annotations.BeanAnnotationAdapterFactory;
import org.jboss.metadata.spi.MetaData;
/**
@@ -50,13 +51,15 @@
// add custom dependencies (e.g. AOP layer).
List<DependencyBuilderListItem> dependencies = info.getDependencies(md);
log.trace("Extra dependencies for " + context.getName() + " " + dependencies);
- if (dependencies != null)
+ if (dependencies != null && dependencies.isEmpty() == false)
{
for (DependencyBuilderListItem dependencyItem : dependencies)
{
dependencyItem.addDependency(context);
}
}
+ // handle custom annotations
+ BeanAnnotationAdapterFactory.getBeanAnnotationAdapter().applyAnnotations(context);
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/LifecycleAction.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -22,7 +22,6 @@
package org.jboss.kernel.plugins.dependency;
import java.util.List;
-import java.util.Set;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.metadata.spi.BeanMetaData;
@@ -35,9 +34,6 @@
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.Value;
/**
* LifecycleAction.
@@ -116,13 +112,6 @@
public abstract String getDefaultInstallMethod();
/**
- * Get install annotation class name
- *
- * @return install annotation name
- */
- public abstract String getInstallAnnotation();
-
- /**
* Get the install parameters
*
* @param beanMetaData bean meta data
@@ -152,13 +141,6 @@
public abstract String getDefaultUninstallMethod();
/**
- * Get uninstall annotation class name
- *
- * @return uninstall annotation name
- */
- public abstract String getUninstallAnnotation();
-
- /**
* Get the uninstall parameters
*
* @param beanMetaData bean meta data
@@ -177,7 +159,7 @@
*/
protected boolean isInstallInvocationIgnored(KernelControllerContext context)
{
- return isInvocationIgnored(getInstallLifecycle(context.getBeanMetaData())) || isInvocationIgnored(context, getInstallAnnotation());
+ return isInvocationIgnored(getInstallLifecycle(context.getBeanMetaData()));
}
/**
@@ -188,7 +170,7 @@
*/
protected boolean isUninstallInvocationIgnored(KernelControllerContext context)
{
- return isInvocationIgnored(getUninstallLifecycle(context.getBeanMetaData())) || isInvocationIgnored(context, getUninstallAnnotation());
+ return isInvocationIgnored(getUninstallLifecycle(context.getBeanMetaData()));
}
/**
@@ -202,55 +184,6 @@
return lifecycle != null && lifecycle.isIgnored();
}
- /**
- * Is invocation ignored due to annotation ignored attibute.
- *
- * @param context the context
- * @param annotationName annotation name
- * @return true if ignored found on annotation
- */
- protected boolean isInvocationIgnored(KernelControllerContext context, String annotationName)
- {
- MethodInfo mi = findMethodWithAnnotation(context, annotationName);
- if (mi != null)
- {
- AnnotationValue av = mi.getAnnotation(annotationName);
- Value value = av.getValue("ignored");
- if (value != null)
- {
- return Boolean.parseBoolean(value.asPrimitive().getValue());
- }
- }
- return false;
- }
-
- /**
- * Find method with annotation matching name parameter.
- *
- * @param context the context
- * @param annotationName annotation name
- * @return method info instance or null if no such method exists
- */
- protected MethodInfo findMethodWithAnnotation(KernelControllerContext context, String annotationName)
- {
- BeanInfo info = context.getBeanInfo();
- if (info != null)
- {
- Set<MethodInfo> methods = info.getMethods();
- if (methods != null)
- {
- for (MethodInfo mi : methods)
- {
- if (mi.isAnnotationPresent(annotationName))
- {
- return mi;
- }
- }
- }
- }
- return null;
- }
-
protected void installActionInternal(KernelControllerContext context) throws Throwable
{
boolean trace = log.isTraceEnabled();
@@ -347,11 +280,6 @@
{
return installMethod;
}
- MethodInfo mi = findMethodWithAnnotation(context, getInstallAnnotation());
- if (mi != null)
- {
- return mi.getName();
- }
return getDefaultInstallMethod();
}
@@ -380,11 +308,6 @@
{
return uninstallMethod;
}
- MethodInfo mi = findMethodWithAnnotation(context, getUninstallAnnotation());
- if (mi != null)
- {
- return mi.getName();
- }
return getDefaultUninstallMethod();
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/StartStopLifecycleAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/StartStopLifecycleAction.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/StartStopLifecycleAction.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -23,8 +23,6 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.LifecycleMetaData;
-import org.jboss.beans.metadata.spi.annotations.StartLifecycle;
-import org.jboss.beans.metadata.spi.annotations.StopLifecycle;
import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
import org.jboss.kernel.spi.dependency.StartKernelControllerContextAware;
@@ -47,11 +45,6 @@
return "start";
}
- public String getInstallAnnotation()
- {
- return StartLifecycle.class.getName();
- }
-
protected Class<? extends KernelControllerContextAware> getActionAwareInterface()
{
return StartKernelControllerContextAware.class;
@@ -66,9 +59,4 @@
{
return "stop";
}
-
- public String getUninstallAnnotation()
- {
- return StopLifecycle.class.getName();
- }
}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -198,7 +198,7 @@
{
for (Iterator i = notInstalled.iterator(); i.hasNext();)
{
- KernelControllerContext context = (KernelControllerContext) i.next();
+ ControllerContext context = (ControllerContext) i.next();
if (context.getState().equals(context.getRequiredState()))
i.remove();
}
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="SimpleBean" class="org.jboss.test.kernel.annotations.support.SimpleInject" />
+
+ <bean name="testBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
+
+ <bean name="otherBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
+
+ <bean name="serviceBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
+
+ <bean name="valueBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
+
+ <bean name="lifecycleBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
+
+ <bean name="deployer1" class="org.jboss.test.kernel.annotations.support.MyDeployer" />
+
+ <bean name="deployer2" class="org.jboss.test.kernel.annotations.support.MyDeployer" />
+
+ <bean name="testconst" class="org.jboss.test.kernel.annotations.support.TestConstructorBean" />
+
+</deployment>
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -35,6 +35,7 @@
import org.jboss.test.kernel.registry.test.RegistryTestSuite;
import org.jboss.test.kernel.inject.test.ContextualInjectionTestSuite;
import org.jboss.test.kernel.metadata.test.MetaDataTestSuite;
+import org.jboss.test.kernel.annotations.test.AnnotationsTestSuite;
/**
* Kernel Test Suite.
@@ -63,6 +64,7 @@
suite.addTest(ContextualInjectionTestSuite.suite());
suite.addTest(XMLTestSuite.suite());
suite.addTest(MetaDataTestSuite.suite());
+ suite.addTest(AnnotationsTestSuite.suite());
return suite;
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/MyDeployer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/MyDeployer.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/MyDeployer.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.annotations.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MyDeployer
+{
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.annotations.support;
+
+import java.util.Set;
+import java.util.HashSet;
+
+import org.jboss.beans.metadata.plugins.annotations.Aliases;
+import org.jboss.beans.metadata.plugins.annotations.Demands;
+import org.jboss.beans.metadata.plugins.annotations.Depends;
+import org.jboss.beans.metadata.plugins.annotations.FactoryMethod;
+import org.jboss.beans.metadata.plugins.annotations.Inject;
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+import org.jboss.beans.metadata.plugins.annotations.Supplys;
+import org.jboss.beans.metadata.plugins.annotations.ValueFactory;
+import org.jboss.beans.metadata.plugins.annotations.Install;
+import org.jboss.beans.metadata.plugins.annotations.Uninstall;
+import org.jboss.beans.metadata.plugins.annotations.Start;
+import org.jboss.beans.metadata.plugins.annotations.InstallMethod;
+import org.jboss.beans.metadata.plugins.annotations.ThisValue;
+import org.jboss.beans.metadata.plugins.annotations.NullValue;
+import org.jboss.beans.metadata.plugins.annotations.UninstallMethod;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Aliases({"al", "test"})
+ at Demands({"otherBean"})
+ at Depends({"serviceBean"})
+ at Supplys({"txBean"})
+public class SimpleInject
+{
+ private int intVF;
+ private TestBean testBean;
+ private Set<MyDeployer> deployers;
+
+ public int getVf()
+ {
+ return intVF;
+ }
+
+ @FactoryMethod
+ public static SimpleInject getInstance(@NullValue Object someNull)
+ {
+ return new SimpleInject();
+ }
+
+ @Start
+ public void startMeUp(@Inject(bean = "lifecycleBean") TestBean bean, @ValueFactory(bean="valueBean", method = "getValue", parameter = "123") int value)
+ {
+ intVF =- value;
+ }
+
+ @StringValue("123")
+ public void setVf(int vf)
+ {
+ this.intVF = vf;
+ }
+
+ @Install
+ public void addDeployer(MyDeployer deployer)
+ {
+ if (deployers == null)
+ deployers = new HashSet<MyDeployer>();
+ deployers.add(deployer);
+ }
+
+ @Uninstall
+ public void removeDeployer(MyDeployer deployer)
+ {
+ deployers.remove(deployer);
+ }
+
+ @InstallMethod
+ public void whenInstalled(@ThisValue SimpleInject me, @NullValue Object plainNull)
+ {
+ System.out.println(me == this);
+ System.out.println("plainNull = " + plainNull);
+ }
+
+ @UninstallMethod
+ public void withUninstall(@ThisValue SimpleInject me, @NullValue Object plainNull)
+ {
+ System.out.println(me == this);
+ System.out.println("plainNull = " + plainNull);
+ }
+
+ public TestBean getTestBean()
+ {
+ return testBean;
+ }
+
+ @Inject(bean = "testBean")
+ public void setTestBean(TestBean bean)
+ {
+ this.testBean = bean;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestBean.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.annotations.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestBean
+{
+ public String getValue(String param)
+ {
+ return param.toUpperCase();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestConstructorBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestConstructorBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/TestConstructorBean.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.Inject;
+import org.jboss.beans.metadata.plugins.annotations.Constructor;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestConstructorBean
+{
+ @Constructor
+ public TestConstructorBean(@Inject(bean = "testBean") TestBean test)
+ {
+ System.out.println("test = " + test);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -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.test.kernel.annotations.test;
+
+import junit.framework.TestSuite;
+import junit.framework.Test;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Annotations Tests");
+ suite.addTest(InjectAnnotationTestCase.suite());
+ return suite;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.annotations.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.deployment.test.AbstractDeploymentTest;
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InjectAnnotationTestCase extends AbstractDeploymentTest
+{
+ public InjectAnnotationTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(InjectAnnotationTestCase.class);
+ }
+
+ public void testInjection() throws Throwable
+ {
+ ControllerContext context = getControllerContext("SimpleBean");
+ assertNotNull(context);
+ System.out.println("context = " + context);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/AnnotatedLifecycleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/AnnotatedLifecycleBean.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/AnnotatedLifecycleBean.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -21,36 +21,36 @@
*/
package org.jboss.test.kernel.deployment.support;
-import org.jboss.beans.metadata.spi.annotations.CreateLifecycle;
-import org.jboss.beans.metadata.spi.annotations.DestroyLifecycle;
-import org.jboss.beans.metadata.spi.annotations.StartLifecycle;
-import org.jboss.beans.metadata.spi.annotations.StopLifecycle;
+import org.jboss.beans.metadata.plugins.annotations.Create;
+import org.jboss.beans.metadata.plugins.annotations.Destroy;
+import org.jboss.beans.metadata.plugins.annotations.Start;
+import org.jboss.beans.metadata.plugins.annotations.Stop;
/**
* @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
*/
public class AnnotatedLifecycleBean extends SimpleLifecycleBean
{
- @CreateLifecycle
+ @Create
public void annotatedCreate()
{
m_create = true;
}
- @StartLifecycle
+ @Start
public void annotatedStart()
{
m_start = true;
}
- @StopLifecycle
+ @Stop
public void annotatedStop()
{
m_start = false;
m_stop = true;
}
- @DestroyLifecycle
+ @Destroy
public void annotatedDestroy()
{
m_create = false;
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/IgnoredAnnotatedLifecycleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/IgnoredAnnotatedLifecycleBean.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/IgnoredAnnotatedLifecycleBean.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -21,36 +21,36 @@
*/
package org.jboss.test.kernel.deployment.support;
-import org.jboss.beans.metadata.spi.annotations.CreateLifecycle;
-import org.jboss.beans.metadata.spi.annotations.DestroyLifecycle;
-import org.jboss.beans.metadata.spi.annotations.StartLifecycle;
-import org.jboss.beans.metadata.spi.annotations.StopLifecycle;
+import org.jboss.beans.metadata.plugins.annotations.Create;
+import org.jboss.beans.metadata.plugins.annotations.Destroy;
+import org.jboss.beans.metadata.plugins.annotations.Start;
+import org.jboss.beans.metadata.plugins.annotations.Stop;
/**
* @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
*/
public class IgnoredAnnotatedLifecycleBean extends AnnotatedLifecycleBean
{
- @CreateLifecycle(ignored = true)
+ @Create(ignored = true)
public void ignoredCreate()
{
m_create = true;
}
- @StartLifecycle(ignored = true)
+ @Start(ignored = true)
public void annotatedStart()
{
m_start = true;
}
- @StopLifecycle(ignored = true)
+ @Stop(ignored = true)
public void annotatedStop()
{
m_start = false;
m_stop = true;
}
- @DestroyLifecycle(ignored = true)
+ @Destroy(ignored = true)
public void ignoredDestroy()
{
m_create = false;
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/MixedLifecycleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/MixedLifecycleBean.java 2007-07-27 11:19:30 UTC (rev 64322)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/MixedLifecycleBean.java 2007-07-27 12:57:03 UTC (rev 64323)
@@ -21,14 +21,14 @@
*/
package org.jboss.test.kernel.deployment.support;
-import org.jboss.beans.metadata.spi.annotations.CreateLifecycle;
+import org.jboss.beans.metadata.plugins.annotations.Create;
/**
* @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
*/
public class MixedLifecycleBean extends SimpleLifecycleBean
{
- @CreateLifecycle(ignored = true)
+ @Create(ignored = true)
public void create()
{
m_create = true;
More information about the jboss-cvs-commits
mailing list