avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application LifecycleHelper.java
Date Sat, 12 Jan 2002 02:12:44 GMT
donaldp     02/01/11 18:12:44

  Modified:    src/java/org/apache/avalon/phoenix/components/application
                        LifecycleHelper.java
  Log:
  Any block that is declared to have a management interface is exported to system management.
  
  Revision  Changes    Path
  1.25      +36 -1     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/LifecycleHelper.java
  
  Index: LifecycleHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/LifecycleHelper.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- LifecycleHelper.java	11 Jan 2002 23:41:12 -0000	1.24
  +++ LifecycleHelper.java	12 Jan 2002 02:12:44 -0000	1.25
  @@ -38,6 +38,7 @@
   import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
   import org.apache.avalon.phoenix.metadata.BlockMetaData;
   import org.apache.avalon.phoenix.metadata.DependencyMetaData;
  +import org.apache.avalon.phoenix.metainfo.ServiceDescriptor;
   
   /**
    * This is a class to help an Application manage lifecycle of
  @@ -231,8 +232,11 @@
               entry.setState( State.STARTED );
               entry.setBlock( block );
   
  +            exportBlock( metaData, block );
  +            
  +            final Block proxy = entry.getProxy();
               final BlockEvent event =
  -                new BlockEvent( name, entry.getProxy(), metaData.getBlockInfo() );
  +                new BlockEvent( name, proxy, metaData.getBlockInfo() );
               m_listenerSupport.blockAdded( event );
           }
           catch( final Throwable t )
  @@ -302,6 +306,37 @@
   
           notice( name, STAGE_DESTROY );
           entry.setState( State.DESTROYED );
  +    }
  +
  +    /**
  +     * Export the services of block, declared to be management 
  +     * services, into management system.
  +     */
  +    private void exportBlock( final BlockMetaData metaData, 
  +                              final Block block )
  +        throws CascadingException
  +    {
  +        final ServiceDescriptor[] services = metaData.getBlockInfo().getManagement();
  +        final String name = metaData.getName();
  +        final ClassLoader classLoader = block.getClass().getClassLoader();
  +
  +        for( int i = 0; i < services.length; i++ )
  +        {
  +            final ServiceDescriptor service = services[ i ];
  +            try
  +            {
  +                final Class clazz = classLoader.loadClass( service.getName() );
  +                m_context.exportObject( name, clazz, block );
  +            }
  +            catch( final Exception e )
  +            {
  +                final String reason = e.toString();
  +                final String message =
  +                    REZ.getString( "export.error", name, service.getName(), reason );
  +                getLogger().error( message );
  +                throw new CascadingException( message, e );
  +            }
  +        }
       }
   
       /**
  
  
  

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


Mime
View raw message