You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2002/09/24 22:39:53 UTC

cvs commit: jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component ComponentHandler.java DefaultComponentFactory.java DefaultComponentHandler.java ExcaliburComponentManager.java ExcaliburComponentSelector.java PoolableComponentHandler.java ThreadSafeComponentHandler.java

bloritsch    2002/09/24 13:39:53

  Modified:    component build.xml default.properties
               component/src/java/org/apache/avalon/excalibur/component
                        ComponentHandler.java DefaultComponentFactory.java
                        DefaultComponentHandler.java
                        ExcaliburComponentManager.java
                        ExcaliburComponentSelector.java
                        PoolableComponentHandler.java
                        ThreadSafeComponentHandler.java
  Log:
  update component to use proxies
  
  Revision  Changes    Path
  1.26      +2 -0      jakarta-avalon-excalibur/component/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/build.xml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- build.xml	21 Aug 2002 06:03:15 -0000	1.25
  +++ build.xml	24 Sep 2002 20:39:52 -0000	1.26
  @@ -16,6 +16,7 @@
           <pathelement location="${logkit.jar}"/>
           <pathelement location="${avalon-framework.jar}"/>
           <pathelement location="${excalibur-collections.jar}"/>
  +        <pathelement location="${excalibur-container.jar}"/>
           <pathelement location="${excalibur-logger.jar}"/>
           <pathelement location="${excalibur-instrument.jar}"/>
           <pathelement location="${excalibur-instrument-manager.jar}"/>
  @@ -75,6 +76,7 @@
       <target name="dependencies" depends="dependencies.optional" description="Check dependencies" unless="skip.dependencies">
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkCommon"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkLogkit"/>
  +        <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkContainer"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkFramework"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkInstrument"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkInstrumentManager"/>
  
  
  
  1.14      +5 -0      jakarta-avalon-excalibur/component/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/default.properties,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- default.properties	6 Sep 2002 06:48:22 -0000	1.13
  +++ default.properties	24 Sep 2002 20:39:52 -0000	1.14
  @@ -38,6 +38,11 @@
   excalibur-collections.lib=${excalibur-collections.home}
   excalibur-collections.jar=${excalibur-collections.lib}/excalibur-collections-1.0.jar
   
  +# ----- Excalibur Container -----
  +excalibur-container.home=${basedir}/../container
  +excalibur-container.lib=${excalibur-container.home}/build/lib
  +excalibur-container.jar=${excalibur-container.lib}/excalibur-container-1.0.jar
  +
   # ----- Excalibur logger, version 1.0 or later -----
   excalibur-logger.home=${basedir}/../logger/dist
   excalibur-logger.lib=${excalibur-logger.home}
  
  
  
  1.7       +11 -7     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ComponentHandler.java
  
  Index: ComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ComponentHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ComponentHandler.java	20 Aug 2002 10:32:10 -0000	1.6
  +++ ComponentHandler.java	24 Sep 2002 20:39:53 -0000	1.7
  @@ -55,6 +55,7 @@
       /**
        * Looks up and returns a component handler for a given component class.
        *
  +     * @param role           The role name of the component.
        * @param componentClass Class of the component for which the handle is
        *                       being requested.
        * @param configuration The configuration for this component.
  @@ -63,15 +64,14 @@
        * @param context The current context object.
        * @param roleManager The current RoleManager.
        * @param loggerManager The current LogKitLoggerManager.
  -     * @param instrumentManager The current InstrumentManager.
  -     * @param instrumentableName The name of the handler.
        *
        * @throws Exception If there were any problems obtaining a ComponentHandler
        *
        * @deprecated This method has been deprecated in favor of the version below which
        *             handles instrumentation.
        */
  -    public static ComponentHandler getComponentHandler( final Class componentClass,
  +    public static ComponentHandler getComponentHandler( final String role,
  +                                                        final Class componentClass,
                                                           final Configuration configuration,
                                                           final ComponentManager componentManager,
                                                           final Context context,
  @@ -79,7 +79,8 @@
                                                           final LogkitLoggerManager loggerManager )
           throws Exception
       {
  -        return ComponentHandler.getComponentHandler( componentClass,
  +        return ComponentHandler.getComponentHandler( role,
  +                                                     componentClass,
                                                        configuration,
                                                        componentManager,
                                                        context,
  @@ -92,6 +93,7 @@
       /**
        * Looks up and returns a component handler for a given component class.
        *
  +     * @param role           The role name of the component.
        * @param componentClass Class of the component for which the handle is
        *                       being requested.
        * @param configuration The configuration for this component.
  @@ -106,7 +108,8 @@
        *
        * @throws Exception If there were any problems obtaining a ComponentHandler
        */
  -    public static ComponentHandler getComponentHandler( final Class componentClass,
  +    public static ComponentHandler getComponentHandler( final String role,
  +                                                        final Class componentClass,
                                                           final Configuration configuration,
                                                           final ComponentManager componentManager,
                                                           final Context context,
  @@ -142,7 +145,8 @@
   
           // Create the factory to use to create the instances of the Component.
           DefaultComponentFactory factory =
  -            new DefaultComponentFactory( componentClass,
  +            new DefaultComponentFactory( role,
  +                                         componentClass,
                                            configuration,
                                            componentManager,
                                            context,
  
  
  
  1.9       +46 -13    jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java
  
  Index: DefaultComponentFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultComponentFactory.java	18 Aug 2002 14:40:22 -0000	1.8
  +++ DefaultComponentFactory.java	24 Sep 2002 20:39:53 -0000	1.9
  @@ -37,6 +37,7 @@
   import org.apache.excalibur.instrument.Instrumentable;
   import org.apache.excalibur.instrument.InstrumentManageable;
   import org.apache.excalibur.instrument.InstrumentManager;
  +import org.apache.excalibur.container.legacy.ComponentProxyGenerator;
   
   /**
    * Factory for Avalon components.
  @@ -88,6 +89,9 @@
       /** Instrumentable Name assigned to objects created by this factory. */
       private String m_instrumentableName;
   
  +    private ComponentProxyGenerator m_proxyGenerator;
  +    private String m_role;
  +
       /*---------------------------------------------------------------
        * Constructors
        *-------------------------------------------------------------*/
  @@ -103,14 +107,16 @@
        * @deprecated This constructor has been deprecated in favor of the version below which
        *             handles instrumentation.
        */
  -    public DefaultComponentFactory( final Class componentClass,
  +    public DefaultComponentFactory( final String role,
  +                                    final Class componentClass,
                                       final Configuration configuration,
                                       final ComponentManager componentManager,
                                       final Context context,
                                       final RoleManager roles,
                                       final LogkitLoggerManager loggerManager )
       {
  -        this( componentClass,
  +        this( role,
  +              componentClass,
                 configuration,
                 componentManager,
                 context,
  @@ -134,7 +140,8 @@
        * @param instrumentableName The instrument name to assign the component if
        *                           it is Instrumentable.
        */
  -    public DefaultComponentFactory( final Class componentClass,
  +    public DefaultComponentFactory( final String role,
  +                                    final Class componentClass,
                                       final Configuration configuration,
                                       final ComponentManager componentManager,
                                       final Context context,
  @@ -144,6 +151,7 @@
                                       final String instrumentableName )
   
       {
  +        m_role = role;
           m_componentClass = componentClass;
           m_configuration = configuration;
           m_componentManager = componentManager;
  @@ -152,6 +160,7 @@
           m_loggerManager = loggerManager;
           m_instrumentManager = instrumentManager;
           m_instrumentableName = instrumentableName;
  +        m_proxyGenerator = new ComponentProxyGenerator( m_componentClass.getClassLoader() );
       }
       
       /*---------------------------------------------------------------
  @@ -293,7 +302,19 @@
   
           m_components.put( component, proxy );
   
  -        return component;
  +        Component returnableComponent;
  +
  +        if ( ! ( component instanceof Component ) )
  +        {
  +           returnableComponent = m_proxyGenerator.getProxy( m_role , component );
  +           m_components.put( returnableComponent, component );
  +        }
  +        else
  +        {
  +           returnableComponent = (Component) component;
  +        }
  +
  +        return returnableComponent;
       }
   
       public final Class getCreatedClass()
  @@ -304,35 +325,47 @@
       public final void decommission( final Object component )
           throws Exception
       {
  +        Object check = m_components.get( component );
  +        Object decommission;
  +        if ( check instanceof ServiceManager || check instanceof ComponentManager || null == check )
  +        {
  +            decommission = component;
  +        }
  +        else
  +        {
  +            decommission = check;
  +            m_components.remove( component );
  +        }
  +
           if( getLogger().isDebugEnabled() )
           {
               getLogger().debug( "ComponentFactory decommissioning instance of " +
                                  m_componentClass.getName() + "." );
           }
   
  -        if( component instanceof Startable )
  +        if( decommission instanceof Startable )
           {
  -            ( (Startable)component ).stop();
  +            ( (Startable)decommission ).stop();
           }
   
           if( component instanceof Disposable )
           {
  -            ( (Disposable)component ).dispose();
  +            ( (Disposable)decommission ).dispose();
           }
   
  -        if( component instanceof Composable )
  +        if( decommission instanceof Composable )
           {
               // ensure any components looked up by this Composable are properly
               // released, if they haven't been released already
  -            ( (ComponentManagerProxy)m_components.get( component ) ).releaseAll();
  +            ( (ComponentManagerProxy)m_components.get( decommission ) ).releaseAll();
           }
   
  -        if( component instanceof Serviceable )
  +        if( decommission instanceof Serviceable )
           {
  -            ( (ServiceManagerProxy)m_components.get( component ) ).releaseAll();
  +            ( (ServiceManagerProxy)m_components.get( decommission ) ).releaseAll();
           }
   
  -        m_components.remove( component );
  +        m_components.remove( decommission );
       }
   
       /*---------------------------------------------------------------
  
  
  
  1.4       +4 -3      jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentHandler.java
  
  Index: DefaultComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultComponentHandler.java	21 Aug 2002 05:04:36 -0000	1.3
  +++ DefaultComponentHandler.java	24 Sep 2002 20:39:53 -0000	1.4
  @@ -51,7 +51,8 @@
        *
        * @throws Exception If there are any problems creating the handler.
        */
  -    protected DefaultComponentHandler( final Class componentClass,
  +    protected DefaultComponentHandler( final String role,
  +                                       final Class componentClass,
                                          final Configuration config,
                                          final ComponentManager manager,
                                          final Context context,
  @@ -60,7 +61,7 @@
           throws Exception
       {
           this(
  -            new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit ),
  +            new DefaultComponentFactory(role, componentClass, config, manager, context, roles, logkit ),
               config );
       }
   
  
  
  
  1.17      +9 -5      jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java
  
  Index: ExcaliburComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ExcaliburComponentManager.java	23 Aug 2002 02:45:50 -0000	1.16
  +++ ExcaliburComponentManager.java	24 Sep 2002 20:39:53 -0000	1.17
  @@ -215,7 +215,8 @@
   
                           final Configuration configuration = new DefaultConfiguration( "", "-" );
   
  -                        handler = getComponentHandler( componentClass,
  +                        handler = getComponentHandler( role,
  +                                                       componentClass,
                                                          configuration,
                                                          m_context,
                                                          m_roles,
  @@ -765,7 +766,8 @@
        *
        * @throws Exception If there were any problems obtaining a ComponentHandler
        */
  -    protected ComponentHandler getComponentHandler( final Class componentClass,
  +    protected ComponentHandler getComponentHandler( final String role,
  +                                                    final Class componentClass,
                                                       final Configuration configuration,
                                                       final Context context,
                                                       final RoleManager roleManager,
  @@ -778,7 +780,8 @@
           String instrumentableName =
               configuration.getAttribute( "instrumentable", configuration.getName() );
           
  -        return ComponentHandler.getComponentHandler( componentClass,
  +        return ComponentHandler.getComponentHandler( role,
  +                                                     componentClass,
                                                        configuration,
                                                        this,
                                                        context,
  @@ -813,7 +816,8 @@
                   getLogger().debug( "Attempting to get Handler for role [" + role + "]" );
               }
   
  -            final ComponentHandler handler = getComponentHandler( component,
  +            final ComponentHandler handler = getComponentHandler( role,
  +                                                                  component,
                                                                     configuration,
                                                                     m_context,
                                                                     m_roles,
  
  
  
  1.15      +7 -4      jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java
  
  Index: ExcaliburComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ExcaliburComponentSelector.java	22 Aug 2002 22:56:10 -0000	1.14
  +++ ExcaliburComponentSelector.java	24 Sep 2002 20:39:53 -0000	1.15
  @@ -625,7 +625,8 @@
        *
        * @throws Exception If there were any problems obtaining a ComponentHandler
        */
  -    protected ComponentHandler getComponentHandler( final Class componentClass,
  +    protected ComponentHandler getComponentHandler( final String role,
  +                                                    final Class componentClass,
                                                       final Configuration configuration,
                                                       final ComponentManager componentManager,
                                                       final Context context,
  @@ -640,7 +641,8 @@
               + configuration.getAttribute( "instrumentable",
                   configuration.getAttribute( "name", configuration.getName() ) );
   
  -        return ComponentHandler.getComponentHandler( componentClass,
  +        return ComponentHandler.getComponentHandler( role,
  +                                                     componentClass,
                                                        configuration,
                                                        componentManager,
                                                        context,
  @@ -678,7 +680,8 @@
   
           try
           {
  -            final ComponentHandler handler = getComponentHandler( component,
  +            final ComponentHandler handler = getComponentHandler( m_rolename,
  +                                                                  component,
                                                                     configuration,
                                                                     m_componentManager,
                                                                     m_context,
  
  
  
  1.6       +4 -3      jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java
  
  Index: PoolableComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PoolableComponentHandler.java	6 Aug 2002 16:28:38 -0000	1.5
  +++ PoolableComponentHandler.java	24 Sep 2002 20:39:53 -0000	1.6
  @@ -105,7 +105,8 @@
        * whether a Component is ThreadSafe, Poolable, or SingleThreaded.
        * It falls back to SingleThreaded if not specified.
        */
  -    protected PoolableComponentHandler( final Class componentClass,
  +    protected PoolableComponentHandler( final String role,
  +                                        final Class componentClass,
                                           final Configuration config,
                                           final ComponentManager manager,
                                           final Context context,
  @@ -114,7 +115,7 @@
           throws Exception
       {
           this(
  -            new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit ),
  +            new DefaultComponentFactory( role, componentClass, config, manager, context, roles, logkit ),
               config );
       }
   
  
  
  
  1.5       +4 -3      jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ThreadSafeComponentHandler.java
  
  Index: ThreadSafeComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ThreadSafeComponentHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ThreadSafeComponentHandler.java	6 Aug 2002 16:28:38 -0000	1.4
  +++ ThreadSafeComponentHandler.java	24 Sep 2002 20:39:53 -0000	1.5
  @@ -37,7 +37,8 @@
        * whether a Component is ThreadSafe, Poolable, or SingleThreaded.
        * It falls back to SingleThreaded if not specified.
        */
  -    protected ThreadSafeComponentHandler( final Class componentClass,
  +    protected ThreadSafeComponentHandler( final String role,
  +                                          final Class componentClass,
                                             final Configuration config,
                                             final ComponentManager manager,
                                             final Context context,
  @@ -46,7 +47,7 @@
           throws Exception
       {
           this(
  -            new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit ),
  +            new DefaultComponentFactory( role, componentClass, config, manager, context, roles, logkit ),
               config );
       }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>