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 BlockEntry.java LifecycleHelper.java
Date Tue, 14 May 2002 12:47:25 GMT
donaldp     02/05/14 05:47:25

  Modified:    src/java/org/apache/avalon/phoenix/components/application
                        BlockEntry.java LifecycleHelper.java
  Log:
  Reworked LifecycleHelper/BlockEntry such that the Block objects are no longer required to
implement marker interface Block. (However other parts of Avalon still demand it).
  
  This also means you need to issue errrors when incompatabilities between applications exist
(ie Block A is composable but some dependencies are not instances of Component)
  
  Revision  Changes    Path
  1.9       +1 -12     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockEntry.java
  
  Index: BlockEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/BlockEntry.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BlockEntry.java	14 May 2002 12:02:49 -0000	1.8
  +++ BlockEntry.java	14 May 2002 12:47:25 -0000	1.9
  @@ -35,16 +35,6 @@
           return m_blockMetaData;
       }
   
  -    public synchronized Block getBlock()
  -    {
  -        return (Block)getObject();
  -    }
  -
  -    public synchronized void setBlock( final Block block )
  -    {
  -        setObject( block );
  -    }
  -
       public synchronized void setObject( final Object object )
       {
           invalidate();
  @@ -53,10 +43,9 @@
           {
               final BlockInfo blockInfo = getMetaData().getBlockInfo();
               final Class[] interfaces = getServiceClasses( object, blockInfo.getServices()
);
  -
               m_invocationHandler = new BlockInvocationHandler( object, interfaces );
  -            super.setObject( object );
           }
  +        super.setObject( object );
       }
   
       public synchronized Block getProxy()
  
  
  
  1.39      +28 -13    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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- LifecycleHelper.java	14 May 2002 12:02:49 -0000	1.38
  +++ LifecycleHelper.java	14 May 2002 12:47:25 -0000	1.39
  @@ -13,6 +13,7 @@
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
  +import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.DefaultComponentManager;
  @@ -32,7 +33,6 @@
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.phoenix.ApplicationEvent;
   import org.apache.avalon.phoenix.ApplicationListener;
  -import org.apache.avalon.phoenix.Block;
   import org.apache.avalon.phoenix.BlockContext;
   import org.apache.avalon.phoenix.BlockEvent;
   import org.apache.avalon.phoenix.BlockListener;
  @@ -211,7 +211,7 @@
               //Creation stage
               stage = STAGE_CREATE;
               notice( name, stage );
  -            final Block block = createBlock( metaData );
  +            final Object block = createBlock( metaData );
   
               //LogEnabled stage
               stage = STAGE_LOGGER;
  @@ -278,11 +278,11 @@
               }
   
               entry.setState( State.STARTED );
  -            entry.setBlock( block );
  +            entry.setObject( block );
   
               exportBlock( metaData, block );
   
  -            final Block proxy = entry.getProxy();
  +            final Object proxy = entry.getProxy();
               final BlockEvent event =
                   new BlockEvent( name, proxy, metaData.getBlockInfo() );
               m_blockListenerSupport.blockAdded( event );
  @@ -294,7 +294,9 @@
           }
       }
   
  -    private void setupLogging( final String name, final Block block, int stage )
  +    private void setupLogging( final String name,
  +                               final Object block,
  +                               int stage )
           throws Exception
       {
           if( block instanceof Loggable )
  @@ -328,7 +330,7 @@
               new BlockEvent( name, entry.getProxy(), metaData.getBlockInfo() );
           m_blockListenerSupport.blockRemoved( event );
   
  -        final Block block = entry.getBlock();
  +        final Object block = entry.getObject();
   
           //Remove block from Management system
           unexportBlock( metaData, block );
  @@ -380,7 +382,7 @@
        * services, into management system.
        */
       private void exportBlock( final BlockMetaData metaData,
  -                              final Block block )
  +                              final Object block )
           throws CascadingException
       {
           final ServiceDescriptor[] services = metaData.getBlockInfo().getManagementAccessPoints();
  @@ -411,7 +413,7 @@
        * services, into management system.
        */
       private void unexportBlock( final BlockMetaData metaData,
  -                                final Block block )
  +                                final Object block )
       {
           final ServiceDescriptor[] services = metaData.getBlockInfo().getManagementAccessPoints();
           final String name = metaData.getName();
  @@ -443,12 +445,12 @@
        * @return the newly created Block object
        * @throws Exception if an error occurs
        */
  -    private Block createBlock( final BlockMetaData metaData )
  +    private Object createBlock( final BlockMetaData metaData )
           throws Exception
       {
           final ClassLoader classLoader = m_context.getClassLoader();
           final Class clazz = classLoader.loadClass( metaData.getClassname() );
  -        return (Block)clazz.newInstance();
  +        return clazz.newInstance();
       }
   
       /**
  @@ -501,6 +503,7 @@
        * @return the created ComponentManager
        */
       private ComponentManager createComponentManager( final BlockMetaData metaData )
  +        throws Exception
       {
           final DefaultComponentManager componentManager = new DefaultComponentManager();
           final DependencyMetaData[] roles = metaData.getDependencies();
  @@ -508,8 +511,20 @@
           for( int i = 0; i < roles.length; i++ )
           {
               final DependencyMetaData role = roles[ i ];
  -            final Block dependency = m_application.getBlock( role.getName() );
  -            componentManager.put( role.getRole(), dependency );
  +            final Object dependency = m_application.getBlock( role.getName() );
  +            if( dependency instanceof Component )
  +            {
  +                componentManager.put( role.getRole(), (Component)dependency );
  +            }
  +            else
  +            {
  +                final String message =
  +                    REZ.getString( "lifecycle.nota-component.error",
  +                                   metaData.getName(),
  +                                   role.getRole(),
  +                                   role.getName() );
  +                throw new Exception( message );
  +            }
           }
   
           return componentManager;
  @@ -523,7 +538,7 @@
           for( int i = 0; i < roles.length; i++ )
           {
               final DependencyMetaData role = roles[ i ];
  -            final Block dependency = m_application.getBlock( role.getName() );
  +            final Object dependency = m_application.getBlock( role.getName() );
               manager.put( role.getRole(), dependency );
           }
   
  
  
  

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