Author: niclas Date: Thu Aug 19 02:08:09 2004 New Revision: 36599 Added: avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/AbstractObjectTypeHandler.java (contents, props changed) avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/ComponentModelTypeHandler.java (contents, props changed) Modified: avalon/trunk/planet/facilities/reflector/blocks/complete/build.xml avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ModelRegistrator.java avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ReflectorImpl.java avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/ObjectTypeHandler.java Log: Added support for an implicit 'Implementation' member for ComponentModel objects, so one can navigate from the Model into the implementation.
Modified: avalon/trunk/planet/facilities/reflector/blocks/complete/build.xml ============================================================================== --- avalon/trunk/planet/facilities/reflector/blocks/complete/build.xml (original) +++ avalon/trunk/planet/facilities/reflector/blocks/complete/build.xml Thu Aug 19 02:08:09 2004 @@ -32,6 +32,7 @@ <x:component name="typehandler-collection" class="org.apache.metro.facilities.reflector.typehandlers.CollectionTypeHandler" /> <x:component name="typehandler-map" class="org.apache.metro.facilities.reflector.typehandlers.MapTypeHandler" /> <x:component name="typehandler-dictionary" class="org.apache.metro.facilities.reflector.typehandlers.DictionaryTypeHandler" /> + <x:component name="typehandler-componentmodel" class="org.apache.metro.facilities.reflector.typehandlers.ComponentModelTypeHandler" /> <x:component name="reflector-http-handler" class="org.apache.metro.facilities.reflector.impl.ReflectionHandler" > <x:parameters> Modified: avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ModelRegistrator.java ============================================================================== --- avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ModelRegistrator.java (original) +++ avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ModelRegistrator.java Thu Aug 19 02:08:09 2004 @@ -27,6 +27,9 @@ import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; +import org.apache.avalon.composition.event.CompositionEvent; +import org.apache.avalon.composition.event.CompositionListener; + import org.apache.avalon.composition.model.ContainmentModel; import org.apache.metro.facilities.reflector.ReflectorService; @@ -37,7 +40,8 @@ * collection="weak" */ public class ModelRegistrator - implements Contextualizable, Serviceable, Initializable + implements Contextualizable, Serviceable, Initializable, + CompositionListener { private ContainmentModel m_Model; private ReflectorService m_Reflector; @@ -58,6 +62,7 @@ throws ContextException { m_Model = (ContainmentModel) ctx.get( "urn:composition:containment.model" ); + m_Model.addCompositionListener( this ); } /** The service method is called by the Avalon framework container. @@ -77,4 +82,27 @@ { m_Reflector.addRootObject( "model", m_Model ); } + + /** + * Notify the listener that a model has been added to + * a source containment model. + * + * @param event the containment event raised by the + * source containment model + */ + public void modelAdded( CompositionEvent event ) + { + } + + /** + * Notify the listener that a model has been removed from + * a source containment model. + * + * @param event the containment event raised by the + * source containment model + */ + public void modelRemoved( CompositionEvent event ) + { + } + } Modified: avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ReflectorImpl.java ============================================================================== --- avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ReflectorImpl.java (original) +++ avalon/trunk/planet/facilities/reflector/impl/src/main/org/apache/metro/facilities/reflector/impl/ReflectorImpl.java Thu Aug 19 02:08:09 2004 @@ -19,6 +19,8 @@ */ package org.apache.metro.facilities.reflector.impl; +import java.lang.reflect.Proxy; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -328,6 +330,13 @@ private TypeHandler getTypeHandler( Object obj ) { + Class clazz = obj.getClass(); + if( Proxy.isProxyClass( clazz ) ) + { + TypeHandler th = (TypeHandler) m_TypeHandlerMap.get( Proxy.class ); + if( th != null ) + return th; + } Iterator list = m_TypeHandlerMap.entrySet().iterator(); while( list.hasNext() ) { Added: avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/AbstractObjectTypeHandler.java ============================================================================== --- (empty file) +++ avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/AbstractObjectTypeHandler.java Thu Aug 19 02:08:09 2004 @@ -0,0 +1,288 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.metro.facilities.reflector.typehandlers; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +import java.util.ArrayList; + +import org.apache.metro.facilities.reflector.ReflectionException; + +import org.apache.metro.facilities.reflector.spi.ReflectorProvider; +import org.apache.metro.facilities.reflector.spi.TypeHandler; +import org.apache.metro.facilities.reflector.spi.Util; + +public abstract class AbstractObjectTypeHandler + implements TypeHandler +{ + protected void getNames( ArrayList names, Object container ) + throws ReflectionException + { + + Class clazz = container.getClass(); + + if( Modifier.isPublic( clazz.getModifiers() ) ) + getNames( names, clazz ); + else + { + ArrayList all = new ArrayList(); + Class[] interfaces = clazz.getInterfaces(); + for( int i=0 ; i < interfaces.length ; i++ ) + { + getNames( names, interfaces[i] ); + } + } + } + + protected String[] packageNames( ArrayList names ) + { + String[] ret = new String[ names.size() ]; + for( int i= 0; i < names.size() ; i++ ) + ret[i] = (String) names.get(i); + return ret; + } + + protected void getNames( ArrayList names, Class clazz ) + throws ReflectionException + { + ///// NORMAL OBJECT + // Retrieve all PUBLIC, non-STATIC fields. + Field[] flds = clazz.getDeclaredFields(); + for( int i=0 ; i < flds.length ; i++ ) + { + int mod = flds[i].getModifiers(); + if( Modifier.isPublic( mod ) && !Modifier.isStatic( mod ) ) + { + String str = flds[i].getName(); + int j = str.indexOf( '_' ); + if( j == 1 ) + str = str.substring( 2 ); + names.add( str); + } + } + // Retrieve PUBLIC non-STATIC GET methods + Method[] methods = clazz.getMethods(); + for( int i=0 ; i < methods.length ; i++ ) + { + int mod = methods[i].getModifiers(); + if( Modifier.isPublic( mod ) && ! Modifier.isStatic( mod )) + { + String str = methods[i].getName(); + if( str.startsWith("get") ) + { + if( methods[i].getParameterTypes().length == 0 ) + { + str = str.substring( 3 ); + if( ! names.contains(str) ) + names.add( str ); + } + } + else if( str.startsWith("is") ) + { + if( methods[i].getParameterTypes().length == 0 ) + { + str = str.substring( 2 ); + if( ! names.contains(str) ) + names.add( str ); + } + } + } + } + } + + public Object getMemberObject( Object container, String memberName ) + throws ReflectionException + { + Method method = Util.findMethod( container, "get" + memberName ); + + if( method == null ) + method = Util.findMethod( container, "is" + memberName ); + + if( method != null && ! Modifier.isPublic( method.getModifiers() ) ) + method = null; + + if( method != null ) + { + try + { + if( method.getName().equals( "getTypes" ) ) + { + System.out.println( method.getName() ); + System.out.println( Modifier.isPublic( method.getModifiers() ) ); + System.out.println( method.getParameterTypes().length ); + System.out.println( method.getReturnType() ); + System.out.println( method.getDeclaringClass() ); + System.out.println( method.getExceptionTypes().length ); + } + return method.invoke(container, new Object[0] ); + } catch( IllegalAccessException e ) + { + throw new ReflectionException( container.getClass().toString() + ".get" + memberName + "() is not declared public.", e ); + } catch( IllegalArgumentException e ) + { + throw new ReflectionException(container.getClass().toString() + ".get" + memberName + "() received illegal arguments. Internal Error?", e); + } catch( InvocationTargetException e ) + { + Exception exc; + Throwable t = e.getTargetException(); + if( t instanceof Exception ) + exc = (Exception) t; + else + exc = null; + throw new ReflectionException( container.getClass().toString() + ".get" + memberName + "() resulted in an exception.\n" + e , exc ); + } + } + else + { + try + { + Field fld = Util.findField( container, memberName ); + return fld.get( container ); + } catch( Exception e ) + { + throw new ReflectionException( "Unable to access the field: " + memberName, e ); + } + } + } + + public void setMemberObject( Object container, String member, Object value ) + throws ReflectionException + { + Class cls = container.getClass(); + Field[] flds = cls.getDeclaredFields(); + Method method = Util.findMethod( container, "set" + member ); + if( method != null ) + { + try + { + Class[] argTypes = method.getParameterTypes(); + Object[] args = new Object[1]; + args[0] = value; + Object obj = method.invoke( container, args ); + } catch( IllegalAccessException e ) + { + throw new ReflectionException( container.getClass().toString() + ".set" + member + "() is not declared public.", e); + } catch( Exception e ) + { + throw new ReflectionException( "Problem accessing " + container.getClass().toString() + ".set" + member + "().", e); + } + } + if( method == null ) + { + for( int i=0; i < flds.length ; i++ ) + { + if( Util.matchField( flds[i].getName(), member ) ) + { + if( flds[i].getType().isPrimitive() ) + { + if( value instanceof String ) + { + try + { + Util.setPrimitive( flds[i], container, (String) value ); + } catch( IllegalAccessException e ) + { + throw new ReflectionException( "The field '" + member + "' of " + container.toString() + " is not declared public.", e); + } + } + } + else + setObject( flds[i], container, value ); + } + } + } + } + + public Class getClass( Object container, String memberName ) + throws ReflectionException + { + Method method = Util.findMethod( container, "get" + memberName ); + if( method == null ) + method = Util.findMethod( container, "is" + memberName ); + + if( method != null ) + { + Class retClass = method.getReturnType(); + if( Modifier.isNative(retClass.getModifiers()) ) + return retClass; + + // Native classes are not properly serialized/deserialized over RMI. + + return Util.expandNativeClass( retClass ); + } + try + { + Field fld = Util.findField( container, memberName ); + return fld.getType(); + } catch( NoSuchFieldException e ) + { + throw new ReflectionException( "Member '" + memberName + "' not found in " + container ); + } + } + + + public boolean isSettable( Object container, String memberName ) + throws ReflectionException + { + Method method = Util.findMethod( container, "set" + memberName ); + + if( method != null ) + return true; + else + return false; + } + + private void setObject( Field fld, Object obj, Object value ) + throws ReflectionException + { + // Create a new instance of the object + // Assign instance to reference. + Class fldClass = fld.getType(); + + Constructor[] constructors = fldClass.getConstructors(); + Constructor constr = null; + for( int j=0; j < constructors.length ; j++ ) + { + Class[] params = constructors[j].getParameterTypes(); + if( params.length == 1 && params[0].getName().equals("String")) + { + constr = constructors[j]; + break; + } + } + + if( constr != null ) + { + try + { + Object[] args = {value}; + Object newObj = constr.newInstance( args ); + fld.set(obj, newObj ); + } catch( Exception e ) + { + throw new ReflectionException( "Unable to construct a " + fldClass, e ); + } + } + else + throw new ReflectionException( "No valid Constructors available for object: " + fldClass ); + } +} Added: avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/ComponentModelTypeHandler.java ============================================================================== --- (empty file) +++ avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/ComponentModelTypeHandler.java Thu Aug 19 02:08:09 2004 @@ -0,0 +1,131 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.metro.facilities.reflector.typehandlers; + +import java.util.ArrayList; + +import org.apache.avalon.composition.model.ComponentModel; + +import org.apache.avalon.framework.service.Serviceable; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; + +import org.apache.metro.facilities.reflector.ReflectionException; + +import org.apache.metro.facilities.reflector.spi.ReflectorProvider; +import org.apache.metro.facilities.reflector.spi.TypeHandler; + +/** + * @avalon.component name="type-handler-componentmodel" lifestyle="singleton" + * @avalon.service type="org.apache.metro.facilities.reflector.spi.TypeHandler" + */ +public class ComponentModelTypeHandler extends AbstractObjectTypeHandler + implements Serviceable +{ + /** + * @avalon.dependency type="org.apache.metro.facilities.reflector.spi.ReflectorProvider" + * key="provider" + */ + public void service( ServiceManager man ) + throws ServiceException + { + ReflectorProvider provider = (ReflectorProvider) man.lookup( "provider" ); + provider.addTypeHandler( this, ComponentModel.class ); + } + + public boolean isDefault() + { + return false; + } + + public String[] getNames( Object container ) + throws ReflectionException + { + if( ! ( container instanceof ComponentModel ) ) + throw new ReflectionException( container + " is not a ComponentModel: " + container.getClass().getName() ); + ArrayList names = new ArrayList(); + names.add( "Implementation" ); + getNames( names, container ); + return packageNames( names ); + } + + public Object getMemberObject( Object container, String membername ) + throws ReflectionException + { + if( ! ( container instanceof ComponentModel ) ) + throw new ReflectionException( container + " is not a ComponentModel: " + container.getClass().getName() ); + if( membername.equals( "Implementation" ) ) + { + try + { + ComponentModel model = (ComponentModel) container; + Object instance = model.resolve( false ); + return instance; + } catch( Exception e ) + { + throw new ReflectionException( "Unable to obtain component instance.", e ); + } + } + return super.getMemberObject( container, membername ); + } + + public void setMemberObject( Object container, String membername, Object value ) + throws ReflectionException + { + if( ! ( container instanceof ComponentModel ) ) + throw new ReflectionException( container + " is not a ComponentModel: " + container.getClass().getName() ); + if( membername.equals( "Implementation" ) ) + { + // Not supported. + return; + } + super.setMemberObject( container, membername, value ); + } + + public Class getClass( Object container, String membername ) + throws ReflectionException + { + if( ! ( container instanceof ComponentModel ) ) + throw new ReflectionException( container + " is not a ComponentModel: " + container.getClass().getName() ); + if( membername.equals( "Implementation" ) ) + { + try + { + ComponentModel model = (ComponentModel) container; + Object instance = model.resolve( false ); + return instance.getClass(); + } catch( Exception e ) + { + throw new ReflectionException( "Unable to obtain component instance.", e ); + } + } + return super.getClass( container, membername ); + } + + public boolean isSettable( Object container, String membername ) + throws ReflectionException + { + if( ! ( container instanceof ComponentModel ) ) + throw new ReflectionException( container + " is not a ComponentModel: " + container.getClass().getName() ); + if( membername.equals( "Implementation" ) ) + { + return false; + } + return super.isSettable( container, membername ); + } +} Modified: avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/ObjectTypeHandler.java ============================================================================== --- avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/ObjectTypeHandler.java (original) +++ avalon/trunk/planet/facilities/reflector/typehandlers/src/main/org/apache/metro/facilities/reflector/typehandlers/ObjectTypeHandler.java Thu Aug 19 02:08:09 2004 @@ -17,13 +17,7 @@ package org.apache.metro.facilities.reflector.typehandlers; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import java.util.ArrayList; +import java.util.ArrayList; import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.service.ServiceException; @@ -33,16 +27,14 @@ import org.apache.metro.facilities.reflector.spi.ReflectorProvider; import org.apache.metro.facilities.reflector.spi.TypeHandler; -import org.apache.metro.facilities.reflector.spi.Util; /** * @avalon.component name="type-handler-object" lifestyle="singleton" * @avalon.service type="org.apache.metro.facilities.reflector.spi.TypeHandler" */ -public class ObjectTypeHandler - implements TypeHandler, Serviceable +public class ObjectTypeHandler extends AbstractObjectTypeHandler + implements Serviceable { - /** * @avalon.dependency type="org.apache.metro.facilities.reflector.spi.ReflectorProvider" * key="provider" @@ -58,251 +50,12 @@ { return true; } - - public String[] getNames( Object container ) - { - ArrayList names = new ArrayList(); - - Class clazz = container.getClass(); - - if( Modifier.isPublic( clazz.getModifiers() ) ) - getNames( names, clazz ); - else - { - ArrayList all = new ArrayList(); - Class[] interfaces = clazz.getInterfaces(); - for( int i=0 ; i < interfaces.length ; i++ ) - { - getNames( names, interfaces[i] ); - } - } - String[] ret = new String[ names.size() ]; - for( int i= 0; i < names.size() ; i++ ) - ret[i] = (String) names.get(i); - return ret; - } - - private void getNames( ArrayList names, Class clazz ) - { - ///// NORMAL OBJECT - // Retrieve all PUBLIC, non-STATIC fields. - Field[] flds = clazz.getDeclaredFields(); - for( int i=0 ; i < flds.length ; i++ ) - { - int mod = flds[i].getModifiers(); - if( Modifier.isPublic( mod ) && !Modifier.isStatic( mod ) ) - { - String str = flds[i].getName(); - int j = str.indexOf( '_' ); - if( j == 1 ) - str = str.substring( 2 ); - names.add( str); - } - } - // Retrieve PUBLIC non-STATIC GET methods - Method[] methods = clazz.getMethods(); - for( int i=0 ; i < methods.length ; i++ ) - { - int mod = methods[i].getModifiers(); - if( Modifier.isPublic( mod ) && ! Modifier.isStatic( mod )) - { - String str = methods[i].getName(); - if( str.startsWith("get") ) - { - if( methods[i].getParameterTypes().length == 0 ) - { - str = str.substring( 3 ); - if( ! names.contains(str) ) - names.add( str ); - } - } - else if( str.startsWith("is") ) - { - if( methods[i].getParameterTypes().length == 0 ) - { - str = str.substring( 2 ); - if( ! names.contains(str) ) - names.add( str ); - } - } - } - } - } - - public Object getMemberObject( Object container, String memberName ) - throws ReflectionException - { - Method method = Util.findMethod( container, "get" + memberName ); - - if( method == null ) - method = Util.findMethod( container, "is" + memberName ); - - if( method != null && ! Modifier.isPublic( method.getModifiers() ) ) - method = null; - - if( method != null ) - { - try - { - if( method.getName().equals( "getTypes" ) ) - { - System.out.println( method.getName() ); - System.out.println( Modifier.isPublic( method.getModifiers() ) ); - System.out.println( method.getParameterTypes().length ); - System.out.println( method.getReturnType() ); - System.out.println( method.getDeclaringClass() ); - System.out.println( method.getExceptionTypes().length ); - } - return method.invoke(container, new Object[0] ); - } catch( IllegalAccessException e ) - { - throw new ReflectionException( container.getClass().toString() + ".get" + memberName + "() is not declared public.", e ); - } catch( IllegalArgumentException e ) - { - throw new ReflectionException(container.getClass().toString() + ".get" + memberName + "() received illegal arguments. Internal Error?", e); - } catch( InvocationTargetException e ) - { - Exception exc; - Throwable t = e.getTargetException(); - if( t instanceof Exception ) - exc = (Exception) t; - else - exc = null; - throw new ReflectionException( container.getClass().toString() + ".get" + memberName + "() resulted in an exception.\n" + e , exc ); - } - } - else - { - try - { - Field fld = Util.findField( container, memberName ); - return fld.get( container ); - } catch( Exception e ) - { - throw new ReflectionException( "Unable to access the field: " + memberName, e ); - } - } - } - public void setMemberObject( Object container, String member, Object value ) - throws ReflectionException - { - Class cls = container.getClass(); - Field[] flds = cls.getDeclaredFields(); - Method method = Util.findMethod( container, "set" + member ); - if( method != null ) - { - try - { - Class[] argTypes = method.getParameterTypes(); - Object[] args = new Object[1]; - args[0] = value; - Object obj = method.invoke( container, args ); - } catch( IllegalAccessException e ) - { - throw new ReflectionException( container.getClass().toString() + ".set" + member + "() is not declared public.", e); - } catch( Exception e ) - { - throw new ReflectionException( "Problem accessing " + container.getClass().toString() + ".set" + member + "().", e); - } - } - if( method == null ) - { - for( int i=0; i < flds.length ; i++ ) - { - if( Util.matchField( flds[i].getName(), member ) ) - { - if( flds[i].getType().isPrimitive() ) - { - if( value instanceof String ) - { - try - { - Util.setPrimitive( flds[i], container, (String) value ); - } catch( IllegalAccessException e ) - { - throw new ReflectionException( "The field '" + member + "' of " + container.toString() + " is not declared public.", e); - } - } - } - else - setObject( flds[i], container, value ); - } - } - } - } - - public Class getClass( Object container, String memberName ) + public String[] getNames( Object container ) throws ReflectionException { - Method method = Util.findMethod( container, "get" + memberName ); - if( method == null ) - method = Util.findMethod( container, "is" + memberName ); - - if( method != null ) - { - Class retClass = method.getReturnType(); - if( Modifier.isNative(retClass.getModifiers()) ) - return retClass; - - // Native classes are not properly serialized/deserialized over RMI. - - return Util.expandNativeClass( retClass ); - } - try - { - Field fld = Util.findField( container, memberName ); - return fld.getType(); - } catch( NoSuchFieldException e ) - { - throw new ReflectionException( "Member '" + memberName + "' not found in " + container ); - } - } - - - public boolean isSettable( Object container, String memberName ) - { - Method method = Util.findMethod( container, "set" + memberName ); - - if( method != null ) - return true; - else - return false; + ArrayList names = new ArrayList(); + getNames( names, container ); + return packageNames( names ); } - - private void setObject( Field fld, Object obj, Object value ) - throws ReflectionException - { - // Create a new instance of the object - // Assign instance to reference. - Class fldClass = fld.getType(); - - Constructor[] constructors = fldClass.getConstructors(); - Constructor constr = null; - for( int j=0; j < constructors.length ; j++ ) - { - Class[] params = constructors[j].getParameterTypes(); - if( params.length == 1 && params[0].getName().equals("String")) - { - constr = constructors[j]; - break; - } - } - - if( constr != null ) - { - try - { - Object[] args = {value}; - Object newObj = constr.newInstance( args ); - fld.set(obj, newObj ); - } catch( Exception e ) - { - throw new ReflectionException( "Unable to construct a " + fldClass, e ); - } - } - else - throw new ReflectionException( "No valid Constructors available for object: " + fldClass ); - } - } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]