[jboss-cvs] JBossAS SVN: r59708 - in projects/microcontainer/trunk: container/src/main/org/jboss/reflect/plugins/introspection and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 17 14:28:58 EST 2007
Author: alesj
Date: 2007-01-17 14:28:57 -0500 (Wed, 17 Jan 2007)
New Revision: 59708
Added:
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/AttributeDispatchContext.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/InvokeDispatchContext.java
Removed:
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DispatchContext.java
Modified:
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java
projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/StringValueMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/Configurator.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ProgressionTestCase.java
Log:
TypeInfo.getTypeInfoFactory, partition of DispatchContext
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -25,13 +25,7 @@
import java.lang.reflect.Modifier;
import java.util.HashMap;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.*;
import org.jboss.util.JBossStringBuilder;
import org.jboss.util.UnreachableStatementException;
@@ -103,7 +97,20 @@
/** The class info helper */
protected ClassInfoHelper classInfoHelper;
-
+
+ /** The type info factory */
+ protected TypeInfoFactory typeInfoFactory;
+
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ return typeInfoFactory;
+ }
+
+ public void setTypeInfoFactory(TypeInfoFactory typeInfoFactory)
+ {
+ this.typeInfoFactory = typeInfoFactory;
+ }
+
/**
* Find a method
*
@@ -577,6 +584,11 @@
{
throw new UnreachableStatementException();
}
+
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ throw new UnreachableStatementException();
+ }
}
static class UnknownClassInfo extends UnknownTypeInfo implements ClassInfo
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -366,6 +366,7 @@
result = new ReflectClassInfoImpl(clazz.getName());
}
result.setType(clazz);
+ result.setTypeInfoFactory(this);
result.setClassInfoHelper(this);
result.setAnnotationHelper(this);
return result;
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -23,7 +23,6 @@
import java.lang.reflect.ParameterizedType;
-import org.jboss.reflect.plugins.ClassInfoHelper;
import org.jboss.reflect.spi.ArrayInfo;
import org.jboss.reflect.spi.TypeInfo;
@@ -41,13 +40,13 @@
/**
* Create a new ParameterizedArrayInfo.
*
- * @param helper the helper
+ * @param factory the factory
* @param delegate the raw array info
* @param parameterizedType the parameterized type
*/
- public ParameterizedArrayInfo(ClassInfoHelper helper, ArrayInfo delegate, ParameterizedType parameterizedType)
+ public ParameterizedArrayInfo(IntrospectionTypeInfoFactoryImpl factory, ArrayInfo delegate, ParameterizedType parameterizedType)
{
- super(helper, delegate, parameterizedType);
+ super(factory, delegate, parameterizedType);
}
public TypeInfo getComponentType()
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -23,15 +23,8 @@
import java.lang.reflect.ParameterizedType;
-import org.jboss.reflect.plugins.ClassInfoHelper;
import org.jboss.reflect.plugins.ClassInfoImpl;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.*;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
@@ -46,8 +39,8 @@
/** The serialVersionUID */
private static final long serialVersionUID = -8739806147734002603L;
- /** The helper */
- protected ClassInfoHelper helper;
+ /** The factory */
+ protected IntrospectionTypeInfoFactoryImpl factory;
/** The raw class info */
protected ClassInfo delegate;
@@ -64,17 +57,22 @@
/**
* Create a new ParameterizedClassInfo.
*
- * @param helper the helper
+ * @param factory the factory
* @param delegate the raw array info
* @param parameterizedType the parameterized type
*/
- public ParameterizedClassInfo(ClassInfoHelper helper, ClassInfo delegate, ParameterizedType parameterizedType)
+ public ParameterizedClassInfo(IntrospectionTypeInfoFactoryImpl factory, ClassInfo delegate, ParameterizedType parameterizedType)
{
- this.helper = helper;
+ this.factory = factory;
this.delegate = delegate;
this.parameterizedType = parameterizedType;
}
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ return factory;
+ }
+
public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
{
return delegate.getDeclaredConstructor(parameters);
@@ -208,14 +206,14 @@
public TypeInfo[] getActualTypeArguments()
{
if (typeArguments == ClassInfoImpl.UNKNOWN_TYPES)
- typeArguments = helper.getActualTypeArguments(this);
+ typeArguments = factory.getActualTypeArguments(this);
return typeArguments;
}
public TypeInfo getOwnerType()
{
if (ownerType == ClassInfoImpl.UNKNOWN_TYPE)
- ownerType = helper.getOwnerType(this);
+ ownerType = factory.getOwnerType(this);
return ownerType;
}
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -34,13 +34,7 @@
import javassist.NotFoundException;
import org.jboss.reflect.plugins.ValueConvertor;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.*;
import org.jboss.util.JBossStringBuilder;
/**
@@ -351,6 +345,11 @@
return getType().isAssignableFrom(info.getType());
}
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ return factory;
+ }
+
public Object convertValue(Object value) throws Throwable
{
return ValueConvertor.convertValue(getType(), value);
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/PrimitiveInfo.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -185,6 +185,12 @@
return (info == this);
}
+ public TypeInfoFactory getTypeInfoFactory()
+ {
+ // FIXME - fix this once you fix the top TODO
+ return typeInfoFactory;
+ }
+
public String toString()
{
return name;
Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -105,4 +105,11 @@
* null.
*/
boolean isAssignableFrom(TypeInfo info);
+
+ /**
+ * Get the TypeInfoFactory that created this type info
+ *
+ * @return type info factory
+ */
+ TypeInfoFactory getTypeInfoFactory();
}
Deleted: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DispatchContext.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DispatchContext.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DispatchContext.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -1,74 +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.dependency.spi;
-
-/**
- * The API similar to the DynamicMBean API
- * where there are methods to get/set Properties/Attributes and invoke on
- * methods/operations with each context knowing how to do this, e.g.
- * KernelControllerContext -> Configurator
- * ServiceControllerContext -> MBeanServer
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public interface DispatchContext extends ControllerContext
-{
- /**
- * Getter property / attribute
- *
- * @param name
- * @return target's property / attribute instance
- * @throws Throwable
- */
- Object get(String name) throws Throwable;
-
- /**
- * Setter property / attribute
- *
- * @param name
- * @param value set target's property / attribute instance
- * @throws Throwable
- */
- void set(String name, Object value) throws Throwable;
-
- /**
- * Invoke method / operation
- *
- * @param name
- * @param parameters
- * @param signature
- * @return inovocation's return object
- * @throws Throwable
- */
- Object invoke(String name, Object parameters[], String[] signature) throws Throwable;
-
- /**
- * Get context's classloader.
- * Used when determining type info for parameter and
- * getting the parameter actual value.
- *
- * @return context's classloader
- * @throws Throwable
- */
- ClassLoader getClassLoader() throws Throwable;
-
-}
Added: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/AttributeDispatchContext.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/AttributeDispatchContext.java (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/AttributeDispatchContext.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -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.dependency.spi.dispatch;
+
+/**
+ * The API similar to the DynamicMBean API
+ * where there are methods to get/set Properties/Attributes.
+ * It is missing invoke, since not all context support it.
+ * KernelControllerContext -> Configurator
+ * ServiceControllerContext -> MBeanServer
+ *
+ * @see InvokeDispatchContext
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface AttributeDispatchContext
+{
+ /**
+ * Getter property / attribute
+ *
+ * @param name
+ * @return target's property / attribute instance
+ * @throws Throwable
+ */
+ Object get(String name) throws Throwable;
+
+ /**
+ * Setter property / attribute
+ *
+ * @param name
+ * @param value set target's property / attribute instance
+ * @throws Throwable
+ */
+ void set(String name, Object value) throws Throwable;
+}
Added: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/InvokeDispatchContext.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/InvokeDispatchContext.java (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/dispatch/InvokeDispatchContext.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -0,0 +1,62 @@
+/*
+* 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.dependency.spi.dispatch;
+
+/**
+ * The API similar to the DynamicMBean API
+ * where there are methods to get/set Properties/Attributes and invoke on
+ * methods/operations with each context knowing how to do this, e.g.
+ * KernelControllerContext -> Configurator
+ * ServiceControllerContext -> MBeanServer
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface InvokeDispatchContext extends AttributeDispatchContext
+{
+ /**
+ * Invoke method / operation
+ *
+ * @param name
+ * @param parameters
+ * @param signature
+ * @return inovocation's return object
+ * @throws Throwable
+ */
+ Object invoke(String name, Object parameters[], String[] signature) throws Throwable;
+
+ /**
+ * Get any target
+ *
+ * @return the target
+ */
+ Object getTarget();
+
+ /**
+ * Get context's classloader.
+ * Used when determining type info for parameter and
+ * getting the parameter actual value.
+ *
+ * @return context's classloader
+ * @throws Throwable
+ */
+ ClassLoader getClassLoader() throws Throwable;
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -26,7 +26,7 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.dependency.spi.DispatchContext;
+import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.reflect.spi.TypeInfo;
@@ -144,10 +144,10 @@
if (context == null)
throw new Error("Should not be here - dependency failed! " + this);
Object result = context.getTarget();
- if (property != null && context instanceof DispatchContext)
+ if (property != null && context instanceof AttributeDispatchContext)
{
- DispatchContext dc = (DispatchContext) context;
- result = dc.get(property);
+ AttributeDispatchContext adc = (AttributeDispatchContext) context;
+ result = adc.get(property);
}
return info != null ? info.convertValue(result) : result;
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -29,7 +29,8 @@
import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
import org.jboss.beans.metadata.spi.PropertyMetaData;
import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DispatchContext;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
import org.jboss.kernel.plugins.config.Configurator;
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.KernelController;
@@ -146,8 +147,11 @@
{
try
{
- DispatchContext context = (DispatchContext) controller.getContext(beanName, ControllerState.INSTANTIATED);
- result = context.get(propertyName);
+ ControllerContext context = controller.getContext(beanName, ControllerState.INSTANTIATED);
+ if (context != null && context instanceof AttributeDispatchContext)
+ {
+ result = ((AttributeDispatchContext)context).get(propertyName);
+ }
}
catch (Throwable t)
{
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/StringValueMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/StringValueMetaData.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/StringValueMetaData.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -85,6 +85,13 @@
if (typeInfo == null)
throw new IllegalArgumentException("Unable to determine type for value: " + value);
+ // we convert it with more precise type
+ // and then check for progression, ...
+ if (typeInfo != info && info != null)
+ {
+ Object typeValue = typeInfo.convertValue(value);
+ return info.convertValue(typeValue);
+ }
return typeInfo.convertValue(value);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/Configurator.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/Configurator.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/Configurator.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -374,6 +374,8 @@
JoinpointFactory jpf = info.getBeanInfo().getJoinpointFactory();
MethodInfo minfo = info.getGetter();
+ if (minfo == null)
+ throw new IllegalArgumentException("Property is write only: " + info);
return getMethodJoinpoint(null, jpf, minfo.getName(), null, null);
}
@@ -650,6 +652,8 @@
JoinpointFactory jpf = info.getBeanInfo().getJoinpointFactory();
MethodInfo minfo = info.getSetter();
+ if (minfo == null)
+ throw new IllegalArgumentException("Property is read only: " + info);
String[] parameterTypes = getParameterTypes(trace, minfo.getParameterTypes());
return getMethodJoinpoint(null, jpf, minfo.getName(), parameterTypes, new Object[] { null });
}
@@ -697,13 +701,18 @@
Set<PropertyInfo> properties = info.getProperties();
if (properties != null && properties.size() > 0)
{
+ ClassInfo classInfo = info.getClassInfo();
+ TypeInfoFactory tif = classInfo.getTypeInfoFactory();
+ if (tif == null)
+ throw new IllegalArgumentException("TypeInfoFactory is null: " + classInfo);
+
for (PropertyInfo ainfo : properties)
{
if (name.equals(ainfo.getName()))
{
String[] typeNames = {type};
TypeInfo[] typeInfos = {ainfo.getType()};
- if (equals(typeNames, typeInfos) || isAssignable(cl, typeNames, typeInfos) || isProgression(cl, typeNames, typeInfos))
+ if (equals(typeNames, typeInfos) || isAssignable(tif, cl, typeNames, typeInfos))
{
return ainfo;
}
@@ -883,9 +892,6 @@
/**
* Test whether type names can be assigned to type infos
*
- * TODO isAssignableFrom should be part of the TypeInfo api
- * with comparisons made between TypeInfos
- *
* @param cl bean classloader
* @param typeNames the type names
* @param typeInfos the type infos
@@ -893,7 +899,7 @@
* @throws Throwable for any error
*/
@SuppressWarnings("unchecked")
- public static boolean isAssignable(ClassLoader cl, String[] typeNames, TypeInfo[] typeInfos) throws Throwable
+ public static boolean isAssignable(TypeInfoFactory tif, ClassLoader cl, String[] typeNames, TypeInfo[] typeInfos) throws Throwable
{
if (cl == null)
return false;
@@ -905,9 +911,7 @@
{
if (typeNames[i] != null)
{
- // TODO - use typeInfos[i].isAssignableFrom(otherTypeInfo)
- Class clazz = Class.forName(typeNames[i], true, cl);
- if (typeInfos[i].getType().isAssignableFrom(clazz) == false)
+ if (typeInfos[i].isAssignableFrom(tif.getTypeInfo(typeNames[i], cl)) == false)
{
return false;
}
@@ -917,40 +921,6 @@
}
/**
- * Test whether type names can progress to type infos
- *
- * @param cl bean classloader
- * @param typeNames the type names
- * @param typeInfos the type infos
- * @return true when we can use progression
- * @throws Throwable for any error
- */
- public static boolean isProgression(ClassLoader cl, String[] typeNames, TypeInfo[] typeInfos) throws Throwable
- {
- if (cl == null)
- return false;
-
- if (simpleCheck(typeNames, typeInfos) == false)
- return false;
-
- // convertor
- ProgressionConvertor convertor = ProgressionConvertorFactory.getInstance().getConvertor();
-
- for (int i = 0; i < typeNames.length; ++i)
- {
- if (typeNames[i] != null)
- {
- Class clazz = Class.forName(typeNames[i], true, cl);
- if (convertor.canProgress(typeInfos[i].getType(), clazz) == false)
- {
- return false;
- }
- }
- }
- return false;
- }
-
- /**
* ValueJoinpoint.
*/
private static class ValueJoinpoint implements Joinpoint
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -25,7 +25,8 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.InstallMetaData;
-import org.jboss.dependency.spi.DispatchContext;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.InstallKernelControllerContextAware;
@@ -60,10 +61,17 @@
for (int i = 0; i < installs.size(); ++i)
{
InstallMetaData install = (InstallMetaData) installs.get(i);
- DispatchContext target = context;
+ ControllerContext target = context;
if (install.getBean() != null)
- target = (DispatchContext) controller.getContext(install.getBean(), install.getDependentState());
- invoke(configurator, target, install.getMethodName(), install.getParameters());
+ target = controller.getContext(install.getBean(), install.getDependentState());
+ if (target instanceof InvokeDispatchContext)
+ {
+ invoke(configurator, (InvokeDispatchContext)target, install.getMethodName(), install.getParameters());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot install, context " + target + " does not implement InvokeDispatchContext");
+ }
}
}
}
@@ -88,23 +96,30 @@
for (int i = uninstalls.size()-1; i >= 0; --i)
{
InstallMetaData uninstall = (InstallMetaData) uninstalls.get(i);
- DispatchContext target = context;
+ ControllerContext target = context;
if (uninstall.getBean() != null)
{
- target = (DispatchContext) controller.getContext(uninstall.getBean(), uninstall.getDependentState());
+ target = controller.getContext(uninstall.getBean(), uninstall.getDependentState());
if (target == null)
{
log.warn("Ignoring uninstall action on target in incorrect state " + uninstall.getBean());
continue;
}
}
- try
+ if (target instanceof InvokeDispatchContext)
{
- invoke(configurator, target, uninstall.getMethodName(), uninstall.getParameters());
+ try
+ {
+ invoke(configurator, (InvokeDispatchContext)target, uninstall.getMethodName(), uninstall.getParameters());
+ }
+ catch (Throwable t)
+ {
+ log.warn("Ignoring uninstall action on target " + uninstall, t);
+ }
}
- catch (Throwable t)
+ else
{
- log.warn("Ignoring uninstall action on target " + uninstall, t);
+ throw new IllegalArgumentException("Cannot uninstall, context " + target + " does not implement InvokeDispatchContext");
}
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -22,16 +22,13 @@
package org.jboss.kernel.plugins.dependency;
import java.security.*;
-import java.util.ArrayList;
import java.util.List;
-import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.ParameterMetaData;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
import org.jboss.dependency.plugins.spi.action.ControllerContextAction;
import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.DispatchContext;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
import org.jboss.joinpoint.spi.Joinpoint;
import org.jboss.kernel.plugins.config.Configurator;
import org.jboss.kernel.spi.config.KernelConfigurator;
@@ -207,7 +204,7 @@
awareInterface.equals(KernelControllerContextAware.class) == false &&
awareInterface.isAssignableFrom(target.getClass()))
{
- System.out.println("-----> " + context.getName() + " " + target.getClass() + " " + context.getState());
+ //System.out.println("-----> " + context.getName() + " " + target.getClass() + " " + context.getState());
((KernelControllerContextAware)target).setKernelControllerContext(context);
}
}
@@ -252,15 +249,8 @@
// DispatchContext util methods
- protected void set(KernelConfigurator configurator, DispatchContext context, PropertyMetaData property) throws Throwable
+ protected Object invoke(KernelConfigurator configurator, InvokeDispatchContext context, String name, List<ParameterMetaData> params) throws Throwable
{
- List<ParameterMetaData> params = new ArrayList<ParameterMetaData>(1);
- params.add(new AbstractParameterMetaData(property.getType(), property.getValue()));
- invoke(configurator, context, property.getName(), params);
- }
-
- protected Object invoke(KernelConfigurator configurator, DispatchContext context, String name, List<ParameterMetaData> params) throws Throwable
- {
String[] signature;
Object[] parameters;
if (params == null || params.isEmpty())
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -27,7 +27,7 @@
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
import org.jboss.metadata.spi.MetaData;
import org.jboss.metadata.spi.scope.ScopeKey;
-import org.jboss.dependency.spi.DispatchContext;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
/**
* Information about dependencies and state.
@@ -35,7 +35,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public interface KernelControllerContext extends KernelRegistryEntry, DispatchContext
+public interface KernelControllerContext extends KernelRegistryEntry, InvokeDispatchContext
{
/**
* Get the kernel
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ProgressionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ProgressionTestCase.java 2007-01-17 18:52:00 UTC (rev 59707)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/ProgressionTestCase.java 2007-01-17 19:28:57 UTC (rev 59708)
@@ -24,6 +24,7 @@
import junit.framework.Test;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.test.kernel.config.support.SimpleBean;
@@ -66,9 +67,15 @@
KernelConfigurator configurator = kernel.getConfigurator();
AbstractBeanMetaData bmd = new AbstractBeanMetaData(SimpleBean.class.getName());
- bmd.addProperty(new AbstractPropertyMetaData("anint", 123.456));
- bmd.addProperty(new AbstractPropertyMetaData("AShort", 987.6543));
- bmd.addProperty(new AbstractPropertyMetaData("AFloat", 314159));
+ AbstractPropertyMetaData prop1 = new AbstractPropertyMetaData("anint", 123.456);
+ bmd.addProperty(prop1);
+ StringValueMetaData svmd = new StringValueMetaData("987.6543");
+ svmd.setType("java.lang.Double");
+ svmd.setConfigurator(configurator);
+ AbstractPropertyMetaData prop2 = new AbstractPropertyMetaData("AShort", svmd);
+ bmd.addProperty(prop2);
+ AbstractPropertyMetaData prop3 = new AbstractPropertyMetaData("AFloat", 314159);
+ bmd.addProperty(prop3);
return (SimpleBean) instantiateAndConfigure(configurator, bmd);
}
More information about the jboss-cvs-commits
mailing list