You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/11/07 06:11:35 UTC
cvs commit: jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet AbstractComponentManagerServlet.java AbstractReferenceProxyLatch.java ExcaliburComponentManagerServlet.java InstrumentManagerReferenceProxy.java LoggerManagerReferenceProxy.java
donaldp 2002/11/06 21:11:35
Modified: component/src/java/org/apache/avalon/excalibur/component
AbstractDualLogEnabledInstrumentable.java
ComponentHandler.java DefaultComponentFactory.java
ExcaliburComponentManager.java
ExcaliburComponentManagerCreator.java
ExcaliburComponentSelector.java
LogKit2LoggerTarget.java
component/src/java/org/apache/avalon/excalibur/component/servlet
AbstractComponentManagerServlet.java
AbstractReferenceProxyLatch.java
ExcaliburComponentManagerServlet.java
InstrumentManagerReferenceProxy.java
LoggerManagerReferenceProxy.java
Log:
Optimize imports
Revision Changes Path
1.2 +0 -1 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/AbstractDualLogEnabledInstrumentable.java
Index: AbstractDualLogEnabledInstrumentable.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/AbstractDualLogEnabledInstrumentable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractDualLogEnabledInstrumentable.java 6 Aug 2002 16:28:37 -0000 1.1
+++ AbstractDualLogEnabledInstrumentable.java 7 Nov 2002 05:11:34 -0000 1.2
@@ -8,7 +8,6 @@
package org.apache.avalon.excalibur.component;
import java.util.ArrayList;
-
import org.apache.excalibur.instrument.Instrument;
import org.apache.excalibur.instrument.Instrumentable;
1.8 +10 -13 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ComponentHandler.java
Index: ComponentHandler.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ComponentHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ComponentHandler.java 24 Sep 2002 20:39:53 -0000 1.7
+++ ComponentHandler.java 7 Nov 2002 05:11:34 -0000 1.8
@@ -8,7 +8,6 @@
package org.apache.avalon.excalibur.component;
import org.apache.avalon.excalibur.pool.Poolable;
-
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
@@ -17,10 +16,9 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.thread.SingleThreaded;
import org.apache.avalon.framework.thread.ThreadSafe;
-
import org.apache.excalibur.instrument.CounterInstrument;
-import org.apache.excalibur.instrument.Instrumentable;
import org.apache.excalibur.instrument.InstrumentManager;
+import org.apache.excalibur.instrument.Instrumentable;
import org.apache.excalibur.instrument.ValueInstrument;
/**
@@ -48,7 +46,7 @@
/** Instrument used to profile the number of puts. */
private CounterInstrument m_putsInstrument;
-
+
/*---------------------------------------------------------------
* Static Methods
*-------------------------------------------------------------*/
@@ -89,7 +87,7 @@
null,
"N/A" );
}
-
+
/**
* Looks up and returns a component handler for a given component class.
*
@@ -139,8 +137,8 @@
if( numInterfaces > 1 )
{
throw new Exception( "[CONFLICT] More than one lifecycle interface in "
- + componentClass.getName() + " May implement no more than one of "
- + "SingleThreaded, ThreadSafe, or Poolable" );
+ + componentClass.getName() + " May implement no more than one of "
+ + "SingleThreaded, ThreadSafe, or Poolable" );
}
// Create the factory to use to create the instances of the Component.
@@ -170,7 +168,7 @@
}
// Set the instrumentable name of the handler.
- ((Instrumentable)handler).setInstrumentableName(
+ ( (Instrumentable)handler ).setInstrumentableName(
ExcaliburComponentManager.INSTRUMENTABLE_NAME + "." + instrumentableName );
return handler;
@@ -204,7 +202,7 @@
return new ThreadSafeComponentHandler( componentInstance );
}
-
+
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
@@ -241,7 +239,7 @@
{
m_references++;
}
-
+
// Notify the instrument manager
m_getsInstrument.increment();
m_referencesInstrument.setValue( m_references );
@@ -273,8 +271,7 @@
{
m_references--;
}
-
- // Notify the instrument manager
+t manager
m_putsInstrument.increment();
m_referencesInstrument.setValue( m_references );
1.10 +14 -17 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java
Index: DefaultComponentFactory.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultComponentFactory.java 24 Sep 2002 20:39:53 -0000 1.9
+++ DefaultComponentFactory.java 7 Nov 2002 05:11:34 -0000 1.10
@@ -9,11 +9,9 @@
import java.util.ArrayList;
import java.util.Collection;
-
import org.apache.avalon.excalibur.collections.BucketMap;
import org.apache.avalon.excalibur.logger.LogKitManageable;
import org.apache.avalon.excalibur.pool.ObjectFactory;
-
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Startable;
@@ -29,15 +27,14 @@
import org.apache.avalon.framework.logger.Loggable;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-
-import org.apache.excalibur.instrument.Instrumentable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.excalibur.container.legacy.ComponentProxyGenerator;
import org.apache.excalibur.instrument.InstrumentManageable;
import org.apache.excalibur.instrument.InstrumentManager;
-import org.apache.excalibur.container.legacy.ComponentProxyGenerator;
+import org.apache.excalibur.instrument.Instrumentable;
/**
* Factory for Avalon components.
@@ -219,8 +216,7 @@
( (Loggable)component ).setLogger( m_loggerManager.getLogKitLoggerForCategory( logger ) );
}
}
- }
-
+
// Set the name of the instrumentable before initialization.
if( component instanceof Instrumentable )
{
@@ -288,7 +284,7 @@
if( component instanceof Instrumentable )
{
// Instrumentable Name is set above.
- if ( m_instrumentManager != null )
+ if( m_instrumentManager != null )
{
m_instrumentManager.registerInstrumentable(
(Instrumentable)component, m_instrumentableName );
@@ -304,14 +300,14 @@
Component returnableComponent;
- if ( ! ( component instanceof Component ) )
+ if( !( component instanceof Component ) )
{
- returnableComponent = m_proxyGenerator.getProxy( m_role , component );
- m_components.put( returnableComponent, component );
+ returnableComponent = m_proxyGenerator.getProxy( m_role, component );
+ m_components.put( returnableComponent, component );
}
else
{
- returnableComponent = (Component) component;
+ returnableComponent = (Component)component;
}
return returnableComponent;
@@ -327,7 +323,7 @@
{
Object check = m_components.get( component );
Object decommission;
- if ( check instanceof ServiceManager || check instanceof ComponentManager || null == check )
+ if( check instanceof ServiceManager || check instanceof ComponentManager || null == check )
{
decommission = component;
}
@@ -393,11 +389,12 @@
}
}
}
-
+
/*---------------------------------------------------------------
* ThreadSafe Methods
*-------------------------------------------------------------*/
// No methods
+ethods
/*---------------------------------------------------------------
* Methods
1.18 +18 -23 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java
Index: ExcaliburComponentManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ExcaliburComponentManager.java 24 Sep 2002 20:39:53 -0000 1.17
+++ ExcaliburComponentManager.java 7 Nov 2002 05:11:34 -0000 1.18
@@ -8,15 +8,12 @@
package org.apache.avalon.excalibur.component;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-
import org.apache.avalon.excalibur.collections.BucketMap;
import org.apache.avalon.excalibur.logger.LogKitManageable;
import org.apache.avalon.excalibur.logger.LogKitManager;
import org.apache.avalon.excalibur.logger.LoggerManager;
-
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
@@ -28,11 +25,10 @@
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
-
import org.apache.excalibur.instrument.Instrument;
-import org.apache.excalibur.instrument.Instrumentable;
import org.apache.excalibur.instrument.InstrumentManageable;
import org.apache.excalibur.instrument.InstrumentManager;
+import org.apache.excalibur.instrument.Instrumentable;
/**
* Default component manager for Avalon's components.
@@ -476,6 +472,8 @@
}
/*---------------------------------------------------------------
+ * Contextual
+ /*---------------------------------------------------------------
* Contextualizable Methods
*-------------------------------------------------------------*/
/** Set up the Component's Context.
@@ -496,30 +494,30 @@
public void initialize()
throws Exception
{
- if ( m_instrumentManager != null )
+ if( m_instrumentManager != null )
{
m_instrumentManager.registerInstrumentable( this, m_instrumentableName );
}
-
+
synchronized( this )
{
m_initialized = true;
- for (int i = 0; i < m_newComponentHandlers.size(); i++ )
+ for( int i = 0; i < m_newComponentHandlers.size(); i++ )
{
final ComponentHandler handler =
(ComponentHandler)m_newComponentHandlers.get( i );
try
{
handler.initialize();
-
+
// Manually register the handler so that it will be located under the
// instrument manager, seperate from the actual instrumentable data of the
// components
- if ( ( m_instrumentManager != null ) &&
+ if( ( m_instrumentManager != null ) &&
( handler instanceof Instrumentable ) )
{
- String handleInstName = ((Instrumentable)handler).getInstrumentableName();
+ String handleInstName = ( (Instrumentable)handler ).getInstrumentableName();
m_instrumentManager.registerInstrumentable( handler, handleInstName );
}
}
@@ -528,7 +526,7 @@
if( getLogger().isErrorEnabled() )
{
getLogger().error( "Caught an exception trying to initialize "
- + "the component handler.", e );
+ + "the component handler.", e );
}
}
}
@@ -541,20 +539,20 @@
final ComponentHandler handler =
(ComponentHandler)m_componentHandlers.get( key );
- if ( !m_newComponentHandlers.contains( handler ) )
+ if( !m_newComponentHandlers.contains( handler ) )
{
try
{
handler.initialize();
-
+
// Manually register the handler so that it will be located under the
// instrument manager, seperate from the actual instrumentable data of the
// components
- if ( ( m_instrumentManager != null ) &&
+ if( ( m_instrumentManager != null ) &&
( handler instanceof Instrumentable ) )
{
- String handleInstName =
- ((Instrumentable)handler).getInstrumentableName();
+ String handleInstName =
+ ( (Instrumentable)handler ).getInstrumentableName();
m_instrumentManager.registerInstrumentable( handler, handleInstName );
}
}
@@ -563,7 +561,7 @@
if( getLogger().isErrorEnabled() )
{
getLogger().error( "Caught an exception trying to initialize "
- + "the component handler.", e );
+ + "the component handler.", e );
}
}
}
@@ -650,10 +648,7 @@
m_logkit = new LogkitLoggerManager( null, logkit );
}
}
-
- /*---------------------------------------------------------------
- * InstrumentManageable Methods
- *-------------------------------------------------------------*/
+-------------------------------------------------------------*/
/**
* Sets the InstrumentManager for child components. Can be for special
* purpose components, however it is used mostly internally.
1.5 +44 -47 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManagerCreator.java
Index: ExcaliburComponentManagerCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManagerCreator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExcaliburComponentManagerCreator.java 21 Aug 2002 12:45:11 -0000 1.4
+++ ExcaliburComponentManagerCreator.java 7 Nov 2002 05:11:34 -0000 1.5
@@ -10,10 +10,8 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-
-import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
-
+import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.configuration.Configuration;
@@ -22,12 +20,10 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.ConsoleLogger;
-import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogKitLogger;
-
+import org.apache.avalon.framework.logger.Logger;
import org.apache.excalibur.instrument.InstrumentManager;
import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
-
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
@@ -85,8 +81,7 @@
private ComponentManager m_componentManager;
/** Internal instrument manager. */
- private InstrumentManager m_instrumentManager;
-
+ private InstrumentManag
/*---------------------------------------------------------------
* Static Methods
*-------------------------------------------------------------*/
@@ -99,7 +94,7 @@
context.makeReadOnly();
return context;
}
-
+
/**
* Creates a Configuration object from data read from an InputStream.
*
@@ -112,7 +107,7 @@
private static Configuration readConfigurationFromStream( InputStream is )
throws Exception
{
- if ( is == null )
+ if( is == null )
{
return null;
}
@@ -123,7 +118,7 @@
return config;
}
}
-
+
/**
* Creates a Configuration object from data read from an InputStream.
*
@@ -136,7 +131,7 @@
private static Configuration readConfigurationFromFile( File file )
throws Exception
{
- if ( file == null )
+ if( file == null )
{
return null;
}
@@ -153,7 +148,7 @@
}
}
}
-
+
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
@@ -182,7 +177,7 @@
Configuration instrumentManagerConfig )
throws Exception
{
- if ( context == null )
+ if( context == null )
{
m_context = createDefaultContext();
}
@@ -190,7 +185,7 @@
{
m_context = context;
}
-
+
// The primordial logger is used for all output up until the point
// where the Logger manager has been initialized. However it is set
// into objects used to load the configuration resource files. Any
@@ -199,7 +194,7 @@
// be displayed, so turn it off by default.
// Unfortunately, there is not a very good place to make this settable.
m_primordialLogger = new ConsoleLogger( ConsoleLogger.LEVEL_INFO );
-
+
try
{
initializeLoggerManager( loggerManagerConfig );
@@ -207,14 +202,14 @@
initializeInstrumentManager( instrumentManagerConfig );
initializeComponentManager( componentManagerConfig );
}
- catch ( Exception e )
+ catch( Exception e )
{
// Clean up after the managers which were set up.
dispose();
throw e;
}
}
-
+
/**
* Create a new ExcaliburComponentManagerCreator using Input Streams.
*
@@ -244,13 +239,13 @@
InputStream instrumentManagerConfigStream )
throws Exception
{
- this ( context,
- readConfigurationFromStream( loggerManagerConfigStream ),
- readConfigurationFromStream( roleManagerConfigStream ),
- readConfigurationFromStream( componentManagerConfigStream ),
- readConfigurationFromStream( instrumentManagerConfigStream ) );
+ this( context,
+ readConfigurationFromStream( loggerManagerConfigStream ),
+ readConfigurationFromStream( roleManagerConfigStream ),
+ readConfigurationFromStream( componentManagerConfigStream ),
+ readConfigurationFromStream( instrumentManagerConfigStream ) );
}
-
+
/**
* Create a new ExcaliburComponentManagerCreator using Files.
*
@@ -279,13 +274,13 @@
File instrumentManagerConfigFile )
throws Exception
{
- this ( context,
- readConfigurationFromFile( loggerManagerConfigFile ),
- readConfigurationFromFile( roleManagerConfigFile ),
- readConfigurationFromFile( componentManagerConfigFile ),
- readConfigurationFromFile( instrumentManagerConfigFile ) );
+ this( context,
+ readConfigurationFromFile( loggerManagerConfigFile ),
+ readConfigurationFromFile( roleManagerConfigFile ),
+ readConfigurationFromFile( componentManagerConfigFile ),
+ readConfigurationFromFile( instrumentManagerConfigFile ) );
}
-
+
/*---------------------------------------------------------------
* Disposable Methods
*-------------------------------------------------------------*/
@@ -298,27 +293,27 @@
// Clean up all of the objects that we created in the propper order.
try
{
- if ( m_componentManager != null )
+ if( m_componentManager != null )
{
ContainerUtil.shutdown( m_componentManager );
}
-
- if ( m_instrumentManager != null )
+
+ if( m_instrumentManager != null )
{
ContainerUtil.shutdown( m_instrumentManager );
}
-
- if ( m_roleManager != null )
+
+ if( m_roleManager != null )
{
ContainerUtil.shutdown( m_roleManager );
}
-
- if ( m_loggerManager != null )
+
+ if( m_loggerManager != null )
{
ContainerUtil.shutdown( m_loggerManager );
}
}
- catch ( Exception e )
+ catch( Exception e )
{
getLogger().error( "Unexpected error disposing managers.", e );
}
@@ -336,7 +331,7 @@
{
return m_loggerManager;
}
-
+
/**
* Returns the configured InstrumentManager. May be null if an instrument
* configuration was not specified in the constructor.
@@ -347,7 +342,7 @@
{
return m_instrumentManager;
}
-
+
/**
* Returns the configured ComponentManager.
*
@@ -357,19 +352,19 @@
{
return m_componentManager;
}
-
+
/**
* Returns the logger for internal use.
*/
private Logger getLogger()
{
- if ( m_logger != null )
+ if( m_logger != null )
{
return m_logger;
}
return m_primordialLogger;
}
-
+
private void initializeLoggerManager( Configuration loggerManagerConfig )
throws Exception
{
@@ -379,7 +374,7 @@
// Resolve a name for the logger, taking the logPrefix into account
String lmDefaultLoggerName;
String lmLoggerName;
- if ( logPrefix == null )
+ if( logPrefix == null )
{
lmDefaultLoggerName = "";
lmLoggerName = loggerManagerConfig.getAttribute( "logger", "system.logkit" );
@@ -411,7 +406,7 @@
loggerManager.contextualize( m_context );
loggerManager.configure( loggerManagerConfig );
m_loggerManager = loggerManager;
-
+
// Since we now have a LoggerManager, we can update the m_logger field
// if it is null and start logging to the "right" logger.
if( m_logger == null )
@@ -438,10 +433,12 @@
private void initializeInstrumentManager( Configuration instrumentManagerConfig )
throws Exception
{
- if ( instrumentManagerConfig != null )
+ if( instrumentManagerConfig != null )
{
// Get the logger for the instrument manager
Logger imLogger = m_loggerManager.getLoggerForCategory(
+ instrumentManagerConfig.getAttribute( "logger", "system.instrument" ) );
+
instrumentManagerConfig.getAttribute( "logger", "system.instrument" ) );
// Set up the Instrument Manager
1.16 +3 -7 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java
Index: ExcaliburComponentSelector.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ExcaliburComponentSelector.java 24 Sep 2002 20:39:53 -0000 1.15
+++ ExcaliburComponentSelector.java 7 Nov 2002 05:11:34 -0000 1.16
@@ -8,15 +8,12 @@
package org.apache.avalon.excalibur.component;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-
import org.apache.avalon.excalibur.collections.BucketMap;
import org.apache.avalon.excalibur.logger.LogKitManageable;
import org.apache.avalon.excalibur.logger.LogKitManager;
import org.apache.avalon.excalibur.logger.LoggerManager;
-
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
@@ -30,11 +27,10 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.thread.ThreadSafe;
-
import org.apache.excalibur.instrument.Instrument;
-import org.apache.excalibur.instrument.Instrumentable;
import org.apache.excalibur.instrument.InstrumentManageable;
import org.apache.excalibur.instrument.InstrumentManager;
+import org.apache.excalibur.instrument.Instrumentable;
/**
* Default component selector for Avalon's components.
@@ -426,7 +422,7 @@
{
handler.initialize();
- // Manually register the handler so that it will be located under the
+ ly register the handler so that it will be located under the
// instrument manager, seperate from the actual instrumentable data of the
// components
if ( ( m_instrumentManager != null ) &&
1.4 +2 -2 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/LogKit2LoggerTarget.java
Index: LogKit2LoggerTarget.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/LogKit2LoggerTarget.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LogKit2LoggerTarget.java 12 Sep 2002 15:47:53 -0000 1.3
+++ LogKit2LoggerTarget.java 7 Nov 2002 05:11:34 -0000 1.4
@@ -8,10 +8,10 @@
package org.apache.avalon.excalibur.component;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.log.Hierarchy;
import org.apache.log.LogEvent;
import org.apache.log.LogTarget;
import org.apache.log.Priority;
-import org.apache.log.Hierarchy;
/**
* A basic LogKit target that routes from LogKit to
1.4 +38 -39 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/AbstractComponentManagerServlet.java
Index: AbstractComponentManagerServlet.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/AbstractComponentManagerServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractComponentManagerServlet.java 19 Sep 2002 05:41:10 -0000 1.3
+++ AbstractComponentManagerServlet.java 7 Nov 2002 05:11:35 -0000 1.4
@@ -9,23 +9,19 @@
import java.io.IOException;
import java.util.ArrayList;
-
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.avalon.excalibur.logger.LoggerManager;
-
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.Logger;
-
import org.apache.excalibur.instrument.CounterInstrument;
import org.apache.excalibur.instrument.Instrument;
-import org.apache.excalibur.instrument.Instrumentable;
import org.apache.excalibur.instrument.InstrumentManager;
+import org.apache.excalibur.instrument.Instrumentable;
import org.apache.excalibur.instrument.ValueInstrument;
/**
@@ -61,8 +57,7 @@
private CounterInstrument m_instrumentRequests;
/** Records the amount of time execute takes to be processed. */
- private ValueInstrument m_instrumentTime;
-
+ private ValueInstrument m_inst
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
@@ -77,18 +72,18 @@
{
//System.out.println( "AbstractComponentManagerServlet( " + referenceName + " )" );
m_referenceName = referenceName;
-
+
// Set up Instrumentable like AbstractInstrumentable
m_registered = false;
m_instrumentList = new ArrayList();
m_childList = new ArrayList();
-
+
// Create the instruments
setInstrumentableName( referenceName );
addInstrument( m_instrumentRequests = new CounterInstrument( "requests" ) );
addInstrument( m_instrumentTime = new ValueInstrument( "time" ) );
}
-
+
/*---------------------------------------------------------------
* HttpServlet Methods
*-------------------------------------------------------------*/
@@ -108,82 +103,82 @@
// Initialize logging for the servlet.
LoggerManager loggerManager =
(LoggerManager)context.getAttribute( LoggerManager.class.getName() );
- if ( loggerManager == null )
+ if( loggerManager == null )
{
throw new IllegalStateException(
"The ExcaliburComponentManagerServlet servlet was not correctly initialized." );
}
Logger logger = loggerManager.getLoggerForCategory( "servlet" );
m_logger = logger.getChildLogger( m_referenceName );
-
- if ( getLogger().isDebugEnabled() )
+
+ if( getLogger().isDebugEnabled() )
{
getLogger().debug( "servlet.init( config )" );
}
-
+
// Obtain a reference to the ComponentManager
m_componentManager =
(ComponentManager)context.getAttribute( ComponentManager.class.getName() );
- if ( m_componentManager == null )
+ if( m_componentManager == null )
{
throw new IllegalStateException(
"The ExcaliburComponentManagerServlet servlet was not correctly initialized." );
}
-
+
// Register this servlet with the InstrumentManager if it exists.
InstrumentManager instrumentManager =
(InstrumentManager)context.getAttribute( InstrumentManager.class.getName() );
- if ( instrumentManager != null )
+ if( instrumentManager != null )
{
try
{
instrumentManager.registerInstrumentable(
this, "servlets." + getInstrumentableName() );
}
- catch ( Exception e )
+ catch( Exception e )
{
throw new ServletException(
"Unable to register the servlet with the instrument manager.", e );
}
}
-
+
// Do this last so the subclasses will be able to access these objects in their
// init method.
super.init( config );
}
-
+
/**
* Called by the servlet container to indicate to a servlet that the servlet
* is being taken out of service.
*/
public void destroy()
{
- if ( getLogger().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
getLogger().debug( "servlet.destroy()" );
}
-
+
//System.out.println( "AbstractComponentManagerServlet.destroy()" );
// Release the ComponentManager by removing its reference.
m_componentManager = null;
-
+
super.destroy();
-
+
// Make sure that the component manager gets collected.
System.gc();
-
+
// Give the system time for the Gc to complete. This is necessary to make sure that
// the ECMServlet has time to dispose all of its managers before the Tomcat server
// invalidates the current class loader.
try
{
- Thread.sleep(250);
+ Thread.sleep( 250 );
}
- catch ( InterruptedException e )
+ catch( InterruptedException e )
{
}
}
-
+
/**
* Receives standard HTTP requests from the public service method and dispatches
* them to the doXXX methods defined in this class.
@@ -195,35 +190,35 @@
* the servlet returns to the client.
*/
public void service( HttpServletRequest request, HttpServletResponse response )
- throws ServletException, IOException
+ throws ServletException, IOException
{
- if ( getLogger().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
StringBuffer sb = new StringBuffer( request.getRequestURI() );
String query = request.getQueryString();
- if ( query != null )
+ if( query != null )
{
sb.append( "?" );
sb.append( query );
}
-
+
getLogger().debug( "Request: " + sb.toString() );
}
-
+
long start = System.currentTimeMillis();
-
+
// Notify the Instrument Manager
m_instrumentRequests.increment();
-
+
super.service( request, response );
-
+
// Notify the Instrument Manager how long the service took.
- if ( m_instrumentTime.isActive() )
+ if( m_instrumentTime.isActive() )
{
m_instrumentTime.setValue( (int)( System.currentTimeMillis() - start ) );
}
}
-
+
/*---------------------------------------------------------------
* Instrumentable Methods
*-------------------------------------------------------------*/
@@ -301,6 +296,10 @@
{
Instrument[] instruments = new Instrument[ m_instrumentList.size() ];
m_instrumentList.toArray( instruments );
+ return instruments;
+ }
+ }
+rray( instruments );
return instruments;
}
}
1.3 +32 -33 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/AbstractReferenceProxyLatch.java
Index: AbstractReferenceProxyLatch.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/AbstractReferenceProxyLatch.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractReferenceProxyLatch.java 21 Aug 2002 12:45:11 -0000 1.2
+++ AbstractReferenceProxyLatch.java 7 Nov 2002 05:11:35 -0000 1.3
@@ -8,10 +8,8 @@
package org.apache.avalon.excalibur.component.servlet;
import org.apache.avalon.excalibur.logger.LoggerManager;
-
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-
import org.apache.excalibur.instrument.InstrumentManager;
/**
@@ -41,8 +39,7 @@
private int m_waitingProxies;
/** Flag that keeps track of when the trigger is requested. */
- private boolean m_triggerRequested;
-
+ private boolean m_triggerReq
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
@@ -64,37 +61,37 @@
public ReferenceProxy createProxy( Object object, String name )
{
m_name = name;
-
- if ( getLogger().isDebugEnabled() )
+
+ if( getLogger().isDebugEnabled() )
{
getLogger().debug( "Creating a proxy named '" + m_name + "' for a "
- + object.getClass().getName() );
+ + object.getClass().getName() );
}
-
+
AbstractReferenceProxy proxy;
- if ( object instanceof LoggerManager )
+ if( object instanceof LoggerManager )
{
proxy = new LoggerManagerReferenceProxy( (LoggerManager)object, this, name );
}
- else if ( object instanceof ComponentManager )
+ else if( object instanceof ComponentManager )
{
proxy = new ComponentManagerReferenceProxy( (ComponentManager)object, this, name );
}
- else if ( object instanceof InstrumentManager )
+ else if( object instanceof InstrumentManager )
{
proxy = new InstrumentManagerReferenceProxy( (InstrumentManager)object, this, name );
}
else
{
throw new IllegalArgumentException( "Don't know how to create a proxy for a "
- + object.getClass().getName() );
+ + object.getClass().getName() );
}
-
+
m_waitingProxies++;
-
+
return proxy;
}
-
+
/**
* Request that the triggered() method be called by asking all of the proxies
* managed by the latch to notify that they are no longer accepting requests
@@ -107,54 +104,54 @@
{
waitingProxies = m_waitingProxies;
}
-
- if ( waitingProxies > 0 )
+
+ if( waitingProxies > 0 )
{
// Invoke garbage collection so that any proxies will be GCed if possible.
System.gc();
-
+
// Give the JVM a little time for the proxies to be GCed
try
{
Thread.sleep( 1500 );
}
- catch ( InterruptedException e )
+ catch( InterruptedException e )
{
}
}
-
+
synchronized( this )
{
m_triggerRequested = true;
waitingProxies = m_waitingProxies;
}
-
- if ( waitingProxies > 0 )
+
+ if( waitingProxies > 0 )
{
- if ( getLogger().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
getLogger().debug( "Trigger requested. " + waitingProxies
- + " proxies have not yet been finalized." );
+ + " proxies have not yet been finalized." );
}
}
else
{
- if ( getLogger().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
getLogger().debug( "Trigger requested. All proxies have been finalized." );
}
-
+
try
{
triggered();
}
- catch ( Exception e )
+ catch( Exception e )
{
getLogger().error( "Encountered an unexpected error in the trigger callback:", e );
}
}
}
-
+
/**
* Called by a proxy when it is finalized.
*
@@ -165,17 +162,19 @@
synchronized( this )
{
m_waitingProxies--;
-
+
// Was that the last proxy?
- if ( m_waitingProxies > 0 )
+ if( m_waitingProxies > 0 )
{
- if ( getLogger().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
getLogger().debug( "The proxy named '" + proxy.getName() + "' was finalized. "
- + m_waitingProxies + " proxies remaining." );
+ + m_waitingProxies + " proxies remaining." );
}
return;
}
+ }
+}
}
// Do this outside the synchronization block.
1.4 +38 -40 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/ExcaliburComponentManagerServlet.java
Index: ExcaliburComponentManagerServlet.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/ExcaliburComponentManagerServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExcaliburComponentManagerServlet.java 19 Sep 2002 05:41:10 -0000 1.3
+++ ExcaliburComponentManagerServlet.java 7 Nov 2002 05:11:35 -0000 1.4
@@ -7,9 +7,8 @@
*/
package org.apache.avalon.excalibur.component.servlet;
-import java.io.InputStream;
import java.io.IOException;
-
+import java.io.InputStream;
import javax.servlet.GenericServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -17,13 +16,10 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;
-
import org.apache.avalon.excalibur.component.ExcaliburComponentManagerCreator;
import org.apache.avalon.excalibur.logger.LoggerManager;
-
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.container.ContainerUtil;
-
import org.apache.excalibur.instrument.InstrumentManager;
/**
@@ -135,12 +131,11 @@
private ExcaliburComponentManagerCreator m_componentManagerCreator;
/** Latch used to shutdown the ExcaliburComponentManagerCreator cleanly. */
- private Latch m_latch;
-
+ private Latch m_lat
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
-
+
/*---------------------------------------------------------------
* GenericServlet Methods
*-------------------------------------------------------------*/
@@ -157,10 +152,10 @@
public void init( ServletConfig servletConfig ) throws ServletException
{
super.init( servletConfig );
-
+
//System.out.println( "ExcaliburComponentManagerServlet.init() BEGIN" );
ServletContext servletContext = getServletContext();
-
+
InputStream loggerManagerConfigStream = null;
InputStream roleManagerConfigStream = null;
InputStream componentManagerConfigStream = null;
@@ -175,7 +170,7 @@
getStreamFromParameter( servletConfig, "components", true );
instrumentManagerConfigStream =
getStreamFromParameter( servletConfig, "instrument", false );
-
+
// Create the ComponentManagerCreator
try
{
@@ -186,7 +181,7 @@
componentManagerConfigStream,
instrumentManagerConfigStream );
}
- catch ( Exception e )
+ catch( Exception e )
{
String msg = "Unable to create the ComponentManagerCreator. "
+ "Most likely a comfiguration problem.";
@@ -198,41 +193,41 @@
// Close the resource streams
try
{
- if ( loggerManagerConfigStream != null )
+ if( loggerManagerConfigStream != null )
{
loggerManagerConfigStream.close();
}
- if ( roleManagerConfigStream != null )
+ if( roleManagerConfigStream != null )
{
roleManagerConfigStream.close();
}
- if ( componentManagerConfigStream != null )
+ if( componentManagerConfigStream != null )
{
componentManagerConfigStream.close();
}
- if ( instrumentManagerConfigStream != null )
+ if( instrumentManagerConfigStream != null )
{
instrumentManagerConfigStream.close();
}
}
- catch ( IOException e )
+ catch( IOException e )
{
throw new ServletException( "Encountered an error closing resource streams.", e );
}
}
-
+
LoggerManager loggerManager = m_componentManagerCreator.getLoggerManager();
-
+
// A series of ReferenceProxies which will be used to access the ComponentManager
// and other managers created by the ComponentManagerCreator must be created.
// This is necessary because the order in which servlets are shut down by a
// ServletContainer can not be controlled. If a manager is disposed before all
// servlets have released their references to it, then errors can result.
-
+
// Create the latch which will manager the ReferenceProxies.
m_latch = new Latch( m_componentManagerCreator );
m_latch.enableLogging( loggerManager.getLoggerForCategory( "system.ecmservlet" ) );
-
+
// Create the actual ReferenceProxies.
ReferenceProxy loggerManagerProxy = m_latch.createProxy(
loggerManager, "LoggerManager" );
@@ -240,13 +235,13 @@
m_componentManagerCreator.getComponentManager(), "ComponentManager" );
ReferenceProxy instrumentManagerProxy = m_latch.createProxy(
m_componentManagerCreator.getInstrumentManager(), "InstrumentManager" );
-
+
// Store references to the proxies in the ServletContext so that other servlets can gain
// access to them
- servletContext.setAttribute( LoggerManager.class.getName(), loggerManagerProxy );
- servletContext.setAttribute( ComponentManager.class.getName(), componentManagerProxy );
+ servletContext.setAttribute( LoggerManager.class.getName(), loggerManagerProxy );
+ servletContext.setAttribute( ComponentManager.class.getName(), componentManagerProxy );
servletContext.setAttribute( InstrumentManager.class.getName(), instrumentManagerProxy );
-
+
//System.out.println( "ExcaliburComponentManagerServlet.init() END" );
}
@@ -256,20 +251,20 @@
public void destroy()
{
//System.out.println( "ExcaliburComponentManagerServlet.destroy() BEGIN" );
-
+
ServletContext servletContext = getServletContext();
-
+
// Remove the references to the managers from the servlet context.
servletContext.removeAttribute( LoggerManager.class.getName() );
servletContext.removeAttribute( ComponentManager.class.getName() );
servletContext.removeAttribute( InstrumentManager.class.getName() );
-
+
// Tell the latch that we are ready for it do dispose of the ECMC
m_latch.requestTrigger();
-
+
//System.out.println( "ExcaliburComponentManagerServlet.destroy() END" );
}
-
+
/**
* This servlet does not accept requests. It will complain if called.
*
@@ -283,7 +278,7 @@
{
throw new UnavailableException( getClass().getName() + " does not except service requests." );
}
-
+
/*---------------------------------------------------------------
* Methods
*-------------------------------------------------------------*/
@@ -303,15 +298,17 @@
private InputStream getStreamFromParameter( ServletConfig servletConfig,
String resourceName,
boolean required )
- throws ServletException {
+ throws ServletException
+ {
String configFileName = servletConfig.getInitParameter( resourceName );
- if ( configFileName == null ) {
- if ( required )
+ if( configFileName == null )
+ {
+ if( required )
{
throw new ServletException( resourceName
- + " parameter must be provided in servlet configuration." );
+ + " parameter must be provided in servlet configuration." );
}
else
{
@@ -325,13 +322,14 @@
InputStream is = servletContext.getResourceAsStream( configFileName );
- if ( is == null ) {
+ if( is == null )
+ {
throw new ServletException( "Resource '" + configFileName + "' is not available." );
}
return is;
}
-
+
/*---------------------------------------------------------------
* Private Classes
*-------------------------------------------------------------*/
@@ -339,7 +337,7 @@
extends AbstractReferenceProxyLatch
{
ExcaliburComponentManagerCreator m_componentManagerCreator;
-
+
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
@@ -353,7 +351,7 @@
{
m_componentManagerCreator = componentManagerCreator;
}
-
+
/*---------------------------------------------------------------
* AbstractReferenceProxyLatch Methods
*-------------------------------------------------------------*/
1.3 +4 -4 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/InstrumentManagerReferenceProxy.java
Index: InstrumentManagerReferenceProxy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/InstrumentManagerReferenceProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InstrumentManagerReferenceProxy.java 21 Aug 2002 12:45:11 -0000 1.2
+++ InstrumentManagerReferenceProxy.java 7 Nov 2002 05:11:35 -0000 1.3
@@ -7,8 +7,8 @@
*/
package org.apache.avalon.excalibur.component.servlet;
-import org.apache.excalibur.instrument.Instrumentable;
import org.apache.excalibur.instrument.InstrumentManager;
+import org.apache.excalibur.instrument.Instrumentable;
/**
* Reference Proxy to an InstrumentManager
@@ -22,7 +22,7 @@
implements InstrumentManager
{
private InstrumentManager m_instrumentManager;
-
+
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
@@ -40,7 +40,7 @@
super( latch, name );
m_instrumentManager = instrumentManager;
}
-
+
/*---------------------------------------------------------------
* InstrumentManager Methods
*-------------------------------------------------------------*/
1.3 +3 -4 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/LoggerManagerReferenceProxy.java
Index: LoggerManagerReferenceProxy.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet/LoggerManagerReferenceProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LoggerManagerReferenceProxy.java 21 Aug 2002 12:45:11 -0000 1.2
+++ LoggerManagerReferenceProxy.java 7 Nov 2002 05:11:35 -0000 1.3
@@ -8,7 +8,6 @@
package org.apache.avalon.excalibur.component.servlet;
import org.apache.avalon.excalibur.logger.LoggerManager;
-
import org.apache.avalon.framework.logger.Logger;
/**
@@ -23,7 +22,7 @@
implements LoggerManager
{
private LoggerManager m_loggerManager;
-
+
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
@@ -41,7 +40,7 @@
super( latch, name );
m_loggerManager = loggerManager;
}
-
+
/*---------------------------------------------------------------
* LoggerManager Methods
*-------------------------------------------------------------*/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>