[jboss-cvs] JBossAS SVN: r64362 - in projects/microcontainer/trunk/kernel/src: main/org/jboss/kernel/plugins/annotations and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 31 05:17:31 EDT 2007
Author: alesj
Date: 2007-07-31 05:17:31 -0400 (Tue, 31 Jul 2007)
New Revision: 64362
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Factory.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/JavaBeanValue.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueUtil.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactorySimpleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithIntParamSimpleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithParamSimpleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactorySimpleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithIntParamSimpleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithParamSimpleBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryAnnotationTestCase.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Parameter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Value.java
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/BasicBeanAnnotationAdapter.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CollectionsAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ParametersAnnotationPlugin.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/ValueFactoryAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryTestCase.java
Log:
Added simple @JavaBeanValue and @Factory.
@Factory tests.
Simple refactoring for Value/Parameter ValueMetaData creation.
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Factory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Factory.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Factory.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.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 Factory
+{
+ Value factory() default @Value();
+
+ String factoryClass() default "";
+
+ String factoryMethod();
+
+ Value[] parameters() default {};
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/JavaBeanValue.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/JavaBeanValue.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/JavaBeanValue.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -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.METHOD, ElementType.PARAMETER})
+public @interface JavaBeanValue
+{
+ String clazz() default "";
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Parameter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Parameter.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Parameter.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -33,6 +33,8 @@
@Target({ElementType.ANNOTATION_TYPE})
public @interface Parameter
{
+ String type() default "";
+
StringValue string() default @StringValue(value="");
Inject inject() default @Inject(valid=false);
@@ -40,4 +42,6 @@
ThisValue thisValue() default @ThisValue(valid = false);
NullValue nullValue() default @NullValue(valid = false);
+
+ JavaBeanValue javabean() default @JavaBeanValue;
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Value.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Value.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/annotations/Value.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -33,6 +33,8 @@
@Target({ElementType.ANNOTATION_TYPE})
public @interface Value
{
+ String type() default "";
+
StringValue string() default @StringValue(value="");
Inject inject() default @Inject(valid=false);
@@ -42,4 +44,6 @@
ThisValue thisValue() default @ThisValue(valid = false);
NullValue nullValue() default @NullValue(valid = false);
+
+ JavaBeanValue javabean() default @JavaBeanValue;
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAdaptersAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -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.kernel.plugins.annotations;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+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 AbstractAdaptersAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends AbstractAnnotationPlugin<T, C>
+{
+ protected List<Annotation2ValueMetaDataAdapter> adapters;
+
+ protected AbstractAdaptersAnnotationPlugin(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));
+ }
+
+}
Modified: 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 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -78,7 +78,7 @@
protected static boolean isAttributePresent(String value)
{
- return value != null && value.length() > 0;
+ return ValueUtil.isAttributePresent(value);
}
protected abstract boolean isElementTypeSupported(ElementType type);
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -24,7 +24,6 @@
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;
@@ -49,17 +48,11 @@
* @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>
+public abstract class AbstractParameterAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation, P extends MutableParameterizedMetaData> extends AbstractAdaptersAnnotationPlugin<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));
+ super(annotation, adapters);
}
protected abstract boolean checkAnnotatedInfo(ElementType type);
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -68,6 +68,7 @@
ValueFactoryAnnotationPlugin.INSTANCE,
ThisValueAnnotationPlugin.INSTANCE,
NullValueAnnotationPlugin.INSTANCE,
+ JavaBeanValueAnnotationPlugin.INSTANCE,
CollectionValueAnnotationPlugin.INSTANCE,
ListValueAnnotationPlugin.INSTANCE,
SetValueAnnotationPlugin.INSTANCE,
@@ -80,6 +81,7 @@
addAnnotationPlugin(new DemandsAnnotationPlugin());
addAnnotationPlugin(new DependsAnnotationPlugin());
addAnnotationPlugin(new SupplysAnnotationPlugin());
+ addAnnotationPlugin(new ClassFactoryAnnotationPlugin(adapters));
/*
addAnnotationPlugin(new InjectConstructorValueAnnotationPlugin());
addAnnotationPlugin(new StringValueConstructorValueAnnotationPlugin());
@@ -98,6 +100,7 @@
addAnnotationPlugin(ValueFactoryAnnotationPlugin.INSTANCE);
addAnnotationPlugin(ThisValueAnnotationPlugin.INSTANCE);
addAnnotationPlugin(NullValueAnnotationPlugin.INSTANCE);
+ addAnnotationPlugin(JavaBeanValueAnnotationPlugin.INSTANCE);
addAnnotationPlugin(CollectionValueAnnotationPlugin.INSTANCE);
addAnnotationPlugin(ListValueAnnotationPlugin.INSTANCE);
addAnnotationPlugin(SetValueAnnotationPlugin.INSTANCE);
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -0,0 +1,86 @@
+/*
+* 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 java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.ClassInfo;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ClassFactoryAnnotationPlugin extends AbstractAdaptersAnnotationPlugin<ClassInfo, Factory>
+{
+ protected ClassFactoryAnnotationPlugin(Annotation2ValueMetaDataAdapter... adapters)
+ {
+ super(Factory.class, adapters);
+ }
+
+ protected boolean isElementTypeSupported(ElementType type)
+ {
+ return ElementType.TYPE == type;
+ }
+
+ protected boolean isMetaDataAlreadyPresent(ClassInfo info, Factory annotation, BeanMetaData beanMetaData)
+ {
+ return beanMetaData.getConstructor() != null;
+ }
+
+ protected void internalApplyAnnotation(ClassInfo info, Factory annotation, KernelControllerContext context) throws Throwable
+ {
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)context.getBeanMetaData();
+ AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
+ if (isAttributePresent(annotation.factoryClass()))
+ {
+ constructor.setFactoryClass(annotation.factoryClass());
+ }
+ else
+ {
+ constructor.setFactory(ValueUtil.createValueMetaData(annotation.factory()));
+ }
+ constructor.setFactoryMethod(annotation.factoryMethod());
+ if (annotation.parameters().length > 0)
+ {
+ List<ParameterMetaData> parameters = new ArrayList<ParameterMetaData>();
+ for(Value parameter : annotation.parameters())
+ {
+ AbstractParameterMetaData apmd = new AbstractParameterMetaData(ValueUtil.createValueMetaData(parameter));
+ if (isAttributePresent(parameter.type()))
+ apmd.setType(parameter.type());
+ parameters.add(apmd);
+ }
+ constructor.setParameters(parameters);
+ }
+ bean.setConstructor(constructor);
+ executeVisit(context, constructor);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CollectionsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CollectionsAnnotationPlugin.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CollectionsAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -23,13 +23,8 @@
import java.lang.annotation.Annotation;
-import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.beans.metadata.plugins.annotations.Value;
-import org.jboss.beans.metadata.plugins.annotations.StringValue;
-import org.jboss.beans.metadata.plugins.annotations.Inject;
-import org.jboss.beans.metadata.plugins.annotations.ValueFactory;
-import org.jboss.beans.metadata.plugins.annotations.NullValue;
-import org.jboss.beans.metadata.plugins.annotations.ThisValue;
+import org.jboss.beans.metadata.spi.ValueMetaData;
/**
* @param <C> annotation type
@@ -44,51 +39,6 @@
protected ValueMetaData createValueMetaData(Value value)
{
- ValueMetaData vmd = null;
-
- StringValue string = value.string();
- if (isAttributePresent(string.value()))
- {
- vmd = StringValueAnnotationPlugin.INSTANCE.createValueMetaData(string);
- }
-
- Inject inject = value.inject();
- if (inject.valid())
- {
- checkValueMetaData(vmd);
- vmd = InjectAnnotationPlugin.INSTANCE.createValueMetaData(inject);
- }
-
- ValueFactory vf = value.valueFactory();
- if (isAttributePresent(vf.bean()))
- {
- checkValueMetaData(vmd);
- vmd = ValueFactoryAnnotationPlugin.INSTANCE.createValueMetaData(vf);
- }
-
- ThisValue thisValue = value.thisValue();
- if (thisValue.valid())
- {
- checkValueMetaData(vmd);
- vmd = ThisValueAnnotationPlugin.INSTANCE.createValueMetaData(thisValue);
- }
-
- NullValue nullValue = value.nullValue();
- if (nullValue.valid())
- {
- checkValueMetaData(vmd);
- vmd = NullValueAnnotationPlugin.INSTANCE.createValueMetaData(nullValue);
- }
-
- if (vmd == null)
- throw new IllegalArgumentException("No value set on @Value annotation!");
-
- return vmd;
+ return ValueUtil.createValueMetaData(value);
}
-
- protected void checkValueMetaData(ValueMetaData value)
- {
- if (value != null)
- throw new IllegalArgumentException("@Value annotation has too many values set!");
- }
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ParametersAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ParametersAnnotationPlugin.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ParametersAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -23,11 +23,7 @@
import java.lang.annotation.Annotation;
-import org.jboss.beans.metadata.plugins.annotations.Inject;
-import org.jboss.beans.metadata.plugins.annotations.NullValue;
import org.jboss.beans.metadata.plugins.annotations.Parameter;
-import org.jboss.beans.metadata.plugins.annotations.StringValue;
-import org.jboss.beans.metadata.plugins.annotations.ThisValue;
import org.jboss.beans.metadata.spi.ValueMetaData;
/**
@@ -43,44 +39,6 @@
protected ValueMetaData createValueMetaData(Parameter parameter)
{
- ValueMetaData vmd = null;
-
- StringValue string = parameter.string();
- if (isAttributePresent(string.value()))
- {
- vmd = StringValueAnnotationPlugin.INSTANCE.createValueMetaData(string);
- }
-
- Inject inject = parameter.inject();
- if (inject.valid())
- {
- checkValueMetaData(vmd);
- vmd = InjectAnnotationPlugin.INSTANCE.createValueMetaData(inject);
- }
-
- ThisValue thisValue = parameter.thisValue();
- if (thisValue.valid())
- {
- checkValueMetaData(vmd);
- vmd = ThisValueAnnotationPlugin.INSTANCE.createValueMetaData(thisValue);
- }
-
- NullValue nullValue = parameter.nullValue();
- if (nullValue.valid())
- {
- checkValueMetaData(vmd);
- vmd = NullValueAnnotationPlugin.INSTANCE.createValueMetaData(nullValue);
- }
-
- if (vmd == null)
- throw new IllegalArgumentException("No value set on @Value annotation!");
-
- return vmd;
+ return ValueUtil.createValueMetaData(parameter);
}
-
- protected void checkValueMetaData(ValueMetaData value)
- {
- if (value != null)
- throw new IllegalArgumentException("@Value annotation has too many values set!");
- }
}
Modified: 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 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -75,6 +75,11 @@
protected PropertyMetaData getPropertyMetaData(PropertyInfo info, C annotation, KernelControllerContext context)
{
+ return getPropertyMetaData(info, annotation, context.getBeanMetaData());
+ }
+
+ protected PropertyMetaData getPropertyMetaData(PropertyInfo info, C annotation, BeanMetaData beanMetaData)
+ {
return getPropertyMetaData(info, annotation);
}
Modified: 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 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryAnnotationPlugin.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -57,7 +57,12 @@
if (parameters.size() > 0)
throw new IllegalArgumentException("Cannot set both parameter and parameters!");
for(Parameter parameter : annotation.parameters())
- parameters.add(new AbstractParameterMetaData(createValueMetaData(parameter)));
+ {
+ AbstractParameterMetaData apmd = new AbstractParameterMetaData(ValueUtil.createValueMetaData(parameter));
+ if (isAttributePresent(parameter.type()))
+ apmd.setType(parameter.type());
+ parameters.add(apmd);
+ }
}
factory.setParameters(parameters);
factory.setDependentState(new ControllerState(annotation.dependantState()));
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueUtil.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueUtil.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueUtil.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -0,0 +1,144 @@
+/*
+* 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.NullValue;
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+import org.jboss.beans.metadata.plugins.annotations.ThisValue;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+import org.jboss.beans.metadata.plugins.annotations.ValueFactory;
+import org.jboss.beans.metadata.plugins.annotations.Parameter;
+import org.jboss.beans.metadata.plugins.annotations.JavaBeanValue;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+final class ValueUtil
+{
+ private static void checkValueMetaData(ValueMetaData value)
+ {
+ if (value != null)
+ throw new IllegalArgumentException("@Value/@Parameter annotation has too many values set!");
+ }
+
+ static boolean isAttributePresent(String value)
+ {
+ return value != null && value.length() > 0;
+ }
+
+ static ValueMetaData createValueMetaData(Value value)
+ {
+ ValueMetaData vmd = null;
+
+ StringValue string = value.string();
+ if (isAttributePresent(string.value()))
+ {
+ vmd = StringValueAnnotationPlugin.INSTANCE.createValueMetaData(string);
+ }
+
+ Inject inject = value.inject();
+ if (inject.valid())
+ {
+ checkValueMetaData(vmd);
+ vmd = InjectAnnotationPlugin.INSTANCE.createValueMetaData(inject);
+ }
+
+ ValueFactory vf = value.valueFactory();
+ if (isAttributePresent(vf.bean()))
+ {
+ checkValueMetaData(vmd);
+ vmd = ValueFactoryAnnotationPlugin.INSTANCE.createValueMetaData(vf);
+ }
+
+ ThisValue thisValue = value.thisValue();
+ if (thisValue.valid())
+ {
+ checkValueMetaData(vmd);
+ vmd = ThisValueAnnotationPlugin.INSTANCE.createValueMetaData(thisValue);
+ }
+
+ NullValue nullValue = value.nullValue();
+ if (nullValue.valid())
+ {
+ checkValueMetaData(vmd);
+ vmd = NullValueAnnotationPlugin.INSTANCE.createValueMetaData(nullValue);
+ }
+
+ JavaBeanValue javabean = value.javabean();
+ if (isAttributePresent(javabean.clazz()))
+ {
+ checkValueMetaData(vmd);
+ vmd = JavaBeanValueAnnotationPlugin.INSTANCE.createValueMetaData(javabean);
+ }
+
+ if (vmd == null)
+ throw new IllegalArgumentException("No value set on @Value annotation!");
+
+ return vmd;
+ }
+
+ static ValueMetaData createValueMetaData(Parameter parameter)
+ {
+ ValueMetaData vmd = null;
+
+ StringValue string = parameter.string();
+ if (isAttributePresent(string.value()))
+ {
+ vmd = StringValueAnnotationPlugin.INSTANCE.createValueMetaData(string);
+ }
+
+ Inject inject = parameter.inject();
+ if (inject.valid())
+ {
+ checkValueMetaData(vmd);
+ vmd = InjectAnnotationPlugin.INSTANCE.createValueMetaData(inject);
+ }
+
+ ThisValue thisValue = parameter.thisValue();
+ if (thisValue.valid())
+ {
+ checkValueMetaData(vmd);
+ vmd = ThisValueAnnotationPlugin.INSTANCE.createValueMetaData(thisValue);
+ }
+
+ NullValue nullValue = parameter.nullValue();
+ if (nullValue.valid())
+ {
+ checkValueMetaData(vmd);
+ vmd = NullValueAnnotationPlugin.INSTANCE.createValueMetaData(nullValue);
+ }
+
+ JavaBeanValue javabean = parameter.javabean();
+ if (isAttributePresent(javabean.clazz()))
+ {
+ checkValueMetaData(vmd);
+ vmd = JavaBeanValueAnnotationPlugin.INSTANCE.createValueMetaData(javabean);
+ }
+
+ if (vmd == null)
+ throw new IllegalArgumentException("No value set on @Value annotation!");
+
+ return vmd;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactorySimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactorySimpleBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactorySimpleBean.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -0,0 +1,98 @@
+/*
+* 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.config.support;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+import org.jboss.beans.metadata.plugins.annotations.JavaBeanValue;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Factory(
+ factory = @Value(javabean = @JavaBeanValue(clazz = "org.jboss.test.kernel.config.support.SimpleBeanFactory")),
+ factoryMethod = "createSimpleBean"
+)
+public class FromFactorySimpleBean extends SimpleBean
+{
+ public FromFactorySimpleBean()
+ {
+ }
+
+ public FromFactorySimpleBean(String string)
+ {
+ super(string);
+ }
+
+ public FromFactorySimpleBean(String string1, String string2)
+ {
+ super(string1, string2);
+ }
+
+ public FromFactorySimpleBean(Integer integer)
+ {
+ super(integer);
+ }
+
+ public FromFactorySimpleBean(Comparable comparable)
+ {
+ super(comparable);
+ }
+
+ public FromFactorySimpleBean(Collection collection)
+ {
+ super(collection);
+ }
+
+ public FromFactorySimpleBean(List list)
+ {
+ super(list);
+ }
+
+ public FromFactorySimpleBean(Set set)
+ {
+ super(set);
+ }
+
+ public FromFactorySimpleBean(Object[] array)
+ {
+ super(array);
+ }
+
+ public FromFactorySimpleBean(Map map)
+ {
+ super(map);
+ }
+
+ public FromFactorySimpleBean(Hashtable hashtable)
+ {
+ super(hashtable);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithIntParamSimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithIntParamSimpleBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithIntParamSimpleBean.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -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.test.kernel.config.support;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+import org.jboss.beans.metadata.plugins.annotations.JavaBeanValue;
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Factory(
+ factory = @Value(javabean = @JavaBeanValue(clazz = "org.jboss.test.kernel.config.support.SimpleBeanFactory")),
+ factoryMethod = "createSimpleBean",
+ parameters = {@Value(type = "java.lang.Integer", string = @StringValue("4"))}
+)
+public class FromFactoryWithIntParamSimpleBean extends SimpleBean
+{
+ public FromFactoryWithIntParamSimpleBean()
+ {
+ }
+
+ public FromFactoryWithIntParamSimpleBean(String string)
+ {
+ super(string);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(String string1, String string2)
+ {
+ super(string1, string2);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(Integer integer)
+ {
+ super(integer);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(Comparable comparable)
+ {
+ super(comparable);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(Collection collection)
+ {
+ super(collection);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(List list)
+ {
+ super(list);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(Set set)
+ {
+ super(set);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(Object[] array)
+ {
+ super(array);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(Map map)
+ {
+ super(map);
+ }
+
+ public FromFactoryWithIntParamSimpleBean(Hashtable hashtable)
+ {
+ super(hashtable);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithParamSimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithParamSimpleBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromFactoryWithParamSimpleBean.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -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.test.kernel.config.support;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+import org.jboss.beans.metadata.plugins.annotations.JavaBeanValue;
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Factory(
+ factory = @Value(javabean = @JavaBeanValue(clazz = "org.jboss.test.kernel.config.support.SimpleBeanFactory")),
+ factoryMethod = "createSimpleBean",
+ parameters = {@Value(string = @StringValue("Factory Value"))}
+)
+public class FromFactoryWithParamSimpleBean extends SimpleBean
+{
+ public FromFactoryWithParamSimpleBean()
+ {
+ }
+
+ public FromFactoryWithParamSimpleBean(String string)
+ {
+ super(string);
+ }
+
+ public FromFactoryWithParamSimpleBean(String string1, String string2)
+ {
+ super(string1, string2);
+ }
+
+ public FromFactoryWithParamSimpleBean(Integer integer)
+ {
+ super(integer);
+ }
+
+ public FromFactoryWithParamSimpleBean(Comparable comparable)
+ {
+ super(comparable);
+ }
+
+ public FromFactoryWithParamSimpleBean(Collection collection)
+ {
+ super(collection);
+ }
+
+ public FromFactoryWithParamSimpleBean(List list)
+ {
+ super(list);
+ }
+
+ public FromFactoryWithParamSimpleBean(Set set)
+ {
+ super(set);
+ }
+
+ public FromFactoryWithParamSimpleBean(Object[] array)
+ {
+ super(array);
+ }
+
+ public FromFactoryWithParamSimpleBean(Map map)
+ {
+ super(map);
+ }
+
+ public FromFactoryWithParamSimpleBean(Hashtable hashtable)
+ {
+ super(hashtable);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactorySimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactorySimpleBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactorySimpleBean.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -0,0 +1,96 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.config.support;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Factory(
+ factoryClass = "org.jboss.test.kernel.config.support.SimpleBeanFactory",
+ factoryMethod = "staticCreateSimpleBean"
+)
+public class FromStaticFactorySimpleBean extends SimpleBean
+{
+ public FromStaticFactorySimpleBean()
+ {
+ }
+
+ public FromStaticFactorySimpleBean(String string)
+ {
+ super(string);
+ }
+
+ public FromStaticFactorySimpleBean(String string1, String string2)
+ {
+ super(string1, string2);
+ }
+
+ public FromStaticFactorySimpleBean(Integer integer)
+ {
+ super(integer);
+ }
+
+ public FromStaticFactorySimpleBean(Comparable comparable)
+ {
+ super(comparable);
+ }
+
+ public FromStaticFactorySimpleBean(Collection collection)
+ {
+ super(collection);
+ }
+
+ public FromStaticFactorySimpleBean(List list)
+ {
+ super(list);
+ }
+
+ public FromStaticFactorySimpleBean(Set set)
+ {
+ super(set);
+ }
+
+ public FromStaticFactorySimpleBean(Object[] array)
+ {
+ super(array);
+ }
+
+ public FromStaticFactorySimpleBean(Map map)
+ {
+ super(map);
+ }
+
+ public FromStaticFactorySimpleBean(Hashtable hashtable)
+ {
+ super(hashtable);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithIntParamSimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithIntParamSimpleBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithIntParamSimpleBean.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -0,0 +1,99 @@
+/*
+* 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.config.support;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Factory(
+ factoryClass = "org.jboss.test.kernel.config.support.SimpleBeanFactory",
+ factoryMethod = "staticCreateSimpleBean",
+ parameters = {@Value(type="java.lang.Integer", string = @StringValue("7"))}
+)
+public class FromStaticFactoryWithIntParamSimpleBean extends SimpleBean
+{
+ public FromStaticFactoryWithIntParamSimpleBean()
+ {
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(String string)
+ {
+ super(string);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(String string1, String string2)
+ {
+ super(string1, string2);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(Integer integer)
+ {
+ super(integer);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(Comparable comparable)
+ {
+ super(comparable);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(Collection collection)
+ {
+ super(collection);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(List list)
+ {
+ super(list);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(Set set)
+ {
+ super(set);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(Object[] array)
+ {
+ super(array);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(Map map)
+ {
+ super(map);
+ }
+
+ public FromStaticFactoryWithIntParamSimpleBean(Hashtable hashtable)
+ {
+ super(hashtable);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithParamSimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithParamSimpleBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/support/FromStaticFactoryWithParamSimpleBean.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -0,0 +1,99 @@
+/*
+* 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.config.support;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+
+/**
+ * A simple bean
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Factory(
+ factoryClass = "org.jboss.test.kernel.config.support.SimpleBeanFactory",
+ factoryMethod = "staticCreateSimpleBean",
+ parameters = {@Value(type="java.lang.String", string = @StringValue("Static Factory Value"))}
+)
+public class FromStaticFactoryWithParamSimpleBean extends SimpleBean
+{
+ public FromStaticFactoryWithParamSimpleBean()
+ {
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(String string)
+ {
+ super(string);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(String string1, String string2)
+ {
+ super(string1, string2);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(Integer integer)
+ {
+ super(integer);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(Comparable comparable)
+ {
+ super(comparable);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(Collection collection)
+ {
+ super(collection);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(List list)
+ {
+ super(list);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(Set set)
+ {
+ super(set);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(Object[] array)
+ {
+ super(array);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(Map map)
+ {
+ super(map);
+ }
+
+ public FromStaticFactoryWithParamSimpleBean(Hashtable hashtable)
+ {
+ super(hashtable);
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ConfigTestSuite.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -47,6 +47,7 @@
suite.addTest(InstantiateAnnotationTestCase.suite());
suite.addTest(FactoryTestCase.suite());
suite.addTest(FactoryXMLTestCase.suite());
+ suite.addTest(FactoryAnnotationTestCase.suite());
suite.addTest(ConfigureAttributeFromObjectTestCase.suite());
suite.addTest(ConfigureAttributeFromStringTestCase.suite());
suite.addTest(ConfigureFromObjectTestCase.suite());
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryAnnotationTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryAnnotationTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryAnnotationTestCase.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -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.test.kernel.config.test;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.test.kernel.config.support.FromFactorySimpleBean;
+import org.jboss.test.kernel.config.support.FromFactoryWithParamSimpleBean;
+import org.jboss.test.kernel.config.support.SimpleBean;
+import org.jboss.test.kernel.config.support.FromStaticFactorySimpleBean;
+import org.jboss.test.kernel.config.support.FromFactoryWithIntParamSimpleBean;
+import org.jboss.test.kernel.config.support.FromStaticFactoryWithParamSimpleBean;
+import org.jboss.test.kernel.config.support.FromStaticFactoryWithIntParamSimpleBean;
+
+/**
+ * Factory Test Case.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryAnnotationTestCase extends FactoryTestCase
+{
+ public static Test suite()
+ {
+ return suite(FactoryAnnotationTestCase.class);
+ }
+
+ public FactoryAnnotationTestCase(String name)
+ {
+ super(name, false);
+ }
+
+ protected SimpleBean simpleInstantiateFromFactory() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("SimpleBean", FromFactorySimpleBean.class.getName());
+ return (SimpleBean)instantiate(builder.getBeanMetaData());
+ }
+
+ protected SimpleBean simpleInstantiateFromFactoryWithParameters() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("SimpleBean", FromFactoryWithParamSimpleBean.class.getName());
+ return (SimpleBean)instantiate(builder.getBeanMetaData());
+ }
+
+ protected SimpleBean simpleInstantiateFromFactoryWithIntegerParameter() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("SimpleBean", FromFactoryWithIntParamSimpleBean.class.getName());
+ return (SimpleBean)instantiate(builder.getBeanMetaData());
+ }
+
+ protected SimpleBean staticInstantiateFromFactory() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("SimpleBean", FromStaticFactorySimpleBean.class.getName());
+ return (SimpleBean)instantiate(builder.getBeanMetaData());
+ }
+
+ protected SimpleBean staticInstantiateFromFactoryWithParameters() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("SimpleBean", FromStaticFactoryWithParamSimpleBean.class.getName());
+ return (SimpleBean)instantiate(builder.getBeanMetaData());
+ }
+
+ protected SimpleBean staticInstantiateFromFactoryWithIntegerParameter() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("SimpleBean", FromStaticFactoryWithIntParamSimpleBean.class.getName());
+ return (SimpleBean)instantiate(builder.getBeanMetaData());
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryTestCase.java 2007-07-31 07:21:43 UTC (rev 64361)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/FactoryTestCase.java 2007-07-31 09:17:31 UTC (rev 64362)
@@ -128,7 +128,7 @@
cmd.setFactory(vmd);
cmd.setFactoryMethod("createSimpleBean");
ArrayList<ParameterMetaData> constructorParams = new ArrayList<ParameterMetaData>();
- AbstractParameterMetaData pmd = new AbstractParameterMetaData(new Integer(4));
+ AbstractParameterMetaData pmd = new AbstractParameterMetaData(4);
pmd.setType("java.lang.Integer");
constructorParams.add(pmd);
cmd.setParameters(constructorParams);
@@ -200,7 +200,7 @@
cmd.setFactoryClass(SimpleBeanFactory.class.getName());
cmd.setFactoryMethod("staticCreateSimpleBean");
ArrayList<ParameterMetaData> constructorParams = new ArrayList<ParameterMetaData>();
- AbstractParameterMetaData pmd = new AbstractParameterMetaData(new Integer(7));
+ AbstractParameterMetaData pmd = new AbstractParameterMetaData(7);
pmd.setType("java.lang.Integer");
constructorParams.add(pmd);
cmd.setParameters(constructorParams);
More information about the jboss-cvs-commits
mailing list