mcconnell 2002/12/20 03:56:37 Modified: meta/src/java/org/apache/avalon/meta/info ContextDescriptor.java EntryDescriptor.java meta/src/java/org/apache/avalon/meta/info/builder XMLServiceCreator.java meta/src/java/org/apache/avalon/meta/model Profile.java Log: Added support for the assication of alias names with entries. Revision Changes Path 1.4 +13 -4 avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/ContextDescriptor.java Index: ContextDescriptor.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/ContextDescriptor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ContextDescriptor.java 19 Dec 2002 10:52:47 -0000 1.3 +++ ContextDescriptor.java 20 Dec 2002 11:56:37 -0000 1.4 @@ -118,7 +118,7 @@ /** * Return the reference decription for the context. * - * @return the referencee descriptor. + * @return the reference descriptor. */ public ReferenceDescriptor getReference() { @@ -126,7 +126,7 @@ } /** - * Return the entries contained in the context. + * Return the local entries contained in the context. * * @return the entries contained in the context. */ @@ -136,7 +136,12 @@ } /** - * Return the entry with specified key. + * Return the entry with specified key. If the supplied key + * corresponds to an alias entry, the key backing the lias will be + * returned. If the supplied key corresponds to a key, that key + * entry will be returned. If the key does not correspond with + * wither an elias or key, null is returned. + * * @param key the context entry key to lookup * @return the entry with specified key. */ @@ -145,6 +150,10 @@ for( int i = 0; i < m_entries.length; i++ ) { final EntryDescriptor entry = m_entries[ i ]; + if( entry.getAlias().equals( key ) ) + { + return entry; + } if( entry.getKey().equals( key ) ) { return entry; 1.2 +34 -1 avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/EntryDescriptor.java Index: EntryDescriptor.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/EntryDescriptor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- EntryDescriptor.java 24 Nov 2002 12:58:26 -0000 1.1 +++ EntryDescriptor.java 20 Dec 2002 11:56:37 -0000 1.2 @@ -73,6 +73,11 @@ private final String m_key; /** + * An alias to a key. + */ + private final String m_alias; + + /** * The class/interface of the Entry. */ private final String m_type; @@ -98,10 +103,27 @@ * Construct an Entry. * @param key the context entry key * @param type the classname of the context entry + * @param alias an alternative key used by the component to reference the key + * @param optional TRUE if this is an optional entry + * @exception NullPointerException if the key or type value are null + */ + public EntryDescriptor( final String key, + final String type, + final boolean optional ) throws NullPointerException + { + this( key, null, type, optional ); + } + + /** + * Construct an Entry. + * @param key the context entry key + * @param type the classname of the context entry + * @param alias an alternative key used by the component to reference the key * @param optional TRUE if this is an optional entry * @exception NullPointerException if the key or type value are null */ public EntryDescriptor( final String key, + final String alias, final String type, final boolean optional ) throws NullPointerException { @@ -118,6 +140,7 @@ m_key = key; m_type = type; m_optional = optional; + m_alias = alias; } /** @@ -128,6 +151,16 @@ public String getKey() { return m_key; + } + + /** + * Return the alias that Component uses to lookup entry. + * + * @return the alias to the key. + */ + public String getAlias() + { + return m_alias; } /** 1.3 +3 -2 avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/builder/XMLServiceCreator.java Index: XMLServiceCreator.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/builder/XMLServiceCreator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XMLServiceCreator.java 19 Dec 2002 10:52:47 -0000 1.2 +++ XMLServiceCreator.java 20 Dec 2002 11:56:37 -0000 1.3 @@ -190,10 +190,11 @@ { final String key = config.getAttribute( "key" ); final String type = config.getAttribute( "type", "java.lang.String" ); + final String alias = config.getAttribute( "alias", null ); final boolean optional = config.getAttributeAsBoolean( "optional", false ); - return new EntryDescriptor( key, type, optional ); + return new EntryDescriptor( key, alias, type, optional ); } 1.7 +16 -2 avalon-sandbox/meta/src/java/org/apache/avalon/meta/model/Profile.java Index: Profile.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/src/java/org/apache/avalon/meta/model/Profile.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Profile.java 15 Dec 2002 17:48:03 -0000 1.6 +++ Profile.java 20 Dec 2002 11:56:37 -0000 1.7 @@ -266,7 +266,21 @@ } else { - m_name = name; + if( mode.equals( Mode.PACKAGED ) ) + { + if( type.getInfo().getName().equals( name ) ) + { + m_name = type.getInfo().getName(); + } + else + { + m_name = type.getInfo().getName() + "#" + name; + } + } + else + { + m_name = name; + } } if( null == categories )
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>