donaldp     2002/09/20 19:58:52

  Modified:    src/java/org/apache/avalon/cornerstone/blocks/rmification
                        DefaultRMIfication.java
  Log:
  Allow users to reuse an existing RMI registry if present
  
  Submitted By: "Marc Tremblay" <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.9       +23 -7     
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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultRMIfication.java   18 May 2002 13:30:09 -0000      1.8
  +++ DefaultRMIfication.java   21 Sep 2002 02:58:52 -0000      1.9
  @@ -38,6 +38,9 @@
       extends AbstractLogEnabled
       implements Configurable, Initializable, Disposable, RMIfication
   {
  +    private static final boolean DEFAULT_CREATE_REGISTRY = true;
  +
  +    private boolean m_createRegistry;
       private int m_port;
       private Registry m_registry;
       private Map m_remotes;
  @@ -45,6 +48,7 @@
       public void configure( final Configuration configuration )
           throws ConfigurationException
       {
  +        m_createRegistry = configuration.getChild( "createRegistry", true 
).getValueAsBoolean( DEFAULT_CREATE_REGISTRY );
           m_port = configuration.getChild( "port", true ).getValueAsInteger( 
Registry.REGISTRY_PORT );
       }
   
  @@ -53,18 +57,30 @@
       {
           m_remotes = new HashMap();
   
  -        m_registry = LocateRegistry.createRegistry( m_port );
  -        if( getLogger().isInfoEnabled() )
  +        if( m_createRegistry )
           {
  -            final String message = "RMI registry created on port " + m_port;
  -            getLogger().info( message );
  +            m_registry = LocateRegistry.createRegistry( m_port );
  +            if( getLogger().isInfoEnabled() )
  +            {
  +                final String message = "RMI registry created on port " + m_port;
  +                getLogger().info( message );
  +            }
  +        }
  +        else
  +        {
  +            m_registry = LocateRegistry.getRegistry( m_port );
  +
  +            if( getLogger().isInfoEnabled() )
  +            {
  +                final String message = "Found RMI registry on port " + m_port;
  +                getLogger().info( message );
  +            }
           }
       }
   
       public void dispose()
       {
           m_registry = null;
  -
           m_remotes.clear();
           m_remotes = null;
       }
  @@ -92,7 +108,7 @@
       {
           synchronized( m_remotes )
           {
  -            final Remote remote = (Remote)m_remotes.get( publicationName );
  +            final Remote remote = (Remote) m_remotes.get( publicationName );
   
               m_registry.unbind( publicationName );
               UnicastRemoteObject.unexportObject( remote, true );
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to