bloritsch 2002/08/27 14:04:53
Modified: container/src/java/org/apache/excalibur/container/legacy
LegacyComponentManager.java
Added: container/src/java/org/apache/excalibur/container/legacy
LegacyComponentSelector.java
Log:
add remaining legacy support
Revision Changes Path
1.2 +16 -1
jakarta-avalon-excalibur/container/src/java/org/apache/excalibur/container/legacy/LegacyComponentManager.java
Index: LegacyComponentManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/container/src/java/org/apache/excalibur/container/legacy/LegacyComponentManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LegacyComponentManager.java 27 Aug 2002 20:23:08 -0000 1.1
+++ LegacyComponentManager.java 27 Aug 2002 21:04:52 -0000 1.2
@@ -69,7 +69,22 @@
try
{
service = m_manager.lookup( role );
- component = m_proxyGen.getProxy( role, service );
+
+ if ( service instanceof ServiceSelector )
+ {
+ String roleName = role;
+ if ( roleName.endsWith("Selector") )
+ {
+ roleName.substring(0, "Selector".length());
+ }
+
+ component =
+ new LegacyComponentSelector( roleName, m_proxyGen,
(ServiceSelector)service );
+ }
+ else
+ {
+ component = m_proxyGen.getProxy( role, service );
+ }
}
catch (ComponentException ce)
{
1.1
jakarta-avalon-excalibur/container/src/java/org/apache/excalibur/container/legacy/LegacyComponentSelector.java
Index: LegacyComponentSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.container.legacy;
import org.apache.avalon.framework.component.*;
import org.apache.avalon.framework.service.*;
import java.util.HashMap;
/**
* Create a Component proxy. Requires JDK 1.3+
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
*/
public final class LegacyComponentSelector implements ComponentSelector
{
private final String m_role;
private final ComponentProxyGenerator m_proxyGen;
private final ServiceSelector m_selector;
private final HashMap m_map;
/**
* Initialize the ComponentProxyGenerator with the default classloader.
* The default classloader is the Thread context classloader.
*/
public LegacyComponentSelector(final String role, final ServiceSelector selector)
{
this( role, new ComponentProxyGenerator(), selector );
}
/**
* Initialize the ComponentProxyGenerator with the supplied classloader.
* If the supplied class loader is null, we use the Thread context class
* loader. If that is null, we use this class's classloader.
*/
public LegacyComponentSelector( final String role,
final ComponentProxyGenerator generator,
final ServiceSelector selector )
{
if ( null == role )
{
throw new NullPointerException( "role" );
}
if ( null == generator )
{
throw new NullPointerException( "generator" );
}
if ( null == selector )
{
throw new NullPointerException( "manager" );
}
m_role = role;
m_proxyGen = generator;
m_selector = selector;
m_map = new HashMap();
}
public boolean hasComponent( Object hint )
{
return m_selector.isSelectable( hint );
}
public Component select( Object hint )
throws ComponentException
{
Component component = null;
Object service = null;
try
{
service = m_selector.select( hint );
component = m_proxyGen.getProxy( m_role, service );
}
catch (ComponentException ce)
{
throw ce;
}
catch (Exception e)
{
throw new ComponentException( m_role + ":" + hint.toString(), e );
}
synchronized ( m_map )
{
m_map.put( component, service );
}
return component;
}
public void release( Component component )
{
Object service = null;
synchronized( m_map )
{
service = m_map.remove( component );
}
m_selector.release( service );
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>