mcconnell 2002/09/10 23:57:24 Modified: assembly/lib corbaloc-1.0.jar assembly/src/etc/activator client.xml assembly/src/java/org/apache/excalibur/merlin/activation Directory.java Directory.xinfo assembly/src/java/org/apache/excalibur/merlin/assembly TypeRegistry.java assembly/src/java/org/apache/excalibur/merlin/service DefaultRegistry.java Registry.java assembly/src/java/org/apache/excalibur/playground/activation ActivationClient.java TestServant.xinfo Log: Updates to handle service descriptor propergation. Revision Changes Path 1.6 +190 -101 jakarta-avalon-excalibur/assembly/lib/corbaloc-1.0.jar <<Binary file>> 1.5 +8 -4 jakarta-avalon-excalibur/assembly/src/etc/activator/client.xml Index: client.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/activator/client.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- client.xml 9 Sep 2002 13:34:49 -0000 1.4 +++ client.xml 11 Sep 2002 06:57:24 -0000 1.5 @@ -21,6 +21,13 @@ <include name="extensions"/> </library> + <classpath> + <fileset dir="lib"> + <include name="corbaloc-1.0.jar"/> + </fileset> + </classpath> + + <!-- Defintion of a container within a PSS enhanced ORB folowed by a Property service. @@ -39,9 +46,6 @@ --> <classpath> - <fileset dir="lib"> - <include name="corbaloc-1.0.jar"/> - </fileset> <fileset dir="build/lib"> <include name="demo.jar"/> </fileset> @@ -62,7 +66,7 @@ class="org.apache.excalibur.playground.activation.ActivationClient" activation="true"> <categories priority="DEBUG"/> <configuration> - <connection url="corbaloc:iiop:1.2@localhost:2056/public/demo"/> + <connection url="corbaloc:iiop:1.2@localhost:2056/public"/> </configuration> </component> 1.2 +35 -37 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/Directory.java Index: Directory.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/Directory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Directory.java 9 Sep 2002 13:44:53 -0000 1.1 +++ Directory.java 11 Sep 2002 06:57:24 -0000 1.2 @@ -4,6 +4,7 @@ import java.io.Serializable; import java.net.URL; import java.net.MalformedURLException; +import java.util.ArrayList; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; @@ -25,6 +26,8 @@ import org.apache.orb.corbaloc.ServiceResolverOperations; import org.apache.orb.corbaloc.ServiceResolverPOATie; import org.apache.orb.corbaloc.ServiceResolverHelper; +import org.apache.orb.corbaloc.Descriptor; +import org.apache.orb.corbaloc.DescriptorValue; import org.openorb.corbaloc.CorbalocService; import org.openorb.corbaloc.CorbalocServiceHelper; @@ -36,6 +39,7 @@ import org.apache.excalibur.merlin.service.UnknownServiceException; import org.apache.excalibur.merlin.service.InvalidPathException; import org.apache.excalibur.merlin.model.Resource; +import org.apache.excalibur.meta.info.ServiceDescriptor; import org.omg.CORBA.Any; import org.omg.PortableServer.POA; @@ -194,6 +198,7 @@ getLogger().info("remote: " + m_corbaloc ); } + //======================================================================= // Startable //======================================================================= @@ -293,7 +298,36 @@ final String error = "Supplied path is a local service."; throw new InvalidReference( path, error ); - } + } + + /** + * Returns a sequence of services registered with the type. + * @return the set of descriptors + */ + public Descriptor[] getDescriptors() + { + Resource[] resources = m_registry.getResources(); + ArrayList list = new ArrayList(); + for( int i=0; i<resources.length; i++ ) + { + Resource resource = resources[i]; + ServiceDescriptor[] services = resource.getServices(); + for( int j=0; j<services.length; j++ ) + { + final ServiceDescriptor service = services[j]; + String protocol = service.getAttribute("avalon:service.protocol", null ); + if( protocol != null ) + { + if( protocol.equals("iiop") ) + { + list.add( new DescriptorValue( service ) ); + } + } + } + } + return (Descriptor[]) list.toArray( new Descriptor[0] ); + } + //======================================================================= // Disposable @@ -308,40 +342,4 @@ super.dispose(); } - //======================================================================= - // implementation - //======================================================================= - - /** - * Pack a value in an. - * @param any the Any - * @return Object the any contents as a Java Object - */ - private Any putResult( Any any, Object object ) - { - if( any == null ) - { - throw new NullPointerException("any"); - } - if( object == null ) - { - throw new NullPointerException("object"); - } - - if( object instanceof org.omg.CORBA.Object ) - { - any.insert_Object( (org.omg.CORBA.Object) object ); - return any; - } - else if( object instanceof Serializable ) - { - any.insert_Value((Serializable) object ); - return any; - } - else - { - throw new IllegalStateException( - "Object type: " + any.type().kind().value() + " unsupported."); - } - } } 1.2 +4 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/Directory.xinfo Index: Directory.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/activation/Directory.xinfo,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Directory.xinfo 9 Sep 2002 13:44:53 -0000 1.1 +++ Directory.xinfo 11 Sep 2002 06:57:24 -0000 1.2 @@ -35,7 +35,10 @@ <services> <service> - <reference type="org.apache.orb.corbaloc.ServiceResolverOperations" /> + <attributes> + <attribute key="avalon:service.protocol" value="iiop"/> + </attributes> + <reference type="org.apache.orb.corbaloc.ServiceResolver" /> </service> <service> <reference type="org.apache.excalibur.merlin.container.Container" /> 1.11 +6 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java Index: TypeRegistry.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- TypeRegistry.java 22 Aug 2002 10:20:09 -0000 1.10 +++ TypeRegistry.java 11 Sep 2002 06:57:24 -0000 1.11 @@ -166,7 +166,11 @@ ServiceDescriptor[] services = type.getServices(); for( int i=0; i<services.length; i++ ) { - vector.add( getServiceClass( services[i] ) ); + ServiceDescriptor service = services[i]; + if( service.getAttribute("avalon:service.protocol","native").equals("native") ) + { + vector.add( getServiceClass( services[i] ) ); + } } return (Class[]) vector.toArray( new Class[0] ); } 1.2 +43 -21 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultRegistry.java Index: DefaultRegistry.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultRegistry.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultRegistry.java 9 Sep 2002 13:44:53 -0000 1.1 +++ DefaultRegistry.java 11 Sep 2002 06:57:24 -0000 1.2 @@ -10,6 +10,7 @@ import java.net.URL; import java.net.MalformedURLException; import java.util.Map; +import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; @@ -158,13 +159,16 @@ */ public void bind( Resource resource ) { - final String name = resource.getProfile().getName(); - if( m_table.get( name ) != null ) + synchronized( m_children ) { - final String error = "Duplicate name: " + name; - throw new IllegalArgumentException( error ); + final String name = resource.getProfile().getName(); + if( m_children.get( name ) != null ) + { + final String error = "Duplicate name: " + name; + throw new IllegalArgumentException( error ); + } + m_children.put( name, resource ); } - m_table.put( name, resource ); } /** @@ -175,19 +179,22 @@ */ public void unbind( Resource resource ) { - String name = resource.getProfile().getName(); - Iterator iterator = m_table.entrySet().iterator(); - while( iterator.hasNext() ) - { - Resource res = (Resource) iterator.next(); - if( res.getProfile().getName().equals( name ) ) - { - m_table.remove( name ); - break; - } + synchronized( m_children ) + { + String name = resource.getProfile().getName(); + Iterator iterator = m_children.entrySet().iterator(); + while( iterator.hasNext() ) + { + Resource res = (Resource) iterator.next(); + if( res.getProfile().getName().equals( name ) ) + { + m_children.remove( name ); + break; + } + } + final String error = "Unknown resource: " + name; + throw new IllegalArgumentException( error ); } - final String error = "Unknown resource: " + name; - throw new IllegalArgumentException( error ); } /** @@ -203,7 +210,7 @@ if( uri.indexOf("/") > -1 ) { String name = uri.substring( 0, uri.indexOf("/") ); - Registry child = (Registry) m_children.get( name ); + Registry child = (Registry) m_table.get( name ); if( child != null ) { return child.locate( uri.substring( uri.indexOf("/") + 1, uri.length() ) ); @@ -224,14 +231,14 @@ if( child != null ) { // - // then forward the request to the child context + // then forward the request to the child // return child.locate(""); } else { - Resource resource = (Resource) m_table.get( uri ); + Resource resource = (Resource) m_children.get( uri ); if( resource != null ) { return resource; @@ -240,6 +247,21 @@ throw new UnknownServiceException( uri, error ); } } + } + + /** + * Returns a list of published resources. + * @return the resources + */ + public synchronized Resource[] getResources() + { + Object[] children = m_children.keySet().toArray(); + ArrayList list = new ArrayList(); + for( int i=0; i<children.length; i++ ) + { + list.add( m_children.get( children[i] ) ); + } + return (Resource[]) list.toArray( new Resource[0] ); } } 1.2 +7 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/Registry.java Index: Registry.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/Registry.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Registry.java 9 Sep 2002 13:44:53 -0000 1.1 +++ Registry.java 11 Sep 2002 06:57:24 -0000 1.2 @@ -61,6 +61,12 @@ */ Resource locate( String uri ) throws UnknownServiceException, InvalidPathException; + /** + * Returns a list of published resources. + * @return the set of published resources + */ + Resource[] getResources( ); + } 1.3 +23 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/activation/ActivationClient.java Index: ActivationClient.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/activation/ActivationClient.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ActivationClient.java 9 Sep 2002 04:30:48 -0000 1.2 +++ ActivationClient.java 11 Sep 2002 06:57:24 -0000 1.3 @@ -17,6 +17,10 @@ import org.omg.CORBA.ORB; import org.apache.orb.corbaloc.Handler; +import org.apache.orb.corbaloc.ServiceResolver; +import org.apache.orb.corbaloc.ServiceResolverHelper; +import org.apache.orb.corbaloc.Descriptor; +import org.apache.orb.corbaloc.Attribute; /** @@ -30,7 +34,7 @@ private Configuration m_config; - private TestCase m_object; + private ServiceResolver m_object; private String m_path; private URL m_url; private ORB m_orb; @@ -79,9 +83,25 @@ getLogger().debug("url: " + m_url ); org.omg.CORBA.Object object = (org.omg.CORBA.Object) connection.getContent(); getLogger().info("got an object: " + object.getClass().getName() ); - m_object = TestCaseHelper.narrow( object ); - m_object.test(); + m_object = ServiceResolverHelper.narrow( object ); getLogger().debug("object: " + m_object.getClass().getName() ); + Descriptor[] descriptors = m_object.getDescriptors(); + getLogger().info("descriptor count: " + descriptors.length ); + for( int i=0; i<descriptors.length; i++ ) + { + Descriptor descriptor = descriptors[i]; + getLogger().info( "type: " + descriptor.getType() + ":" + + descriptor.getVersion() ); + + Attribute[] attributes = descriptor.getAttributes(); + for( int j=0; j<attributes.length; j++ ) + { + Attribute attribute = attributes[j]; + getLogger().info( + " attribute: " + attribute.getKey() + + ", " + attribute.getValue() ); + } + } } catch( Throwable e ) { 1.4 +11 -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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TestServant.xinfo 10 Sep 2002 23:07:21 -0000 1.3 +++ TestServant.xinfo 11 Sep 2002 06:57:24 -0000 1.4 @@ -52,7 +52,17 @@ <services> <service> - <reference type="org.apache.excalibur.playground.activation.TestCaseOperations"/> + <attributes> + <attribute key="avalon:service.protocol" value="iiop"/> + <attribute key="avalon:service.name" value="test-case"/> + <attribute key="avalon:service.title" value="Test Case"/> + <attribute key="avalon:service.summary"> + Demonstration of the test-case remote service activation. + </attribute> + <attribute key="avalon:service.description" + value="http://home.osm.net/doc/merlin/test-case.html"/> + </attributes> + <reference type="org.apache.excalibur.playground.activation.TestCase"/> </service> </services>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>