mcconnell 2002/09/12 01:30:04 Modified: assembly build.xml assembly/src/etc activation.mf assembly/src/java/org/apache/excalibur/merlin/assembly TypeManager.java assembly/src/java/org/apache/excalibur/playground/activation TestServant.xinfo Added: assembly/src/java/org/apache/excalibur/merlin/assembly ServiceRegistry.java Log: Addition of a ServiceRegistry supporting the seperate service meta-info. Revision Changes Path 1.61 +2 -1 jakarta-avalon-excalibur/assembly/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- build.xml 11 Sep 2002 16:38:30 -0000 1.60 +++ build.xml 12 Sep 2002 08:30:04 -0000 1.61 @@ -474,7 +474,8 @@ --> <target name="orb.context"> - <available property="orb.available" file="${apps.dir}/enterprise/orb/dist/orb-2.0.jar"/> + <available property="orb.available" + file="${apps.dir}/enterprise/orb/dist/orb-2.0.jar"/> </target> <target name="orb.update" depends="orb.context" if="orb.available"> 1.4 +1 -1 jakarta-avalon-excalibur/assembly/src/etc/activation.mf Index: activation.mf =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/activation.mf,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- activation.mf 12 Sep 2002 06:09:14 -0000 1.3 +++ activation.mf 12 Sep 2002 08:30:04 -0000 1.4 @@ -12,5 +12,5 @@ Name: org/apache/excalibur/merlin/activation/Directory.class Avalon: Type -Name: org/apache/excalibur/merlin/activation/TestCase.class +Name: org/apache/excalibur/playground/activation/TestCase.class Avalon: Service 1.21 +29 -5 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java Index: TypeManager.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- TypeManager.java 10 Sep 2002 23:07:21 -0000 1.20 +++ TypeManager.java 12 Sep 2002 08:30:04 -0000 1.21 @@ -115,6 +115,11 @@ private TypeRegistry m_types; /** + * The service registry. + */ + private ServiceRegistry m_services; + + /** * The base directory. */ private File m_home; @@ -214,6 +219,7 @@ getLocalLogger().debug("initialize"); m_types = new TypeRegistry( this, getLocalLogger().getChildLogger( "types" ) ); + m_services = new ServiceRegistry( this, getLocalLogger().getChildLogger( "services" ) ); // // handle the bootstrap process @@ -307,13 +313,13 @@ final Iterator it = attributes.keySet().iterator(); while( it.hasNext() ) { + final String path = cleanName( name ); + final Object entry = it.next(); if( entry.toString().equals( "Avalon-Block" ) ) { if( attributes.get( entry ).equals( "true" ) ) { - final String path = - name.substring( 0, name.indexOf( ".class" ) ); try { m_types.addBlock( path ); @@ -336,8 +342,6 @@ { if( attributes.get( entry ).equals( "Type" ) ) { - final String path = - name.substring( 0, name.indexOf( ".class" ) ); try { m_types.addType( path ); @@ -348,6 +352,18 @@ getLocalLogger().warn( warning, e ); } } + else if( attributes.get( entry ).equals( "Service" ) ) + { + try + { + m_services.addService( path ); + } + catch( Throwable e ) + { + final String warning = "Bypassing service: " + path ; + getLocalLogger().warn( warning, e ); + } + } } } } @@ -680,4 +696,12 @@ return (Manifest[])manifests.toArray( new Manifest[ 0 ] ); } + /** + * Strips the ".class" ending off of a Type/Block/Service name. + */ + private final String cleanName( String name ) + { + int end = name.indexOf( ".class" ); + return name.substring( 0, ( end >= 0 ) ? end : name.length() ); + } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ServiceRegistry.java Index: ServiceRegistry.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import java.util.List; import java.util.LinkedList; import java.util.ArrayList; import java.util.Hashtable; import java.util.Vector; import java.util.Iterator; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.meta.info.Service; import org.apache.excalibur.meta.info.builder.ServiceBuilder; import org.apache.excalibur.meta.verifier.VerifyException; /** * Internal table that holds available component type keyed relative * to the service it provides. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a> * @version $Revision: 1.1 $ $Date: 2002/09/12 08:30:04 $ */ class ServiceRegistry extends AbstractLogEnabled { //======================================================================= // state //======================================================================= private ServiceBuilder m_builder = new ServiceBuilder(); private ClassLoader m_classloader; /** * Service types keyed by classname. */ private Hashtable m_table = new Hashtable(); //======================================================================= // constructor //======================================================================= /** * Creation of a new service registry. * @param registry the registry that will be supplied to new component defintions * @param loader the registry class loader * @param profiles the configuration fragment containing explicit component profiles */ public ServiceRegistry( ClassLoader loader, Logger logger ) { m_classloader = loader; super.enableLogging( logger ); m_builder.enableLogging( logger ); getLogger().debug("service registry established"); } //======================================================================= // implemetation //======================================================================= /** * Test is a service is know in the registry. */ public boolean isLocal( String classname ) { return getService( classname ) != null; } /** * Register a service defintion. * * @param classname the service class name * @return the service descriptor */ public Service addService( String path ) throws Exception { final String classname = path.replace('/','.'); getLogger().debug("service: " + classname ); Service service = getService( classname ); if( service == null ) { service= m_builder.build( classname, m_classloader ); m_table.put( classname, service ); } return service; } /** * Returns the service implementation class. * * @param type the service defintion * @exception VerifyException if the service fails verification */ protected Class getServiceClass( Service service ) throws Exception { return m_classloader.loadClass( service.getClassname() ); } /** * Returns the set of services know to the registry. * @return the services */ public Service[] getServices() { return (Service[]) m_table.values().toArray( new Service[0] ); } /** * Returns the set of services matching a supplied phase. * @return the set of types capable of supporting the stage. */ public Service getService( ReferenceDescriptor reference ) { Service service = (Service) m_table.get( reference.getClassname() ); if( service.matches( reference ) ) { return service; } return null; } /** * Returns a registered component type. * @return the component type from the registry or null if the type is unknown */ public Service getService( String classname ) { return (Service) m_table.get( classname ); } } 1.5 +1 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/activation/TestServant.xinfo Index: TestServant.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/activation/TestServant.xinfo,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TestServant.xinfo 11 Sep 2002 06:57:24 -0000 1.4 +++ TestServant.xinfo 12 Sep 2002 08:30:04 -0000 1.5 @@ -51,7 +51,7 @@ </component> <services> - <service> + <service> <attributes> <attribute key="avalon:service.protocol" value="iiop"/> <attribute key="avalon:service.name" value="test-case"/>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>