mcconnell 2004/03/12 10:12:35
Modified: merlin/activation/impl/src/java/org/apache/avalon/activation/impl
DefaultComponentFactory.java
Log:
Correction dealing with context handling with security enabled.
Revision Changes Path
1.8 +33 -22
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultComponentFactory.java
Index: DefaultComponentFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultComponentFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultComponentFactory.java 11 Mar 2004 18:13:14 -0000 1.7
+++ DefaultComponentFactory.java 12 Mar 2004 18:12:35 -0000 1.8
@@ -439,7 +439,6 @@
}
}
-
private Class getContextCastingClass()
{
if( null == m_model.getContextModel() )
@@ -824,7 +823,7 @@
if( model == null ) return;
final DeploymentModel provider = model.getProvider();
- if( null == provider )
+ if(( null == provider ) && (instance instanceof Contextualizable ))
{
getLogger().debug( "applying context" );
@@ -832,36 +831,48 @@
// its classic avalon
//
- try
+ if( context instanceof Context )
{
- if( m_secure )
+ try
{
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
{
- ((Contextualizable)instance).contextualize( (Context)
context );
- return null;
- }
- },
- m_model.getAccessControlContext() );
+ public Object run() throws Exception
+ {
+ ((Contextualizable)instance).contextualize(
+ (Context) context );
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.contextualize( instance, (Context) context );
+ }
}
- else
+ catch( Throwable e )
{
- ContainerUtil.contextualize( instance, (Context) context );
+ final String error =
+ REZ.getString(
+ "lifecycle.error.avalon-contextualization",
+ m_model.getQualifiedName() );
+ throw new LifecycleException( error, e );
}
}
- catch( Throwable e )
+ else
{
- final String error =
- REZ.getString(
- "lifecycle.error.avalon-contextualization",
- m_model.getQualifiedName() );
- throw new LifecycleException( error, e );
+ final String error =
+ "Supplied context class ["
+ + context.getClass().getName()
+ + "] does not implement the Avalon Context interface.";
+ throw new LifecycleException( error );
}
}
- else
+ else if( null != provider )
{
getLogger().debug( "applying custom context" );
try
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]