avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl StandardBlock.java
Date Mon, 09 Jun 2003 01:05:34 GMT
mcconnell    2003/06/08 18:05:34

  Modified:    merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        StandardBlock.java
  Log:
  Enhanced handling of virtual service construction.
  
  Revision  Changes    Path
  1.9       +62 -44    avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java
  
  Index: StandardBlock.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/StandardBlock.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StandardBlock.java	29 May 2003 21:01:38 -0000	1.8
  +++ StandardBlock.java	9 Jun 2003 01:05:34 -0000	1.9
  @@ -164,6 +164,11 @@
       */
       private ThreadGroup m_threads;
   
  +   /**
  +    * The array of interfaces classes that the container represents.
  +    */
  +    private Class[] m_classes;
  +
       //=====================================================================
       // Contextualizable
       //=====================================================================
  @@ -349,6 +354,52 @@
       }
   
      /**
  +    * Return a virtual services matching the supplied interface class.
  +    * @param clazz an interface class
  +    * @return the virtual service directive
  +    */
  +    public VirtualService getVirtualService( Class clazz )
  +    {
  +        ContainmentProfile profile = 
  +          (ContainmentProfile) m_applianceContext.getProfile();
  +        return profile.getVirtualService( clazz );
  +    }
  +
  +    private Object getVirtualService( Object source ) throws Exception
  +    {
  +        return getVirtualService( source, null );
  +    }
  +
  +    private Object getVirtualService( Object source, String ref ) throws Exception
  +    {
  +        getLogger().debug( "building virtual service proxy (VSP)" );
  +        Object instance = super.resolve( source, ref );
  +        Object proxy = Proxy.newProxyInstance( 
  +          m_engine, 
  +          getInterfaceClasses(), 
  +          new BlockInvocationHandler( this, instance ) );
  +        return proxy;
  +    }
  +
  +    private Class[] getInterfaceClasses() throws Exception
  +    {
  +        if( m_classes == null )
  +        {
  +            List list = new ArrayList();
  +            ServiceDescriptor[] services = getServices();
  +            for( int i=0; i<services.length; i++ )
  +            {
  +                final ServiceDescriptor service = services[i];
  +                final String classname = service.getReference().getClassname();
  +                Class clazz = m_engine.loadClass( classname );
  +                list.add( clazz );
  +            }
  +            m_classes = (Class[]) list.toArray( new Class[0] );
  +        }
  +        return m_classes;
  +    }
  +
  +   /**
       * Assemble the appliance.  The implementation extends the default
       * appliance behavior by instantiating the container it is managing,
       * and applying assembly to the container instance. This results in
  @@ -712,6 +763,16 @@
                   }
               }
           }
  +        try
  +        {
  +            m_threads.destroy();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error =
  +              "Unexpected error while attempting to destroy thread group in: " + this;
  +            getLogger().warn( error );
  +        }
       }
   
      /**
  @@ -733,49 +794,6 @@
       }
   
      /**
  -    * Return a virtual services matching the supplied interface class.
  -    * @param clazz an interface class
  -    * @return the virtual service directive
  -    */
  -    public VirtualService getVirtualService( Class clazz )
  -    {
  -        String classname = clazz.getName();
  -        ContainmentProfile profile = 
  -          (ContainmentProfile) m_applianceContext.getProfile();
  -        return profile.getVirtualService( clazz );
  -    }
  -
  -    private Object getVirtualService( Object source ) throws Exception
  -    {
  -        return getVirtualService( source, null );
  -    }
  -
  -    private Object getVirtualService( Object source, String ref ) throws Exception
  -    {
  -        getLogger().debug( "building virtual service proxy (VSP)" );
  -        Object instance = super.resolve( source, ref );
  -        Object proxy = Proxy.newProxyInstance( 
  -          m_engine, 
  -          getInterfaceClasses(), 
  -          new BlockInvocationHandler( this, instance ) );
  -        return proxy;
  -    }
  -
  -    private Class[] getInterfaceClasses() throws Exception
  -    {
  -        List list = new ArrayList();
  -        ServiceDescriptor[] services = getServices();
  -        for( int i=0; i<services.length; i++ )
  -        {
  -            final ServiceDescriptor service = services[i];
  -            final String classname = service.getReference().getClassname();
  -            Class clazz = m_engine.loadClass( classname );
  -            list.add( clazz );
  -        }
  -        return (Class[]) list.toArray( new Class[0] );
  -    }
  -
  -   /**
       * Internal utility class that enables the execution a block as a 
       * thread against which a context classloader can be assigned.
       */
  @@ -867,7 +885,7 @@
                   }
                   catch( Throwable wakeup )
                   {
  -                        // return
  +                    // return
                   }
               }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message