CVS update: talon/src/java/talon

From: cvs@openprivacy.org
Date: Sun Feb 18 2001 - 23:47:52 PST

  • Next message: cvs@openprivacy.org: "CVS update: sierra/docs"

    Date: Sunday February 18, 19101 @ 23:47
    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-serv26172/src/java/talon

    Modified Files:
            ComponentFactory.java ComponentHandle.java
    Log Message:
    named component handle passing without any additional information... we now pull a handle from the HandleManager.

    *****************************************************************
    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.7

    CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentFactory.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/ComponentFactory.java.diff?r1=1.7&r2=1.6

    -----------------------------------

    Index: talon/src/java/talon/ComponentFactory.java
    diff -u talon/src/java/talon/ComponentFactory.java:1.6 talon/src/java/talon/ComponentFactory.java:1.7
    --- talon/src/java/talon/ComponentFactory.java:1.6 Sun Feb 11 14:02:10 2001
    +++ talon/src/java/talon/ComponentFactory.java Sun Feb 18 23:47:52 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.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 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.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         static {
     
    @@ -82,26 +82,44 @@
          * Given a ComponentHandle get a Component
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentFactory.java,v 1.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         public static Component getInstance( ComponentHandle handle )
             throws TalonException {
     
             Initializer.init();
             
    - //FIXME: only smart enough to use Singletons :(
    -
             //FIXME: if the component we fetch isn't the correct implementation of
             //the given interface... throw an Exception because the resulting object
             //won't be able to be (cast) and the application will get a RuntimeException
             //write a use case for this.
     
    +
    + //make sure this handle has an implementation. if the implementation is
    + //not set then we should try to use the HandleManager to recover.
    +
    +
    + //use the default lifetime
    + if ( handle.getLifetime() == null ) {
    + handle.setLifetime( LIFETIME_DEMAND );
    + }
    +
    + //if the implementation is null... try to pull this out of the HandleManager
    + if ( handle.getImplementation() == null && handle.getName() != null ) {
    +
    + PropertyManager props = handle.getInitProperties();
    +
    + handle = HandleManager.byName( handle.getName() );
    + handle.setInitProperties( props );
    + }
    +
    +
             
             //determine what lifetime to use
     
             String lifetime = handle.getLifetime();
             
    - if ( lifetime == null || lifetime.equals( LIFETIME_DEMAND ) ) {
    + if ( lifetime.equals( LIFETIME_DEMAND ) ) {
                 return getDemandBasedInstance( handle );
             } else if ( lifetime.equals( LIFETIME_SINGLETON ) ) {
                 return getSingletonBasedInstance( handle );
    @@ -114,7 +132,7 @@
          * 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.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         private static Component getDemandBasedInstance( ComponentHandle handle )
             throws TalonException {
    @@ -129,7 +147,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.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         private static Component getSingletonBasedInstance( ComponentHandle handle )
             throws TalonException {
    @@ -153,13 +171,13 @@
          * Perform basic instantiation on a component.
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentFactory.java,v 1.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         private static Component instantiateComponent( ComponentHandle handle )
             throws TalonException {
     
             try {
    -
    +
                 Component comp = (Component)Class.forName( handle.getImplementation() ).newInstance();
                 comp.setComponentHandle( handle );
                 comp.init();
    @@ -176,7 +194,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.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         static void putSingleton( ComponentHandle handle, Component comp ) {
             singletons.put( handle, comp );
    @@ -189,7 +207,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.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         public static Logger getLogger() {
             return ComponentFactory.logger;
    @@ -199,7 +217,7 @@
          *
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentFactory.java,v 1.6 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentFactory.java,v 1.7 2001/02/19 07:47:52 burton Exp $
          */
         public static void setLogger( Logger logger ) {
             ComponentFactory.logger = logger;

    *****************************************************************
    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.8

    CVSWeb: View this file: http://openprivacy.org/cgi-bin/cvsweb/cvsweb.cgi/talon/src/java/talon/ComponentHandle.java?rev=1.8&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.8&r2=1.7

    -----------------------------------

    Index: talon/src/java/talon/ComponentHandle.java
    diff -u talon/src/java/talon/ComponentHandle.java:1.7 talon/src/java/talon/ComponentHandle.java:1.8
    --- talon/src/java/talon/ComponentHandle.java:1.7 Sun Feb 11 14:02:10 2001
    +++ talon/src/java/talon/ComponentHandle.java Sun Feb 18 23:47:52 2001
    @@ -18,7 +18,7 @@
      * Object which is used to find components within the system.
      *
      * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
      */
     public class ComponentHandle {
         
    @@ -50,7 +50,7 @@
          * Create a basic ComponentHandle
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public ComponentHandle() {}
          
    @@ -59,7 +59,7 @@
          * pulled from the Talon properties.
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public ComponentHandle( String _interface ) {
     
    @@ -71,7 +71,7 @@
          * The interface and classname.
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public ComponentHandle( String _interface,
                                 String _implementation ) {
    @@ -86,7 +86,7 @@
          * The interface and classname. You may specify a PropertyManager here.
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public ComponentHandle( String _interface,
                                 String _classname,
    @@ -101,7 +101,7 @@
          * Also set the name.
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public ComponentHandle( String name,
                                 String _interface,
    @@ -165,7 +165,7 @@
     
          /**
           * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
           */
         public String getLifetime() {
             return this._lifetime;
    @@ -175,7 +175,7 @@
     
         /**
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public ComponentHandle setLifetime( String _lifetime ) {
             this._lifetime = _lifetime;
    @@ -184,7 +184,7 @@
     
         /**
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public String getDescription() {
             return this._description;
    @@ -192,7 +192,7 @@
         
         /**
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public ComponentHandle setDescription( String _description ) {
             this._description = _description;
    @@ -202,7 +202,7 @@
         /**
          * @see Component
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public PropertyManager getInitProperties() {
             return this.initProperties;
    @@ -217,10 +217,31 @@
          * Dump Handle information..
          *
          * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    - * @version $Id: ComponentHandle.java,v 1.7 2001/02/11 22:02:10 burton Exp $
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
          */
         public String toString() {
             return this.getName() + ":" + this.getInterface() + " -> " + this.getImplementation();
    + }
    +
    + /**
    + * Return a cloned ComponentHandle.
    + *
    + * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</a>
    + * @version $Id: ComponentHandle.java,v 1.8 2001/02/19 07:47:52 burton Exp $
    + */
    + public Object clone() {
    +
    + ComponentHandle handle = new ComponentHandle();
    +
    + handle.setName( this.getName() );
    + handle.setDescription( this.getDescription() );
    + handle.setLifetime( this.getLifetime() );
    + handle.setInitProperties( this.getInitProperties() );
    + handle.setInterface( this.getInterface() );
    + handle.setImplementation( this.getImplementation() );
    +
    + return (Object)handle;
    +
         }
         
     }



    This archive was generated by hypermail 2b30 : Sun Feb 18 2001 - 23:47:53 PST