mcconnell 2002/09/10 23:56:20 Modified: enterprise/corbaloc build.properties build.xml enterprise/corbaloc/src/idl corbaloc.idl enterprise/corbaloc/src/java/org/apache/orb/corbaloc Handler.java Added: enterprise/corbaloc/lib excalibur-meta-1.0.jar enterprise/corbaloc/src/java/org/apache/orb/corbaloc AttributeDefaultFactory.java AttributeValue.java DescriptorDefaultFactory.java DescriptorValue.java Log: Updated to provide IIOP based propergation of a service description and related attributes (requires CORBA 2.3 valuetype implementation at runtime - e.g. JDK 1.4.1, OpenORB 1.3.0, ..). Revision Changes Path 1.2 +4 -0 jakarta-avalon-apps/enterprise/corbaloc/build.properties Index: build.properties =================================================================== RCS file: /home/cvs/jakarta-avalon-apps/enterprise/corbaloc/build.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- build.properties 7 Sep 2002 06:56:22 -0000 1.1 +++ build.properties 11 Sep 2002 06:56:19 -0000 1.2 @@ -9,3 +9,7 @@ MINOR=0 MICRO=0 +excalibur.dir = ../../jakarta-avalon-excalibur + +lib.dir=lib + 1.2 +26 -4 jakarta-avalon-apps/enterprise/corbaloc/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-apps/enterprise/corbaloc/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- build.xml 7 Sep 2002 06:56:22 -0000 1.1 +++ build.xml 11 Sep 2002 06:56:19 -0000 1.2 @@ -53,6 +53,7 @@ <property name="etc.dir" value="${src.dir}/etc" /> <property name="idl.dir" value="${src.dir}/idl" /> <property name="build.dir" value="build" /> + <property name="lib.dir" value="lib" /> <property name="overview.html" value="${etc.dir}/overview.html" /> <property name="javadoc.root.path" value="${build.dir}/api" /> @@ -61,7 +62,6 @@ <property name="idl.class" value="org.openorb.compiler.IdlCompiler" /> - <path id="project.classpath"> <fileset dir="${common.path}/lib"> <include name="logkit*.jar" /> @@ -70,6 +70,9 @@ <fileset dir="${orb.path}/lib"> <include name="openorb*.jar" /> </fileset> + <fileset dir="${lib.dir}"> + <include name="excalibur-meta-1.0.jar" /> + </fileset> </path> <!-- MAIN TARGETS --> @@ -83,7 +86,7 @@ <!-- PREPARE --> - <target name="prepare" > + <target name="prepare" depends="meta.update"> <mkdir dir="${build.dir}/src" /> <mkdir dir="${build.dir}/lib" /> </target> @@ -99,6 +102,9 @@ <srcfiles dir="${build.dir}/lib"> <include name="org/apache/orb/**/*.*"/> </srcfiles> + <srcfiles dir="${lib.dir}"> + <include name="**/*.*"/> + </srcfiles> </uptodate> </target> @@ -117,6 +123,7 @@ </classpath> <arg line="-silence"/> <arg line="-native URL java.net.URL"/> + <arg line="-native Version org.apache.avalon.framework.Version"/> <arg line="-d ${build.dir}/src"/> <arg line="-I ${idl.dir}"/> <arg line="corbaloc.idl" /> @@ -128,7 +135,6 @@ <javac debug="off" destdir="${build.dir}/lib" deprecation="true" target="1.2"> <classpath> <path refid="project.classpath" /> - <pathelement path="${build.dir}/lib" /> </classpath> <src path="${build.dir}/src" /> <src path="${src.dir}/java" /> @@ -169,5 +175,21 @@ <link href="${jdk.href}" /> </javadoc> </target> - + + <!-- + Update the local copy of the ORB. + --> + + <target name="meta.context"> + <mkdir dir="${lib.dir}"/> + <available property="meta.available" + file="${excalibur.dir}/meta/build/lib/excalibur-meta-1.0.jar"/> + </target> + + <target name="meta.update" depends="meta.context" if="meta.available"> + <echo message="updating meta jar file"/> + <copy toDir="${lib.dir}" + file="${excalibur.dir}/meta/build/lib/excalibur-meta-1.0.jar"/> + </target> + </project> 1.1 jakarta-avalon-apps/enterprise/corbaloc/lib/excalibur-meta-1.0.jar <<Binary file>> 1.2 +154 -4 jakarta-avalon-apps/enterprise/corbaloc/src/idl/corbaloc.idl Index: corbaloc.idl =================================================================== RCS file: /home/cvs/jakarta-avalon-apps/enterprise/corbaloc/src/idl/corbaloc.idl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- corbaloc.idl 7 Sep 2002 06:55:01 -0000 1.1 +++ corbaloc.idl 11 Sep 2002 06:56:20 -0000 1.2 @@ -1,5 +1,5 @@ // -// hello.idl +// corbaloc.idl // // Created on 13 February 2002 // by Stephen McConnell <[EMAIL PROTECTED]> @@ -7,11 +7,109 @@ #ifndef _CORBALOC_IDL_ #define _CORBALOC_IDL_ -#pragma prefix "orb.apache.org" +module org +{ +module apache +{ +module orb +{ module corbaloc { + native Version; + + valuetype Attribute; + + valuetype Attributes sequence <Attribute>; + + valuetype Descriptor; + + valuetype Descriptors sequence <Descriptor>; + + abstract valuetype AttributeProvider + { + /** + * Returns the nested attributes. + * @return the sequence of nested attribute values + */ + Attributes getAttributes(); + + /** + * Returns a attribute value for a key using a default value + * @param the default value if the key is undefined + * @return the attribute value + */ + string getAttribute( in string theKey, in string value ); + + }; + + /** + * An attribute. + */ + valuetype Attribute : AttributeProvider + { + /** + * The key. + */ + private string m_key; + + /** + * The value. + */ + private string m_value; + + /** + * The nested attributes. + */ + private Attributes m_attributes; + + /** + * Attribute key. + * @return the attribute key + */ + string getKey(); + + /** + * Attribute value. + * @return the attribute value + */ + string getValue(); + }; + + /** + * A valuetype that declares meta information about a service. + */ + valuetype Descriptor : AttributeProvider + { + /** + * The service classname. + */ + private string m_type; + + /** + * The service version. + */ + private string m_version; + + /** + * The nested attributes. + */ + private Attributes m_attributes; + + /** + * Returns a service type. + * @return the service type (the interface classname) + */ + string getType(); + + /** + * Returns a service version. + * @return the service version + */ + Version getVersion(); + }; + /** * Exception indicating the referral of the request to an * alternative URL. @@ -56,7 +154,6 @@ * A message detailing the cause of the invalid status. */ string message; - }; /** @@ -100,15 +197,68 @@ InvalidQuery, UnknownReference, InvalidReference, ServiceRedirection ); }; + /** + * An abstract interface that provides information of published services. + */ + abstract interface Registry + { + /** + * Returns a sequence of services registered with the type. + */ + Descriptors getDescriptors(); + }; /** * The ServiceResolver interface defines a corbaloc resolvable resource capable * of handling unresolved corbaloc fragments. */ - interface ServiceResolver : Resolver + interface ServiceResolver : Resolver, Registry { }; + /** + * An abstract interface implemented by objects capable of handling + * URL based queries. + */ + abstract interface Finder + { + /** + * Process a query based on a URL query syntax. A url of the + * form corbaloc::home.osm.net/gateway?connect=true%amp;value=3 will have + * a query element corresponding to <code>connect=true%amp;value=3</code>. + * Query strings are composed of a sequence of query name value pairs + * where each pair is delimited by the %amp; character. + * + * @param query the query string + * @return the query value + * @exception InvalidQuery if the query is invalid + * @exception ServiceRedirection if the query is being redirected + */ + any query( in string query ) raises ( InvalidQuery, ServiceRedirection ); + }; + + /** + * An abstract interface implemented by objects capable of handling + * URL based reference lookup. + */ + abstract interface Chooser + { + /** + * Process a query based on a URL ref syntax. A url of the + * form <code>corbaloc::home.osm.net/gateway#12345A</code> will have + * a ref element corresponding to <code>12345A</code>. + * + * @param reference the ref string + * @return the result of the reference selection + * @exception UnknownReference if the supplied ref cannot be resolved + * @exception ServiceRedirection if the ref reesolution is being redirected + */ + any select( in string reference ) raises ( UnknownReference, InvalidReference, ServiceRedirection ); + }; +}; +}; }; +}; + #endif // _CORBALOC_IDL_ 1.2 +13 -0 jakarta-avalon-apps/enterprise/corbaloc/src/java/org/apache/orb/corbaloc/Handler.java Index: Handler.java =================================================================== RCS file: /home/cvs/jakarta-avalon-apps/enterprise/corbaloc/src/java/org/apache/orb/corbaloc/Handler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Handler.java 7 Sep 2002 06:53:40 -0000 1.1 +++ Handler.java 11 Sep 2002 06:56:20 -0000 1.2 @@ -71,6 +71,19 @@ public Handler( ORB orb ) { m_orb = orb; + org.omg.CORBA_2_3.ORB orb23 = (org.omg.CORBA_2_3.ORB) orb; + + if( orb23.lookup_value_factory( DescriptorHelper.id() ) == null ) + { + orb23.register_value_factory( + DescriptorHelper.id(), + new DescriptorDefaultFactory() + ); + orb23.register_value_factory( + AttributeHelper.id(), + new AttributeDefaultFactory() + ); + } } /** 1.1 jakarta-avalon-apps/enterprise/corbaloc/src/java/org/apache/orb/corbaloc/AttributeDefaultFactory.java Index: AttributeDefaultFactory.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. * * Original contribution OSM SARL 2002, http://www.osm.net */ package org.apache.orb.corbaloc; import java.io.Serializable; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.StreamableValue; import org.omg.CORBA_2_3.portable.InputStream; import org.omg.CORBA.portable.ValueFactory; /** * Link valuetype held by a resource containing a reference to * User that administyers the resource. */ public class AttributeDefaultFactory implements ValueFactory { //========================================================== // ValueFactory //========================================================== /** * Descriptor factory. */ public Serializable read_value( InputStream input ) { return input.read_value( new AttributeValue() ); } } 1.1 jakarta-avalon-apps/enterprise/corbaloc/src/java/org/apache/orb/corbaloc/AttributeValue.java Index: AttributeValue.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. * * Original contribution OSM SARL 2002, http://www.osm.net */ package org.apache.orb.corbaloc; import java.io.Serializable; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.StreamableValue; import org.omg.CORBA_2_3.portable.InputStream; import org.omg.CORBA.portable.ValueFactory; /** * Link valuetype held by a resource containing a reference to * User that administyers the resource. */ public class AttributeValue extends Attribute implements ValueFactory { //========================================================== // constructors //========================================================== /** * Default constructor for stream internalization. */ public AttributeValue() { } /** * Creation of a new descriptor based on a supplied key and value * @param key the attribute key * @param value the attribute value */ public AttributeValue( String key, String value ) { this( key, value, new Attribute[0] ); } /** * Creation of a new descriptor based on a supplied attribute sequence. * @param key the attribute key * @param value the attribute value * @param attributes a sequence of nested attributes */ public AttributeValue( String key, String value, Attribute[] attributes ) { if( key == null ) { throw new NullPointerException( "key" ); } if( value == null ) { throw new NullPointerException( "value" ); } if( attributes == null ) { throw new NullPointerException( "attributes" ); } m_attributes = attributes; m_key = key; m_value = value; } //======================================================================== // Descriptor //======================================================================== /** * Attribute key. * @return the attribute key */ public String getKey() { return m_key; } /** * Attribute value. * @return the attribute value */ public String getValue() { return m_value; } /** * Returns an nested attributes. * @return the sequence of nested attribute values */ public Attribute[] getAttributes() { return m_attributes; } /** * Returns a attribute value for a key using a default value * @param the default value if the key is undefined * @return the attribute value */ public String getAttribute( String key, String value ) { String result = getAttribute( key ); if( result != null ) { return result; } return value; } /** * Returns a attribute value for a key. * @return the attribute value or null of the key is unknown */ private String getAttribute( String key ) { for( int i=0; i<m_attributes.length; i++ ) { final Attribute attribute = m_attributes[i]; if( attribute.getKey().equals( key ) ) { return attribute.getValue(); } } return null; } //========================================================== // ValueFactory //========================================================== /** * Descriptor factory. */ public Serializable read_value( InputStream input ) { return input.read_value( new DescriptorValue() ); } } 1.1 jakarta-avalon-apps/enterprise/corbaloc/src/java/org/apache/orb/corbaloc/DescriptorDefaultFactory.java Index: DescriptorDefaultFactory.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. * * Original contribution OSM SARL 2002, http://www.osm.net */ package org.apache.orb.corbaloc; import java.io.Serializable; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.StreamableValue; import org.omg.CORBA_2_3.portable.InputStream; import org.omg.CORBA.portable.ValueFactory; /** * Link valuetype held by a resource containing a reference to * User that administyers the resource. */ public class DescriptorDefaultFactory implements ValueFactory { public DescriptorDefaultFactory() { } //========================================================== // ValueFactory //========================================================== /** * Descriptor factory. */ public Serializable read_value( InputStream input ) { return input.read_value( new DescriptorValue() ); } } 1.1 jakarta-avalon-apps/enterprise/corbaloc/src/java/org/apache/orb/corbaloc/DescriptorValue.java Index: DescriptorValue.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. * * Original contribution OSM SARL 2002, http://www.osm.net */ package org.apache.orb.corbaloc; import java.io.Serializable; import java.util.ArrayList; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.StreamableValue; import org.omg.CORBA_2_3.portable.InputStream; import org.omg.CORBA.portable.ValueFactory; import org.apache.avalon.framework.Version; import org.apache.excalibur.meta.info.ServiceDescriptor; /** * Link valuetype held by a resource containing a reference to * User that administyers the resource. */ public class DescriptorValue extends Descriptor implements ValueFactory { //========================================================== // constructors //========================================================== /** * Default constructor for stream internalization. */ public DescriptorValue() { } /** * Creation of a new descriptor based on a supplied meta info description. * * @param type the type descriptor */ public DescriptorValue( ServiceDescriptor service ) { ArrayList list = new ArrayList(); String[] keys = service.getAttributeNames(); m_type = service.getService().getClassname(); m_version = service.getService().getVersion().toString(); for( int i=0; i<keys.length; i++ ) { String key = keys[i]; String value = service.getAttribute( key ); list.add( new AttributeValue( key, value ) ); } m_attributes = (Attribute[]) list.toArray( new Attribute[0] ); } //======================================================================== // Descriptor //======================================================================== /** * Returns an nested attributes. * @return the sequence of nested attribute values */ public Attribute[] getAttributes() { return m_attributes; } /** * Returns a service type. * @return the service type (the interface classname) */ public String getType() { return m_type; } /** * Returns a service version. * @return the service version */ public Version getVersion() { return Version.getVersion( m_version ); } /** * Returns a attribute value for a key using a default value * @param the default value if the key is undefined * @return the attribute value */ public String getAttribute( String key, String value ) { String result = getAttribute( key ); if( result != null ) { return result; } return value; } /** * Returns a attribute value for a key. * @return the attribute value or null of the key is unknown */ private String getAttribute( String key ) { for( int i=0; i<m_attributes.length; i++ ) { final Attribute attribute = m_attributes[i]; if( attribute.getKey().equals( key ) ) { return attribute.getValue(); } } return null; } //========================================================== // ValueFactory //========================================================== /** * Descriptor factory. */ public Serializable read_value( InputStream input ) { return input.read_value( new DescriptorValue() ); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>