avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel DefaultLoader.java
Date Sat, 23 Feb 2002 13:47:04 GMT
mcconnell    02/02/23 05:47:04

  Modified:    apps/enterprise/orb build.xml
               apps/enterprise/orb/lib openorb-1.2.2.jar
                        openorb_tools-1.2.2.jar
               apps/enterprise/orb/src/examples/hello/java/hello
                        HelloDemo.java HelloInitializer.java
                        HelloProvider.java
               apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel
                        DefaultLoader.java
  Log:
  Updated to include support for clean shutdown and disposal of interceptors.
  
  Revision  Changes    Path
  1.16      +1 -0      jakarta-avalon-cornerstone/apps/enterprise/orb/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/build.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- build.xml	23 Feb 2002 00:25:57 -0000	1.15
  +++ build.xml	23 Feb 2002 13:47:02 -0000	1.16
  @@ -186,6 +186,7 @@
   	    <path refid="project.classpath" />
             <pathelement path="${dist}/${orb.examples.jar}" />
   	  </classpath>
  +	  <arg line="-Dopenorb.debug=0"/>
        </java>
     </target>
   
  
  
  
  1.5       +1561 -1501jakarta-avalon-cornerstone/apps/enterprise/orb/lib/openorb-1.2.2.jar
  
  	<<Binary file>>
  
  
  1.5       +165 -139  jakarta-avalon-cornerstone/apps/enterprise/orb/lib/openorb_tools-1.2.2.jar
  
  	<<Binary file>>
  
  
  1.2       +25 -15    jakarta-avalon-cornerstone/apps/enterprise/orb/src/examples/hello/java/hello/HelloDemo.java
  
  Index: HelloDemo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/examples/hello/java/hello/HelloDemo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HelloDemo.java	22 Feb 2002 16:29:04 -0000	1.1
  +++ HelloDemo.java	23 Feb 2002 13:47:04 -0000	1.2
  @@ -61,7 +61,16 @@
   
       public static void main( String[] args )
       {
  +        //
  +        // create a new instance of the demo
  +        //
  +
           final HelloDemo demo = new HelloDemo();
  +
  +        //
  +        // add a shutdown hook just in case the user aborts the demo
  +        //
  +
           Runtime.getRuntime().addShutdownHook( 
             new Thread()
             {
  @@ -72,6 +81,10 @@
             }
           );
   
  +        //
  +        // prepare and execute the demo
  +        //
  +
           try
           {
               demo.enableLogging( createBootstrapLogger( "hello" ) );
  @@ -167,27 +180,24 @@
       public void dispose()
       {
           if( m_disposed ) return;
  +        m_disposed = true;
  +
  +        if( getLogger().isDebugEnabled() ) getLogger().debug( "Hello Demo disposal." );
           try
           {
  -            if( getLogger().isDebugEnabled() ) getLogger().debug( "shutting down demo"
);
  -            if( m_orb instanceof org.apache.orb.ORB )
  -            {
  -                ((org.apache.orb.ORB)m_orb).stop();
  -            }
  -            else
  -            {
  -                m_orb.shutdown( true );
  -            }
  +            m_orb.shutdown( true );
           }
           catch( Throwable e)
           {
  -            e.printStackTrace();
  +            if( getLogger().isWarnEnabled() ) getLogger().warn( 
  +               "Ignoring exception while stopping the ORB.", e );
  +        }
  +        finally
  +        {
  +            m_orb = null;
  +            m_config = null;
  +            m_context = null;
           }
  -        if( getLogger().isDebugEnabled() ) getLogger().debug( "demo disposal" );
  -        m_orb = null;
  -        m_config = null;
  -        m_context = null;
  -        m_disposed = true;
       }
   
       //=======================================================================
  
  
  
  1.2       +22 -18    jakarta-avalon-cornerstone/apps/enterprise/orb/src/examples/hello/java/hello/HelloInitializer.java
  
  Index: HelloInitializer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/examples/hello/java/hello/HelloInitializer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HelloInitializer.java	22 Feb 2002 16:29:04 -0000	1.1
  +++ HelloInitializer.java	23 Feb 2002 13:47:04 -0000	1.2
  @@ -58,7 +58,7 @@
    */
   
   public class HelloInitializer extends LocalObject
  -implements LogEnabled, Configurable, Contextualizable, ORBInitializer
  +implements LogEnabled, Configurable, Contextualizable, ORBInitializer, Disposable
   {
   
       private Logger m_logger;
  @@ -171,30 +171,34 @@
           {
               throw new CascadingRuntimeException( "Unable to start embedded server.", e);
           }
  -        finally
  -        {
  -
  -            //
  -            // dispose of ourselves now because we have nothing more to
  -            // contribute
  -            //
  -
  -            dispose();
  -        }
       }
   
       //=======================================================================
       // Disposable
       //=======================================================================
       
  -    private void dispose()
  +   /**
  +    * Disposal will be invoked by the ORB initializer following shutdown of the 
  +    * ORB we have been initialized within.
  +    */
  +    public void dispose()
       {
  -
           if( getLogger().isDebugEnabled() ) getLogger().debug("initializer disposal" );
  -        m_config = null;
  -        m_context = null;
  -        m_poa = null;
  -        m_logger = null;
  +        try
  +        {
  +            m_poa.stop();
  +        }
  +        catch( Throwable e )
  +        {
  +            if( getLogger().isWarnEnabled() ) getLogger().warn(
  +              "ignoring exception while stopping Hello provider", e );
  +        }
  +        finally
  +        {
  +            m_poa = null;
  +            m_config = null;
  +            m_context = null;
  +            m_logger = null;
  +        }
       }
  -
   }
  
  
  
  1.2       +2 -29     jakarta-avalon-cornerstone/apps/enterprise/orb/src/examples/hello/java/hello/HelloProvider.java
  
  Index: HelloProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/examples/hello/java/hello/HelloProvider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HelloProvider.java	22 Feb 2002 16:29:04 -0000	1.1
  +++ HelloProvider.java	23 Feb 2002 13:47:04 -0000	1.2
  @@ -66,7 +66,6 @@
       private Configuration m_config;
       private Context m_context;
   
  -    private HelloProvider m_this;
       private ORB m_orb;
       private Hello m_hello;
       private POA m_root;
  @@ -196,33 +195,6 @@
           }
   
           //
  -        // add a shutdown hook so we can stop the server and dispose of 
  -        // resources
  -        //
  -
  -        m_this = this;
  -        Runtime.getRuntime().addShutdownHook( 
  -          new Thread()
  -          {
  -              public void run()
  -              {
  -                  try
  -                  {
  -                      if( m_this != null ) m_this.stop();
  -                  }
  -                  catch( Throwable e )
  -                  {
  -                      // ignore it
  -                  }
  -                  finally
  -                  {
  -                      if( m_this != null ) m_this.dispose();
  -                  }
  -              }
  -          }
  -        );
  -
  -        //
           // register server as an initial reference
           //
   
  @@ -294,6 +266,7 @@
   	      final String warning = "Internal error while shutting down the ORB.";
               if( getLogger().isWarnEnabled() ) getLogger().warn( warning, e );
           }
  +        if( getLogger().isDebugEnabled() ) getLogger().debug( "provider stopped" );
       }
   
       //=======================================================================
  @@ -306,7 +279,7 @@
       */
       public void dispose()
       {
  -        if( getLogger().isDebugEnabled() ) getLogger().debug("disposal of embedded Hello
World" );
  +        if( getLogger().isDebugEnabled() ) getLogger().debug("disposal of embedded Hello
World Provider" );
           m_config = null;
           m_context = null;
           m_hello = null;
  
  
  
  1.6       +67 -31    jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel/DefaultLoader.java
  
  Index: DefaultLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/enterprise/orb/src/java/org/apache/orb/CORBA/kernel/DefaultLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultLoader.java	22 Feb 2002 16:29:35 -0000	1.5
  +++ DefaultLoader.java	23 Feb 2002 13:47:04 -0000	1.6
  @@ -25,6 +25,7 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.CascadingRuntimeException;
   import org.apache.avalon.framework.CascadingException;
  +import org.apache.avalon.framework.activity.Disposable;
   
   import org.apache.orb.CascadingConfiguration;
   
  @@ -48,7 +49,7 @@
    * Experimental ORB loader. 
    */
   
  -public class DefaultLoader implements ORBLoader
  +public class DefaultLoader implements ORBLoader, Disposable
   {
   
       //=========================================================================
  @@ -69,9 +70,10 @@
       private Context m_context;
       private Hashtable m_table = new Hashtable();
   
  -    private Properties _properties;
  +    private Properties m_properties;
       private File m_base;
       private org.openorb.CORBA.ORB m_orb;
  +    private ORBInitInfo m_init_info;
   
       //=========================================================================
       // implementation
  @@ -166,8 +168,8 @@
           }
   
           //
  -        // get the base directory from which any property declarations that
  -        // use file attributes can be resolved
  +        // get the base directory to use for resolution of property declarations that
  +        // uses file attributes
           //
    
           try
  @@ -189,7 +191,7 @@
           java.util.Properties properties = new java.util.Properties( m_default_properties
);
   
           //
  -        // Add any "initializer" element are included in the configuration as 
  +        // Add any "initializer" element that are included in the configuration as 
           // properties.
           //
   
  @@ -202,7 +204,8 @@
           }
   
           //
  -        // Add any "property" elements that are included in the supplied configuration
  +        // Add any "property" elements that are included in the configuration as 
  +        // properties.
           //
   
           try
  @@ -216,7 +219,8 @@
           }
           
           //
  -        // overwrite default values with the supplied properties argument
  +        // Overwrite the derived property values with the values from the supplied 
  +        // properties argument
           //
   
           if( props != null )
  @@ -246,8 +250,6 @@
           // create the orb init info.
           //
   
  -        ORBInitInfo init_info;
  -
           try
           {
               Object [] cargs = new Object[ 4 ];
  @@ -258,14 +260,16 @@
               targs[ 1 ] = org.openorb.CORBA.ORB.class;
   
               Configurator conf = new Configurator( args, properties );
  -            _properties = conf.getProperties();
  +            m_properties = conf.getProperties();
               load_initializers( cargs, conf.getInitializers() );
   
               targs[ 2 ] = ORBInitializer[].class;
               targs[ 3 ] = FeatureInitializer[].class;
   
  -            init_info = ( ORBInitInfo ) constructClass( 
  +            m_init_info = ( ORBInitInfo ) constructClass( 
                  "openorb.pi.ORBInitInfoClass", "org.openorb.PI.OpenORBInitInfo", cargs,
targs );
  +            if( m_init_info instanceof LogEnabled) 
  +               ((LogEnabled)m_init_info).enableLogging( m_logger );
           }
           catch ( Throwable ex )
           {
  @@ -273,11 +277,11 @@
                "Internal exception while attempting to create ORBInitInfo", ex );
           }
   
  -        init_info.pre_init();
  +        m_init_info.pre_init();
   
           // set the stack trace option
           org.openorb.util.Trace.setShowStackTrace( 
  -          _properties.getBooleanProperty( "openorb.debug.ShowStackTrace", false ) );
  +          m_properties.getBooleanProperty( "openorb.debug.ShowStackTrace", false ) );
   
           try
           {
  @@ -292,7 +296,7 @@
           }
   
           enableTrace();
  -        init_info.post_init();
  +        m_init_info.post_init();
       }
   
       /**
  @@ -300,7 +304,7 @@
        */
       public void display_configuration( java.io.PrintWriter out )
       {
  -        _properties.display( out );
  +        m_properties.display( out );
       }
   
       /**
  @@ -308,7 +312,7 @@
        */
       public void display_configuration( Logger logger )
       {
  -        _properties.display( logger );
  +        m_properties.display( logger );
       }
   
       /**
  @@ -361,7 +365,7 @@
        */
       public Iterator properties( String name )
       {
  -        return _properties.properties( name );
  +        return m_properties.properties( name );
       }
   
       /**
  @@ -370,7 +374,7 @@
        */
       public Property getProperty( String name )
       {
  -        return _properties.getProperty( name );
  +        return m_properties.getProperty( name );
       }
   
       /**
  @@ -380,7 +384,7 @@
        */
       public String getStringProperty( String name, String defl )
       {
  -        return _properties.getStringProperty( name, defl );
  +        return m_properties.getStringProperty( name, defl );
       }
   
       /**
  @@ -391,7 +395,7 @@
       public String getStringProperty( String name )
       throws PropertyNotFoundException
       {
  -        return _properties.getStringProperty( name );
  +        return m_properties.getStringProperty( name );
       }
   
       /**
  @@ -402,7 +406,7 @@
        */
       public int getIntProperty( String name, int defl )
       {
  -        return _properties.getIntProperty( name, defl );
  +        return m_properties.getIntProperty( name, defl );
       }
   
       /**
  @@ -414,7 +418,7 @@
       public int getIntProperty( String name )
       throws PropertyNotFoundException
       {
  -        return _properties.getIntProperty( name );
  +        return m_properties.getIntProperty( name );
       }
   
       /**
  @@ -424,7 +428,7 @@
        */
       public boolean getBooleanProperty( String name, boolean defl )
       {
  -        return _properties.getBooleanProperty( name, defl );
  +        return m_properties.getBooleanProperty( name, defl );
       }
   
       /**
  @@ -435,7 +439,7 @@
       public boolean getBooleanProperty( String name )
       throws PropertyNotFoundException
       {
  -        return _properties.getBooleanProperty( name );
  +        return m_properties.getBooleanProperty( name );
       }
   
       /**
  @@ -446,7 +450,7 @@
        */
       public URL getURLProperty( String name, URL defl )
       {
  -        return _properties.getURLProperty( name, defl );
  +        return m_properties.getURLProperty( name, defl );
       }
   
       /**
  @@ -458,7 +462,7 @@
       public URL getURLProperty( String name )
       throws PropertyNotFoundException
       {
  -        return _properties.getURLProperty( name );
  +        return m_properties.getURLProperty( name );
       }
   
       /**
  @@ -469,7 +473,7 @@
        */
       public Class getClassProperty( String name, Class defl )
       {
  -        return _properties.getClassProperty( name, defl );
  +        return m_properties.getClassProperty( name, defl );
       }
   
       /**
  @@ -481,7 +485,7 @@
        */
       public Class getClassProperty( String name, String defl )
       {
  -        return _properties.getClassProperty( name, defl );
  +        return m_properties.getClassProperty( name, defl );
       }
   
       /**
  @@ -493,7 +497,7 @@
       public Class getClassProperty( String name )
       throws PropertyNotFoundException
       {
  -        return _properties.getClassProperty( name );
  +        return m_properties.getClassProperty( name );
       }
   
       /**
  @@ -702,7 +706,7 @@
       //============================================================================
   
      /**
  -    * Returns the default ORB properties 
  +    * Returns the system wide default ORB properties 
       */
       public static java.util.Properties getDefaultProperties( ) 
       {
  @@ -726,7 +730,7 @@
       }
   
      /**
  -    * Returns the default configuration resource. 
  +    * Returns the system default ORB configuration resource. 
       */
       private static Configuration loadDefaultConfiguration( ) 
           throws MissingResourceException, ConfigurationException
  @@ -863,6 +867,38 @@
   		    }
   		}
   		properties.setProperty( name, value );
  +        }
  +    }
  +
  +    //=====================================================================
  +    // Disposable
  +    //=====================================================================
  +
  +   /**
  +    * Called by the ORB during shutdown enabling the initalizer to clean up.
  +    */
  +    public void dispose()
  +    {
  +        if( m_logger.isDebugEnabled() ) m_logger.debug( "ORB Loader disposal" );
  +        try
  +        {
  +            if( m_init_info instanceof Disposable ) ((Disposable)m_init_info).dispose();
  +        }
  +        catch( Throwable e )
  +        {
  +            // log message but don't throw an exception 
  +            final String warning = "Ignoring error during initializer disposal.";
  +            m_logger.warn( warning, e );
  +        }
  +        finally
  +        {
  +            m_config = null;
  +            m_context = null;
  +            m_table = null;
  +            m_properties = null;
  +            m_base = null;
  +            m_orb = null;
  +            m_init_info = null;
           }
       }
   }
  
  
  

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