From: cvs@openprivacy.orgCVS update: talon/src/java/talon
Date: Sunday March 11, 19101 @ 22:17
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-serv30816/src/java/talon
Modified Files:
ComponentFactory.java HandleManager.java TalonException.java
Log Message:
...
*****************************************************************
File: talon/src/java/talon/ComponentFactory.java
CVSWEB Options: -------------------
CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentFactory.java?annotate=1.11
CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentFactory.java?rev=1.11&content-type=text/x-cvsweb-markup
CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentFactory.java.diff?r1=1.11&r2=1.10
-----------------------------------
Index: talon/src/java/talon/ComponentFactory.java
diff -u talon/src/java/talon/ComponentFactory.java:1.10 talon/src/java/talon/ComponentFactory.java:1.11
--- talon/src/java/talon/ComponentFactory.java:1.10 Sun Mar 11 01:50:47 2001
+++ talon/src/java/talon/ComponentFactory.java Sun Mar 11 22:17:29 2001
@@ -17,7 +17,7 @@
* Create instances of components and manage their lifetimes.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
public class ComponentFactory {
@@ -68,7 +68,7 @@
* Static initializer...
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
static {
@@ -82,11 +82,13 @@
* Given a ComponentHandle get a Component
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
public static Component getInstance( ComponentHandle handle )
throws TalonException {
+
+ //init Talon... this only executes once (if talon isn't already initialized)
Initializer.init();
//FIXME: if the component we fetch isn't the correct implementation of
@@ -103,66 +105,28 @@
if ( handle.getLifetime() == null ) {
handle.setLifetime( LIFETIME_DEMAND );
}
-
- //try to fill in any blank information
- if ( handle.getName() != null ) {
-
- try {
-
- ComponentHandle realHandle = HandleManager.byName( handle.getName() );
-
- //interface
- if ( realHandle.getInterface() != null && handle.getInterface() == null ) {
- handle.setInterface( realHandle.getInterface() );
- }
-
- //implementation
- if ( realHandle.getImplementation() != null && handle.getImplementation() == null ) {
- handle.setImplementation( realHandle.getImplementation() );
- }
-
- //consider merging init properties sometime in the future.
- if ( handle.getInitProperties().size() == 0 && realHandle.getInitProperties().size() != 0 ) {
-
- logger.debug( "Handle provided doesn't have any properties." );
- handle.setInitProperties( realHandle.getInitProperties() );
-
- }
-
-
-
- } catch ( NotFoundException nfe ) {
- //this is a normal state. We are just basically hoping that an
- //implementation is registered here so that we can find out the
- //correct interface.
- }
-
- }
+ //Try to fill in any blank information. A Component can be instantiated
+ //by multiple methods. (name, interface, implementation) and we need to
+ //try to fill in any blank information.
+
- //if the inteface is null. see if the implementation is in the
- //HandleManager and use this.
- try {
-
- ComponentHandle interfaceHandle = HandleManager.byImplementation( handle.getImplementation() );
+ constrain( handle.getName(), handle, HandleManager.getNameRegistry() );
+ constrain( handle.getImplementation(), handle, HandleManager.getImplementationRegistry() );
- if ( handle.getInterface() == null && interfaceHandle.getInterface() != null ) {
- handle.setInterface( interfaceHandle.getInterface() );
- }
-
- } catch ( NotFoundException nfe ) {
- //this is a normal state. We are just basically hoping that an
- //implementation is registered here so that we can find out the
- //correct interface.
- }
+ //no go over the handle and make sure we have enough information.
//if the interface is still unknown. Make sure we warn the user.
if ( handle.getInterface() == null ) {
logger.warning( "Unknown interface for handle: " + handle.toString() );
}
-
+
+ //if the implementatio is unknown there is nothing we can do
+ if ( handle.getImplementation() == null ) {
+ throw new TalonException( "Unable to determine implementation classname." );
+ }
//determine what lifetime to use
@@ -177,11 +141,65 @@
throw new TalonException( "Do not know how to create " + handle.toString() );
}
+ private static void constrain( String name,
+ ComponentHandle handle,
+ PropertyManager repository ) {
+
+ if ( name != null && repository.containsKey( name ) ) {
+
+
+ ComponentHandle prototype = (ComponentHandle)repository.getProperty( name );
+
+ constrain( handle, prototype);
+
+ }
+
+
+ }
+
+
+ /**
+ * Assume that the given handle does not have all known information. Use
+ * the given prototype as a basis for getting more info.
+ *
+ * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
+ */
+ private static void constrain( ComponentHandle handle,
+ ComponentHandle prototype ) {
+
+ //name
+ if ( prototype.getName() != null && handle.getName() == null ) {
+ handle.setName( prototype.getName() );
+ }
+
+ //interface
+ if ( prototype.getInterface() != null && handle.getInterface() == null ) {
+ handle.setInterface( prototype.getInterface() );
+ }
+
+ //implementation
+ if ( prototype.getImplementation() != null && handle.getImplementation() == null ) {
+ handle.setImplementation( prototype.getImplementation() );
+ }
+
+ //consider merging init properties sometime in the future.
+
+ if ( handle.getInitProperties().size() == 0 && prototype.getInitProperties().size() != 0 ) {
+
+ logger.debug( "Handle provided doesn't have any properties." );
+ handle.setInitProperties( prototype.getInitProperties() );
+
+ }
+
+
+ }
+
/**
* Get a component instantiating a new one everytime we need it.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
private static Component getDemandBasedInstance( ComponentHandle handle )
throws TalonException {
@@ -196,7 +214,7 @@
* Get a singleton or create it if necessary.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
private static Component getSingletonBasedInstance( ComponentHandle handle )
throws TalonException {
@@ -219,7 +237,7 @@
* Perform basic instantiation on a component.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
private static Component instantiateComponent( ComponentHandle handle )
throws TalonException {
@@ -232,8 +250,7 @@
return comp;
} catch ( Throwable t ) {
- t.printStackTrace();
- throw new TalonException( t.getMessage() );
+ throw new TalonException( t );
}
}
@@ -242,7 +259,7 @@
* Put a singleton to the Factory.
* FIXME: Should this throw an Exception if this object is already present?
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
static void putSingleton( ComponentHandle handle, Component comp ) {
singletons.put( handle, comp );
@@ -255,7 +272,7 @@
* don't have to worry about fetching an object from the component system.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
public static Logger getLogger() {
return ComponentFactory.logger;
@@ -265,7 +282,7 @@
*
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: ComponentFactory.java,v 1.10 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: ComponentFactory.java,v 1.11 2001/03/12 06:17:29 burton Exp $
*/
public static void setLogger( Logger logger ) {
ComponentFactory.logger = logger;
*****************************************************************
File: talon/src/java/talon/HandleManager.java
CVSWEB Options: -------------------
CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/HandleManager.java?annotate=1.7
CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/HandleManager.java?rev=1.7&content-type=text/x-cvsweb-markup
CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/HandleManager.java.diff?r1=1.7&r2=1.6
-----------------------------------
Index: talon/src/java/talon/HandleManager.java
diff -u talon/src/java/talon/HandleManager.java:1.6 talon/src/java/talon/HandleManager.java:1.7
--- talon/src/java/talon/HandleManager.java:1.6 Sun Mar 11 01:50:47 2001
+++ talon/src/java/talon/HandleManager.java Sun Mar 11 22:17:29 2001
@@ -21,7 +21,7 @@
* them.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
public class HandleManager extends BaseComponent {
@@ -64,7 +64,7 @@
* If the given handles does NOT already exist. Add it.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
private static void registerComponentHandle( SimplePropertyManager manager,
String key,
@@ -83,7 +83,7 @@
* Get a handle by its name
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
public static ComponentHandle byName( String _name )
throws TalonException {
@@ -103,7 +103,7 @@
* Get a handle by its interface
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
public static ComponentHandle byInterface( String _interface )
throws TalonException {
@@ -116,7 +116,7 @@
* Get a handle by its impl
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
public static ComponentHandle byImplementation( String _implementation )
throws TalonException {
@@ -132,19 +132,40 @@
}
/**
- * Get all registered components
+ * Get a specic registry.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
- public static PropertyManager getRegistry() {
+ static PropertyManager getNameRegistry() {
return byName;
}
/**
+ * Get a specic registry.
+ *
+ * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
+ */
+ static PropertyManager getInterfaceRegistry() {
+ return byInterface;
+ }
+
+
+ /**
+ * Get a specic registry.
+ *
+ * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
+ */
+ static PropertyManager getImplementationRegistry() {
+ return byImplementation;
+ }
+
+ /**
* @see Dumpable
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
public static void dump() {
dump(System.out);
@@ -154,7 +175,7 @@
/**
* @see Dumpable
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: HandleManager.java,v 1.6 2001/03/11 09:50:47 burton Exp $
+ * @version $Id: HandleManager.java,v 1.7 2001/03/12 06:17:29 burton Exp $
*/
public static void dump( PrintStream ps ) {
*****************************************************************
File: talon/src/java/talon/TalonException.java
CVSWEB Options: -------------------
CVSWeb: Annotate this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/TalonException.java?annotate=1.5
CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/TalonException.java?rev=1.5&content-type=text/x-cvsweb-markup
CVSWeb: Diff to previous version: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/TalonException.java.diff?r1=1.5&r2=1.4
-----------------------------------
Index: talon/src/java/talon/TalonException.java
diff -u talon/src/java/talon/TalonException.java:1.4 talon/src/java/talon/TalonException.java:1.5
--- talon/src/java/talon/TalonException.java:1.4 Sun Mar 11 15:51:20 2001
+++ talon/src/java/talon/TalonException.java Sun Mar 11 22:17:29 2001
@@ -19,7 +19,7 @@
* this Exception was created.
*
* @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
- * @version $Id: TalonException.java,v 1.4 2001/03/11 23:51:20 burton Exp $
+ * @version $Id: TalonException.java,v 1.5 2001/03/12 06:17:29 burton Exp $
*/
public class TalonException extends Exception {
@@ -34,8 +34,14 @@
}
public TalonException( Throwable reason ) {
- super( reason.getMessage() );
+
+ super( "See attached nested exeception ( " +
+ reason.getClass().getName() +
+ " ): " +
+ reason.getMessage() );
+
this.reason = reason;
+
}
public void printStackTrace() {
This archive was generated by hypermail 2b30 : Sun Mar 11 2001 - 22:17:30 PST