mcconnell 2002/12/19 22:38:19 Modified: assembly/src/java/org/apache/avalon/assembly/lifecycle ContextHandler.java assembly/src/java/org/apache/avalon/assembly/lifecycle/context DefaultContextualizationService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal ExtendedDisposalService.java assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization ExtendedInitializationService.java assembly/src/java/org/apache/avalon/assembly/lifestyle AbstractLifestyleHandler.java Log: Updates concerning context handling. Revision Changes Path 1.8 +32 -7 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/ContextHandler.java Index: ContextHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/ContextHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ContextHandler.java 19 Dec 2002 10:40:06 -0000 1.7 +++ ContextHandler.java 20 Dec 2002 06:38:18 -0000 1.8 @@ -228,21 +228,22 @@ { ContextDescriptor descriptor = appliance.getProfile().getType().getContext(); ContextDirective directive = appliance.getProfile().getContext(); - return buildContext( descriptor, directive, context ); + return buildContext( appliance, descriptor, directive, context ); } /** * Internal utility to construct a context instance using a descriptor, directive and source * context instances. * - * @param appliance the apliance containing the context dependency declarations + * @param appliance the appliance containing the context dependency declarations * @param context a supplimentary context object to used during value resolution - * @return a context object containing only those context entries desribed under the + * @return a context object containing only those context entries required under the * supplied descriptor * @exception Exception if a required context value cannot be resolved or an error * occurs during context value creation */ - protected Context buildContext( ContextDescriptor descriptor, ContextDirective directive, Context context ) + protected Context buildContext( + Appliance appliance, ContextDescriptor descriptor, ContextDirective directive, Context context ) throws Exception { if( !m_initialized ) @@ -253,6 +254,12 @@ Map map = new HashMap(); Context result; + // + // check for meta-data about how to create a specialized context type + // and if its present then create it using the standard constructor + // pattern otherwise use the DefaultContext implementation + // + if( directive != null ) { final String classname = directive.getClassname(); @@ -299,9 +306,20 @@ result = new DefaultContext( map ); } + // + // the context object has been constructed and not we need to populate it based + // on the context criteria declared by the component type + // + EntryDescriptor[] entries = getMergedEntries( descriptor ); getLogger().debug( "context " + descriptor + " contains " + entries.length + "entries" ); + // + // the above list of enties contains the entries explicity declared by the + // component in its xinfo + any entries declared in a service def for he context + // type + // + for( int i = 0; i < entries.length; i++ ) { EntryDescriptor entry = entries[ i ]; @@ -314,6 +332,13 @@ Object object = getContextValue( context, key ); // + // if the entry is a standard avalon context entry names (component name, + // partition, home or working directory, the handle it now + // + + //object = resolveStandardKey( appliance, context, key ); + + // // If the context value is unresolved, try to handle resolution // using an import directive supplied under the directive // @@ -469,11 +494,11 @@ * @return a new Context for service * @throws Exception if unable to create context */ - protected Context createContext( ExtensionDescriptor extension, Context context ) + protected Context createContext( Appliance appliance, ExtensionDescriptor extension, Context context ) throws Exception { ContextDescriptor descriptor = extension.getContext(); - return buildContext( descriptor, null, context ); + return buildContext( appliance, descriptor, null, context ); } /** 1.7 +20 -1 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefaultContextualizationService.java 19 Dec 2002 10:42:24 -0000 1.6 +++ DefaultContextualizationService.java 20 Dec 2002 06:38:18 -0000 1.7 @@ -128,6 +128,11 @@ if(( provider != null ) || (object instanceof Contextualizable )) { + + // + // the component is requesting contextualization in one form or another + // + if( getLogger().isDebugEnabled() ) { final String message = appliance.toString(); @@ -144,9 +149,19 @@ source = context; } + // + // populate the "standard" context with the actual context entries that + // the component is requesting + // + Context standard = createStandardContext( appliance, source ); + // + // resolve the contextualization strategy - either its a custom + // interface and handler, or its classic Avalon - try custom first + // + if( provider != null ) { if( getLogger().isDebugEnabled() ) @@ -170,6 +185,10 @@ throw new ContextException( error, e ); } } + + // + // otherwise, its classic contextulization + // try { 1.6 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/ExtendedDisposalService.java Index: ExtendedDisposalService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/disposal/ExtendedDisposalService.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ExtendedDisposalService.java 17 Dec 2002 05:02:25 -0000 1.5 +++ ExtendedDisposalService.java 20 Dec 2002 06:38:18 -0000 1.6 @@ -182,7 +182,7 @@ { Type type = provider.getProfile().getType(); final ExtensionDescriptor descriptor = type.getExtension( stage ); - context = createContext( descriptor, m_context ); + context = createContext( provider, descriptor, m_context ); } catch( Throwable e ) { 1.7 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/ExtendedInitializationService.java Index: ExtendedInitializationService.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/initialization/ExtendedInitializationService.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ExtendedInitializationService.java 17 Dec 2002 05:03:23 -0000 1.6 +++ ExtendedInitializationService.java 20 Dec 2002 06:38:19 -0000 1.7 @@ -164,7 +164,7 @@ { Type type = provider.getProfile().getType(); final ExtensionDescriptor descriptor = type.getExtension( stage ); - context = createContext( descriptor, m_context ); + context = createContext( provider, descriptor, m_context ); } catch( Throwable e ) { 1.11 +2 -2 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java Index: AbstractLifestyleHandler.java =================================================================== RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- AbstractLifestyleHandler.java 17 Dec 2002 11:35:50 -0000 1.10 +++ AbstractLifestyleHandler.java 20 Dec 2002 06:38:19 -0000 1.11 @@ -464,7 +464,7 @@ final ExtensionDescriptor ext = type.getExtension( stage ); try { - Context extensionContext = createContext( ext, context ); + Context extensionContext = createContext( provider, ext, context ); table.put( stage, extensionContext ); } catch( Throwable e )
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>