From: cvs@openprivacy.orgCVS update: talon/src/java/talon
Date: Tuesday March 13, 19101 @ 21:43
Author: burton
CVSWEB Options: -------------------
Main CVSWeb: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi
View this module: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon
-----------------------------------
Update of /usr/local/cvs/public/talon/src/java/talon
In directory giga:/tmp/cvs-serv811/src/java/talon
Modified Files:
BaseComponent.java ComponentHandle.java ReferenceFactory.java
Log Message:
interface determination is now the default
*****************************************************************
File: talon/src/java/talon/BaseComponent.java
CVSWEB Options: -------------------
CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/BaseComponent.java?annotate=1.10
CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/BaseComponent.java?rev=1.10&content-type=text/x-cvsweb-markup
CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/BaseComponent.java.diff?r1=1.10&r2=1.9
-----------------------------------
Index: talon/src/java/talon/BaseComponent.java
diff -u talon/src/java/talon/BaseComponent.java:1.9 talon/src/java/talon/BaseComponent.java:1.10
--- talon/src/java/talon/BaseComponent.java:1.9 Tue Mar 13 01:53:07 2001
+++ talon/src/java/talon/BaseComponent.java Tue Mar 13 21:43:35 2001
@@ -21,7 +21,7 @@
* develoeprs as a base for the Components they create.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public abstract class BaseComponent implements Component {
@@ -41,7 +41,7 @@
/**
* @see Component
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle getComponentHandle() {
return this.handle;
@@ -50,7 +50,7 @@
/**
* @see Component
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public void setComponentHandle( ComponentHandle handle ) {
this.handle = handle;
@@ -59,7 +59,7 @@
/**
* @see Component
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public URI getComponentReference() {
@@ -78,7 +78,7 @@
* the method in that class.
* @see Component
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public URI getTypeReference() {
@@ -92,7 +92,7 @@
/**
* @see Component
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public Logger getLogger() {
try {
@@ -115,7 +115,7 @@
* Default impl of toString() just dumps handle info...
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public String toString() {
return this.getComponentHandle().toString();
@@ -124,67 +124,14 @@
/**
* @see Component
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: BaseComponent.java,v 1.9 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: BaseComponent.java,v 1.10 2001/03/14 05:43:35 burton Exp $
*/
public Class[] getInterfaces() {
if ( componentInterfaces == null ) {
- Vector knownInterfaces = new Vector();
-
- //go through every class and determine all known interfacs
-
- Class current = getClass();
-
- while ( current != null ) {
-
- Class[] interfaces = current.getInterfaces();
-
- for ( int i = 0; i < interfaces.length; ++i ) {
-
- if ( knownInterfaces.contains( interfaces[i] ) == false ){
-
- knownInterfaces.addElement( interfaces[i] );
-
- }
-
- }
-
- current = current.getSuperclass();
-
- }
-
-
- //go through all of these interfaces and if these are Component
- //interfaces add them.
-
- //go over all knownInterfaces and remove any that don't apply.
-
- for ( int i = 0; i < knownInterfaces.size(); ++i ) {
-
- Class currentInterface = (Class)knownInterfaces.elementAt( i );
-
- //remove the talon.Component interface... we don't need this.
- if ( currentInterface.equals( talon.Component.class ) ||
- currentInterface.getName().equals( talon.Component.class.getName() ) ) {
-
- knownInterfaces.removeElement( currentInterface );
+ this.componentInterfaces = ReferenceFactory.getInterfaces( this.getClass() );
- }
-
- //make sure this isn't just a random class like Serializable, etc.
- //It must implement a Talon component.
- if ( ! Component.class.isAssignableFrom( currentInterface ) ) {
-
- knownInterfaces.removeElement( currentInterface );
-
- }
-
- }
-
- this.componentInterfaces = new Class[ knownInterfaces.size() ];
- knownInterfaces.copyInto( this.componentInterfaces );
-
}
return componentInterfaces;
*****************************************************************
File: talon/src/java/talon/ComponentHandle.java
CVSWEB Options: -------------------
CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentHandle.java?annotate=1.12
CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentHandle.java?rev=1.12&content-type=text/x-cvsweb-markup
CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentHandle.java.diff?r1=1.12&r2=1.11
-----------------------------------
Index: talon/src/java/talon/ComponentHandle.java
diff -u talon/src/java/talon/ComponentHandle.java:1.11 talon/src/java/talon/ComponentHandle.java:1.12
--- talon/src/java/talon/ComponentHandle.java:1.11 Fri Mar 9 16:10:43 2001
+++ talon/src/java/talon/ComponentHandle.java Tue Mar 13 21:43:35 2001
@@ -23,7 +23,7 @@
* to hold property information.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public class ComponentHandle {
@@ -57,7 +57,7 @@
* URI. Default is none.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
private String name = null;
@@ -65,7 +65,7 @@
* Create a basic ComponentHandle
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle() {}
@@ -74,7 +74,7 @@
* pulled from the Talon properties.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle( String _interface ) {
@@ -85,7 +85,7 @@
/**
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle( String _interface,
String _implementation ) {
@@ -99,7 +99,7 @@
/**
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle( String _interface,
String _classname,
@@ -112,7 +112,7 @@
/**
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle( String name,
String _interface,
@@ -131,7 +131,7 @@
* component.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public String getInterface() {
return _interface;
@@ -164,6 +164,15 @@
}
/**
+ * Set the value of _classname.
+ * @param v Value to assign to _classname.
+ */
+ public ComponentHandle setImplementation( Class _implementation ) {
+ this.setImplementation( _implementation.getName() );
+ return this;
+ }
+
+ /**
* Get the name for this component.
*/
public String getName() {
@@ -180,7 +189,7 @@
/**
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public String getLifetime() {
return this._lifetime;
@@ -190,7 +199,7 @@
/**
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle setLifetime( String _lifetime ) {
this._lifetime = _lifetime;
@@ -199,7 +208,7 @@
/**
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public String getDescription() {
return this._description;
@@ -207,7 +216,7 @@
/**
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle setDescription( String _description ) {
this._description = _description;
@@ -219,7 +228,7 @@
* initialization.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public PropertyManager getInitProperties() {
return this.initProperties;
@@ -228,7 +237,7 @@
/**
* @see #getInitProperties
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public ComponentHandle setInitProperties( PropertyManager initProperties ) {
this.initProperties = initProperties;
@@ -239,7 +248,7 @@
* Dump Handle information..
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public String toString() {
//FIXME: output the typeReference
@@ -249,7 +258,7 @@
/**
* @see Component
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public URI getTypeReference() {
@@ -265,7 +274,7 @@
* Return a cloned ComponentHandle.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentHandle.java,v 1.11 2001/03/10 00:10:43 burton Exp $
+ * @version $Id: ComponentHandle.java,v 1.12 2001/03/14 05:43:35 burton Exp $
*/
public Object clone() {
*****************************************************************
File: talon/src/java/talon/ReferenceFactory.java
CVSWEB Options: -------------------
CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ReferenceFactory.java?annotate=1.4
CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ReferenceFactory.java?rev=1.4&content-type=text/x-cvsweb-markup
CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ReferenceFactory.java.diff?r1=1.4&r2=1.3
-----------------------------------
Index: talon/src/java/talon/ReferenceFactory.java
diff -u talon/src/java/talon/ReferenceFactory.java:1.3 talon/src/java/talon/ReferenceFactory.java:1.4
--- talon/src/java/talon/ReferenceFactory.java:1.3 Tue Mar 13 01:53:07 2001
+++ talon/src/java/talon/ReferenceFactory.java Tue Mar 13 21:43:35 2001
@@ -25,7 +25,7 @@
* @see #Component.getTypeReference
* @see #ComponentHandle.getTypeReference
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ReferenceFactory.java,v 1.3 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: ReferenceFactory.java,v 1.4 2001/03/14 05:43:35 burton Exp $
*/
public class ReferenceFactory {
@@ -33,7 +33,7 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ReferenceFactory.java,v 1.3 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: ReferenceFactory.java,v 1.4 2001/03/14 05:43:35 burton Exp $
*/
public static URI getComponentReference( Component component ) {
@@ -57,8 +57,10 @@
String _interface = component.getComponentHandle().getInterface();
//FIXME: rewrite this to use the calculated interfaces.
-
- return new URI( "talon://" + host + "/component/" + _implementation + "/interface/" + _interface + "/hashcode/" + component.hashCode() );
+
+ Class[] interfaces = getInterfaces( component.getClass() );
+
+ return new URI( "talon://" + host + "/component/" + _implementation + buildInterfaceURIPart( interfaces ) + "/hashcode/" + component.hashCode() );
}
@@ -67,7 +69,7 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ReferenceFactory.java,v 1.3 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: ReferenceFactory.java,v 1.4 2001/03/14 05:43:35 burton Exp $
*/
public static URI getTypeReference( Component component ) {
@@ -75,33 +77,34 @@
ComponentHandle handle = component.getComponentHandle();
- StringBuffer interfaceURIPart = new StringBuffer();
-
- if ( handle.getInterface() == null ) {
+ String interfaceURIPart = buildInterfaceURIPart( component.getInterfaces() );
- Class[] interfaces = component.getInterfaces();
-
- for ( int i = 0; i < interfaces.length; ++i ) {
- interfaceURIPart.append( "/interface/" );
- interfaceURIPart.append( interfaces[i].getName() );
- }
-
- return getTypeReference( handle, interfaceURIPart.toString() );
- }
+ return getTypeReference( handle, interfaceURIPart );
- return getTypeReference( handle );
-
}
/**
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ReferenceFactory.java,v 1.3 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: ReferenceFactory.java,v 1.4 2001/03/14 05:43:35 burton Exp $
*/
public static URI getTypeReference( ComponentHandle handle ) {
+
+ try {
+
+ Class clazz = Class.forName( handle.getImplementation() );
+
+ Class[] interfaces = getInterfaces( clazz );
- return getTypeReference( handle, "/interface/" + handle.getInterface() );
+ return getTypeReference( handle, buildInterfaceURIPart( interfaces ));
+
+ } catch ( Throwable t ) {
+
+ //if for some reason we can't instantiate this... just use the
+ //default (which may be null.
+ return getTypeReference( handle, "/interface/" + handle.getInterface() );
+ }
}
@@ -109,11 +112,95 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ReferenceFactory.java,v 1.3 2001/03/13 09:53:07 burton Exp $
+ * @version $Id: ReferenceFactory.java,v 1.4 2001/03/14 05:43:35 burton Exp $
*/
private static URI getTypeReference( ComponentHandle handle, String interfaceURIPart) {
return new URI( "talon:///component/" + handle.getImplementation() + interfaceURIPart );
+
+ }
+
+ /**
+ *
+ *
+ * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
+ * @version $Id: ReferenceFactory.java,v 1.4 2001/03/14 05:43:35 burton Exp $
+ */
+ private static String buildInterfaceURIPart( Class[] interfaces ) {
+
+ StringBuffer interfaceURIPart = new StringBuffer();
+
+ for ( int i = 0; i < interfaces.length; ++i ) {
+ interfaceURIPart.append( "/interface/" );
+ interfaceURIPart.append( interfaces[i].getName() );
+ }
+
+ return interfaceURIPart.toString();
+
+ }
+
+ /**
+ *
+ *
+ * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
+ * @version $Id: ReferenceFactory.java,v 1.4 2001/03/14 05:43:35 burton Exp $
+ */
+ static Class[] getInterfaces( Class current ) {
+
+ Vector knownInterfaces = new Vector();
+
+ //go through every class and determine all known interfacs
+
+ while ( current != null ) {
+
+ Class[] interfaces = current.getInterfaces();
+
+ for ( int i = 0; i < interfaces.length; ++i ) {
+
+ if ( knownInterfaces.contains( interfaces[i] ) == false ){
+
+ knownInterfaces.addElement( interfaces[i] );
+
+ }
+
+ }
+
+ current = current.getSuperclass();
+
+ }
+
+
+ //go through all of these interfaces and if these are Component
+ //interfaces add them.
+
+ //go over all knownInterfaces and remove any that don't apply.
+
+ for ( int i = 0; i < knownInterfaces.size(); ++i ) {
+
+ Class currentInterface = (Class)knownInterfaces.elementAt( i );
+
+ //remove the talon.Component interface... we don't need this.
+ if ( currentInterface.equals( talon.Component.class ) ||
+ currentInterface.getName().equals( talon.Component.class.getName() ) ) {
+
+ knownInterfaces.removeElement( currentInterface );
+
+ }
+
+ //make sure this isn't just a random class like Serializable, etc.
+ //It must implement a Talon component.
+ if ( ! Component.class.isAssignableFrom( currentInterface ) ) {
+
+ knownInterfaces.removeElement( currentInterface );
+
+ }
+
+ }
+
+ Class[] componentInterfaces = new Class[ knownInterfaces.size() ];
+ knownInterfaces.copyInto( componentInterfaces );
+
+ return componentInterfaces;
}
This archive was generated by hypermail 2b30 : Tue Mar 13 2001 - 21:44:06 PST