adammurdoch 2002/06/25 00:32:11 Modified: container/src/java/org/apache/myrmidon/components/configurer DefaultConfigurer.java Log: Changed how the configurer maps a element to the typed adder. Not sure it's any better. Revision Changes Path 1.58 +26 -35 jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java Index: DefaultConfigurer.java =================================================================== RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- DefaultConfigurer.java 25 Jun 2002 00:35:20 -0000 1.57 +++ DefaultConfigurer.java 25 Jun 2002 07:32:11 -0000 1.58 @@ -313,7 +313,7 @@ // Locate the configurer for the child element final PropertyConfigurer childConfigurer = - getConfigurerFromName( state.getConfigurer(), name, true, true, context ); + getConfigurerFromName( state.getConfigurer(), name, true, context ); // Create & configure the child element final Object child = @@ -342,7 +342,7 @@ // Set the property final String name = element.getName(); - setReference( state, name, id, context, true ); + setReference( state, name, id, context ); } /** @@ -351,8 +351,7 @@ private void setReference( final ConfigurationState state, final String refName, final String unresolvedId, - final TaskContext context, - final boolean isAdder ) + final TaskContext context ) throws Exception { // Adjust the name @@ -360,7 +359,7 @@ // Locate the configurer for the property final PropertyConfigurer configurer = - getConfigurerFromName( state.getConfigurer(), name, false, isAdder, context ); + getConfigurerFromName( state.getConfigurer(), name, false, context ); // Resolve any props in the id String id = context.resolveValue( unresolvedId ).toString(); @@ -403,8 +402,11 @@ throws Exception { // Set the value - final PropertyConfigurer property = - getConfigurerFromName( state.getConfigurer(), name, false, false, context ); + final PropertyConfigurer property = state.getConfigurer().getSetter( name ); + if( property == null ) + { + throw new NoSuchPropertyException(); + } setValue( property, state, value, context ); } @@ -506,49 +508,38 @@ private PropertyConfigurer getConfigurerFromName( final ObjectConfigurer configurer, final String name, boolean ignoreRoleName, - final boolean isAdder, final TaskContext context ) throws Exception { // Try a named property - if( !isAdder ) + PropertyConfigurer propertyConfigurer = configurer.getAdder( name ); + if( propertyConfigurer != null ) { - PropertyConfigurer propertyConfigurer = configurer.getSetter( name ); - if( propertyConfigurer != null ) - { - return propertyConfigurer; - } + return propertyConfigurer; } - else + + // Try a typed property + propertyConfigurer = configurer.getTypedProperty(); + if( propertyConfigurer != null ) { - PropertyConfigurer propertyConfigurer = configurer.getAdder( name ); - if( propertyConfigurer != null ) + if( ignoreRoleName ) { return propertyConfigurer; } - - // Try a typed property - propertyConfigurer = configurer.getTypedProperty(); - if( propertyConfigurer != null ) + else { - if( ignoreRoleName ) + // Check the role name + final RoleManager roleManager = + (RoleManager)context.getService( RoleManager.class ); + final RoleInfo roleInfo = roleManager.getRoleByShortName( name ); + if( roleInfo != null + && propertyConfigurer.getType().isAssignableFrom( roleInfo.getImplementationClass() ) ) { return propertyConfigurer; } - else - { - // Check the role name - final RoleManager roleManager = - (RoleManager)context.getService( RoleManager.class ); - final String classname = propertyConfigurer.getType().getName(); - final RoleInfo roleInfo = roleManager.getRoleByInterface( classname ); - if( roleInfo != null && name.equalsIgnoreCase( roleInfo.getShortName() ) ) - { - return propertyConfigurer; - } - } } } + // Unknown prop throw new NoSuchPropertyException(); } -- To unsubscribe, e-mail: For additional commands, e-mail: