mcconnell 2003/01/08 19:58:27 Modified: assembly/src/java/org/apache/avalon/assembly/engine EngineClassLoader.java assembly/src/java/org/apache/avalon/assembly/lifecycle DefaultAssemblyService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/context DefaultContextManager.java DefaultContextualizationService.java assembly/src/test/org/apache/avalon/playground/basic BasicComponent.xinfo Log: Updates to the contextualization strategy. Revision Changes Path 1.22 +3 -3 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java Index: EngineClassLoader.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- EngineClassLoader.java 8 Jan 2003 21:21:40 -0000 1.21 +++ EngineClassLoader.java 9 Jan 2003 03:58:26 -0000 1.22 @@ -804,9 +804,9 @@ } /** - * Register a type and associated profiles with the container. + * Register a type and associated profiles with the engine. * @param path the path to the appliance implementation class - * @return the appliance + * @exception EngineRuntimeException if a registration error occurs */ public void register( String path ) throws EngineRuntimeException { 1.4 +4 -4 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultAssemblyService.java Index: DefaultAssemblyService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultAssemblyService.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DefaultAssemblyService.java 21 Dec 2002 03:28:37 -0000 1.3 +++ DefaultAssemblyService.java 9 Jan 2003 03:58:26 -0000 1.4 @@ -277,7 +277,7 @@ visited.add( appliance ); ContextDescriptor context = appliance.getType().getContext(); - String ext = context.getAttribute( "urn:assembly:lifecycle.context.extension" ); + String ext = context.getAttribute( "urn:assembly:lifecycle.context.strategy" ); if(( ext != null ) && ( appliance.getContextProvider() == null )) { final String message = "resolving context handler for: " + appliance ; @@ -303,7 +303,7 @@ if( supplier == null ) { final String error = - "Unresolved context handler: " + "Unresolved context strategy handler: " + ext + " in appliance: " + appliance; appliance.setEnabled( false ); final Exception problem = new Exception( error ); @@ -314,7 +314,7 @@ appliance.setContextProvider( supplier ); map.add( supplier ); getLogger().debug( - "assigning context handler: " + supplier + "assigning context strategy handler: " + supplier + " to: " + appliance ); } } 1.2 +5 -5 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/DefaultContextManager.java Index: DefaultContextManager.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/DefaultContextManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultContextManager.java 19 Dec 2002 10:42:24 -0000 1.1 +++ DefaultContextManager.java 9 Jan 2003 03:58:26 -0000 1.2 @@ -64,20 +64,20 @@ import org.apache.avalon.assembly.appliance.Appliance; /** - * Definition of an extension handler that handles the Contextualization + * Definition of an strategy handler that handles the Contextualization * process. This implementation is provided as a template for alternative * context handlers. The requirements for introduction of an alternative * handler include: * <ul> - * <li>A class implementing the [EMAIL PROTECTED] Contextualization} interface.</li> + * <li>A class implementing the [EMAIL PROTECTED] Contextualization} handler interface.</li> * <li>Declaration in the classes xinfo of the extension type where the * type attribute value is a version interface reference corresponding * to the interface that the target component must implement.</li> * <li>Declaration by the target component in it's xinfo atttributes * of the criteria for a custom context handler under the attribute - * key "urn:assembly:lifecycle.context.extension" and value - * corresponding to the extension type value. </li> - * <li>Implementation of the extension type interface by the target + * key "urn:assembly:lifecycle.context.strategy" and value + * corresponding to the strategy type. </li> + * <li>Implementation of the strategy type interface by the target * component.</li> * </ul> * 1.10 +34 -18 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/DefaultContextualizationService.java Index: DefaultContextualizationService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/context/DefaultContextualizationService.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DefaultContextualizationService.java 21 Dec 2002 09:26:34 -0000 1.9 +++ DefaultContextualizationService.java 9 Jan 2003 03:58:26 -0000 1.10 @@ -102,7 +102,6 @@ if( context != null ) { - Appliance provider = appliance.getContextProvider(); // @@ -135,31 +134,48 @@ } // - // otherwise, its classic contextulization + // otherwise, its classic Avalon contextulization // - try + if( object instanceof Contextualizable ) { - ((Contextualizable)object).contextualize( context ); + try + { + ((Contextualizable)object).contextualize( context ); + } + catch( ContextException e ) + { + // + // this could be improved if the framework ContextException + // held the context key that the client is accessing + // + + final String error = + "Target component is requesting a context entry that has not been declared." + + " Please check component xinfo descriptor context criteria in type: " + + appliance.getType(); + throw new ContextException( error, e ); + } + catch( Throwable e ) + { + final String error = + "Unexpected exception during contextualization of target: " + appliance; + throw new ContextException( error, e ); + } } - catch( ContextException e ) + else { // - // this could be improved if the framework ContextException - // held the context key that the client is accessing + // the appliance has established a context argument for classic Avalon + // contextualization but the target object does not implement the + // Avalon Contextualization interface // final String error = - "Target component is requesting a context entry that has not been declared." - + " Please check component xinfo descriptor context criteria in type: " - + appliance.getType(); - throw new ContextException( error, e ); - } - catch( Throwable e ) - { - final String error = - "Unexpected exception during contextualization of target: " + appliance; - throw new ContextException( error, e ); + "Appliance " + + appliance + + " is handling an object that is declaring a contextualization dependency but does not implement the Avalon Contextualization interface."; + throw new ContextException( error ); } } } 1.2 +1 -1 avalon-sandbox/assembly/src/test/org/apache/avalon/playground/basic/BasicComponent.xinfo Index: BasicComponent.xinfo =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/playground/basic/BasicComponent.xinfo,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- BasicComponent.xinfo 19 Dec 2002 10:46:17 -0000 1.1 +++ BasicComponent.xinfo 9 Jan 2003 03:58:27 -0000 1.2 @@ -21,7 +21,7 @@ <context type="org.apache.avalon.playground.basic.BasicContext"> <attributes> - <attribute key="urn:assembly:lifecycle.context.extension" + <attribute key="urn:assembly:lifecycle.context.strategy" value="org.apache.avalon.framework.context.Contextualizable:4.1"/> </attributes> <entry key="location"/>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>