You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2001/12/12 21:26:07 UTC
cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component ExcaliburComponentManager.java
bloritsch 01/12/12 12:26:07
Modified: src/java/org/apache/avalon/excalibur/component
ExcaliburComponentManager.java
Log:
clean up ExcaliburComponentManager messages
Revision Changes Path
1.13 +55 -35 jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java
Index: ExcaliburComponentManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ExcaliburComponentManager.java 2001/12/11 09:53:27 1.12
+++ ExcaliburComponentManager.java 2001/12/12 20:26:07 1.13
@@ -33,7 +33,7 @@
*
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
- * @version CVS $Revision: 1.12 $ $Date: 2001/12/11 09:53:27 $
+ * @version CVS $Revision: 1.13 $ $Date: 2001/12/12 20:26:07 $
* @since 4.0
*/
public class ExcaliburComponentManager
@@ -126,24 +126,21 @@
}
/**
- * Tests for existence of a component
+ * Tests for existence of a component. Please note that this test is for
+ * <strong>existing</strong> components, and a component will not be created
+ * to satisfy the request.
*/
public boolean hasComponent( final String role )
{
if ( ! m_initialized ) return false;
if ( m_disposed ) return false;
- boolean exists = false;
+ boolean exists = m_componentHandlers.containsKey( role );
- try
+ if ( ! exists && null != m_parentManager )
{
- this.release( this.lookup( role ) );
- exists = true;
+ exists = m_parentManager.hasComponent( role );
}
- catch ( Throwable t )
- {
- // We can safely ignore all exceptions
- }
return exists;
}
@@ -151,6 +148,7 @@
/** Properly initialize of the Child handlers.
*/
public void initialize( )
+ throws Exception
{
synchronized( this )
{
@@ -262,40 +260,62 @@
// create the component next
}
}
-
- if (getLogger().isDebugEnabled()) {
- getLogger().debug( "Could not find ComponentHandler, attempting to create one for role: " + role );
- }
- try
+ if ( null != m_roles )
{
final String className = m_roles.getDefaultClassNameForRole( role );
- final Class componentClass = m_loader.loadClass( className );
- final Configuration configuration = new DefaultConfiguration( "", "-" );
+ if ( null != className )
+ {
+ if (getLogger().isDebugEnabled())
+ {
+ getLogger().debug( "Could not find ComponentHandler, attempting to create one for role: " + role );
+ }
- handler =
- ComponentHandler.getComponentHandler( componentClass,
- configuration,
- this,
- m_context,
- m_roles,
- m_logkit);
+ try
+ {
+ final Class componentClass = m_loader.loadClass( className );
- handler.setLogger( getLogger() );
- handler.initialize();
- }
- catch( final Exception e )
- {
- final String message = "Could not find component";
- if( getLogger().isErrorEnabled() )
- {
- getLogger().debug( message + " for role: " + role, e );
+ final Configuration configuration = new DefaultConfiguration( "", "-" );
+
+ handler =
+ ComponentHandler.getComponentHandler( componentClass,
+ configuration,
+ this,
+ m_context,
+ m_roles,
+ m_logkit);
+
+ handler.setLogger( getLogger() );
+ handler.initialize();
+ }
+ catch( final Exception e )
+ {
+ final String message = "Could not find component";
+ if( getLogger().isErrorEnabled() )
+ {
+ getLogger().debug( message + " for role: " + role, e );
+ }
+ throw new ComponentException( message, e );
+ }
+
+ m_componentHandlers.put( role, handler );
}
- throw new ComponentException( message, e );
}
+ }
+ else
+ {
+ getLogger().debug( "The Role Manager has not been set!" );
+ }
- m_componentHandlers.put( role, handler );
+ if ( null == handler )
+ {
+ final String message = "Could not find component";
+ if( getLogger().isErrorEnabled() )
+ {
+ getLogger().debug( message + " for role: " + role );
+ }
+ throw new ComponentException( message );
}
Component component = null;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>