avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/rmification RMIfication.java RMIficationListener.java
Date Fri, 11 Jan 2002 14:03:18 GMT
colus       02/01/11 06:03:18

  Modified:    src/java/org/apache/avalon/cornerstone/blocks/rmification
                        DefaultRMIfication.java
               src/java/org/apache/avalon/cornerstone/services/rmification
                        RMIfication.java RMIficationListener.java
  Log:
  Fix RMification's publish bug.
  
  Revision  Changes    Path
  1.2       +7 -1      jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/rmification/DefaultRMIfication.java
  
  Index: DefaultRMIfication.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/rmification/DefaultRMIfication.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultRMIfication.java	11 Jan 2002 05:58:42 -0000	1.1
  +++ DefaultRMIfication.java	11 Jan 2002 14:03:18 -0000	1.2
  @@ -26,10 +26,11 @@
   import org.apache.avalon.cornerstone.services.rmification.RMIfication;
   
   /**
  - * FIXME: INPROGRESS
  + * FIXME: INPROGRESS and NOT TESTED
    * Default implementation of <code>RMIfication</code>.
    *
    * @author <a href="mailto:colus@apache.org">Eung-ju Park</a>
  + * @version $Revision: 1.2 $
    */
   public class DefaultRMIfication
       extends AbstractLogEnabled
  @@ -51,6 +52,7 @@
           m_remoteObjects = new HashMap();
   
           m_registry = LocateRegistry.createRegistry( m_port );
  +        getLogger().debug( "RMI registry created on port " + m_port );
       }
   
       public void dispose()
  @@ -71,6 +73,8 @@
   
               m_remoteObjects.put( publicationName, remote );
           }
  +
  +        getLogger().debug( "Published " + publicationName );
       }
   
       public void unpublish( final String publicationName )
  @@ -85,5 +89,7 @@
   
               m_remoteObjects.remove( publicationName );
           }
  +
  +        getLogger().debug( "Unpublished " + publicationName );
       }
   }
  
  
  
  1.2       +2 -1      jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/rmification/RMIfication.java
  
  Index: RMIfication.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/rmification/RMIfication.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RMIfication.java	11 Jan 2002 05:58:42 -0000	1.1
  +++ RMIfication.java	11 Jan 2002 14:03:18 -0000	1.2
  @@ -13,10 +13,11 @@
   import java.rmi.RemoteException;
   
   /**
  - * FIXME: INPROGRESS
  + * FIXME: INPROGRESS and NOT TESTED
    * This service provides a way to publish an <code>Remote<code> object via
RMI.
    *
    * @author <a href="mailto:colus@apache.org">Eung-ju Park</a>
  + * @version $Revision: 1.2 $
    */
   public interface RMIfication
   {
  
  
  
  1.2       +38 -29    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/rmification/RMIficationListener.java
  
  Index: RMIficationListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/rmification/RMIficationListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RMIficationListener.java	11 Jan 2002 06:07:50 -0000	1.1
  +++ RMIficationListener.java	11 Jan 2002 14:03:18 -0000	1.2
  @@ -8,6 +8,7 @@
   package org.apache.avalon.cornerstone.services.rmification;
   
   import java.rmi.Remote;
  +import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
  @@ -21,54 +22,60 @@
   import org.apache.avalon.phoenix.BlockListener;
   
   /**
  - * FIXME: INPROGRESS
  + * FIXME: INPROGRESS and NOT TESTED
    *
    * @author <a href="mailto:colus@isoft.co.kr">Eung-ju Park</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class RMIficationListener
  -    implements org.apache.avalon.framework.configuration.Configurable, BlockListener
  +    implements Configurable, BlockListener
   {
       private String m_publisherName;
       private RMIfication m_publisher;
  -    private java.util.Map m_publications;
  -    private java.util.List m_queue;
  +    private Map m_publications;
  +    private List m_queue;
   
  -    public void configure( final org.apache.avalon.framework.configuration.Configuration
configuration )
  -        throws org.apache.avalon.framework.configuration.ConfigurationException
  +    public void configure( final Configuration configuration )
  +        throws ConfigurationException
       {
           m_publisherName = configuration.getChild( "publisher" ).getValue( "rmification"
);
   
  -        m_publications = new java.util.HashMap();
  -        final org.apache.avalon.framework.configuration.Configuration[] confs = configuration.getChildren(
"publish" );
  +        m_publications = new HashMap();
  +        final Configuration[] confs = configuration.getChildren( "publish" );
           for ( int i = 0; i < confs.length; i++ )
           {
  -            final org.apache.avalon.framework.configuration.Configuration conf = confs[
i ];
  +            final Configuration conf = confs[ i ];
   
  -            final String blockName = conf.getAttribute( "remote" );
  +            final String blockName = conf.getAttribute( "block" );
               final String name = conf.getAttribute( "name", blockName );
   
               m_publications.put( name, blockName );
           }
  +
  +        m_queue = new ArrayList();
       }
   
  -    public void blockAdded( final org.apache.avalon.phoenix.BlockEvent event )
  +    public void blockAdded( final BlockEvent event )
       {
  +        System.out.println( "Block " + event.getName() + " added" );
  +
           if ( m_publisherName.equals( event.getName() ) )
           {
  +            System.out.println( "Found publisher" );
  +
               m_publisher = (RMIfication)event.getBlock();
               for ( int i = 0; i < m_queue.size(); i++ )
               {
  -                final org.apache.avalon.phoenix.BlockEvent queued = (org.apache.avalon.phoenix.BlockEvent)m_queue.get(
i );
  +                final BlockEvent queued = (BlockEvent)m_queue.get( i );
                   publishBlock( event );
               }
               m_queue.clear();
               m_queue = null;
           }
   
  -        if ( m_publications.containsKey( event.getName() ) )
  +        if ( m_publications.containsValue( event.getName() ) )
           {
  -            if ( event.getBlock() instanceof java.rmi.Remote )
  +            if ( event.getBlock() instanceof Remote )
               {
                   publishBlock( event );
               }
  @@ -79,9 +86,11 @@
           }
       }
   
  -    public void blockRemoved( final org.apache.avalon.phoenix.BlockEvent event )
  +    public void blockRemoved( final BlockEvent event )
       {
  -        if ( event.getBlock() instanceof java.rmi.Remote )
  +        System.out.println( "Block " + event.getName() + " added" );
  +
  +        if ( event.getBlock() instanceof Remote )
           {
               unpublishBlock( event );
           }
  @@ -92,45 +101,45 @@
           return null != m_publisher;
       }
   
  -    private void publishBlock( final org.apache.avalon.phoenix.BlockEvent event )
  +    private void publishBlock( final BlockEvent event )
       {
  -        if ( !isPublisherReady() )
  +        if ( ! isPublisherReady() )
           {
               m_queue.add( event );
               return;
           }
   
  -        final org.apache.avalon.phoenix.Block block = event.getBlock();
  +        final Block block = event.getBlock();
           final String blockName = event.getName();
   
  -        final java.util.Iterator entries = m_publications.entrySet().iterator();
  +        final Iterator entries = m_publications.entrySet().iterator();
           while ( entries.hasNext() )
           {
  -            final java.util.Map.Entry entry = (java.util.Map.Entry)entries.next();
  +            final Map.Entry entry = (Map.Entry)entries.next();
   
               if ( entry.getValue().equals( blockName ) )
               {
                   try
                   {
  -                    m_publisher.publish( (java.rmi.Remote)block, (String)entry.getKey()
);
  +                    m_publisher.publish( (Remote)block, (String)entry.getKey() );
                   }
                   catch ( final Exception e )
                   {
  -                    throw new org.apache.avalon.framework.CascadingRuntimeException( "",
e );
  +                    throw new CascadingRuntimeException( "Unable to publish " + entry.getKey(),
e );
                   }
               }
           }
       }
   
  -    private void unpublishBlock( final org.apache.avalon.phoenix.BlockEvent event )
  +    private void unpublishBlock( final BlockEvent event )
       {
  -        final org.apache.avalon.phoenix.Block block = event.getBlock();
  +        final Block block = event.getBlock();
           final String blockName = event.getName();
   
  -        final java.util.Iterator entries = m_publications.entrySet().iterator();
  +        final Iterator entries = m_publications.entrySet().iterator();
           while ( entries.hasNext() )
           {
  -            final java.util.Map.Entry entry = (java.util.Map.Entry)entries.next();
  +            final Map.Entry entry = (Map.Entry)entries.next();
   
               if ( entry.getValue().equals( blockName ) )
               {
  @@ -140,7 +149,7 @@
                   }
                   catch ( final Exception e )
                   {
  -                    throw new org.apache.avalon.framework.CascadingRuntimeException( "",
e );
  +                    throw new CascadingRuntimeException( "Fail to unpublish " + entry.getKey(),
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