leif 2002/11/07 04:43:19
Modified: src/java/org/apache/avalon/framework/service
WrapperServiceManager.java
WrapperServiceSelector.java
Log:
Fix the WrapperServiceManager so that the component looked from the wrapped
ComponentManager is always the same component as is released. Ie we need
to unwrap the components that we wrap.
Revision Changes Path
1.3 +10 -2
jakarta-avalon/src/java/org/apache/avalon/framework/service/WrapperServiceManager.java
Index: WrapperServiceManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/service/WrapperServiceManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WrapperServiceManager.java 7 Nov 2002 09:06:13 -0000 1.2
+++ WrapperServiceManager.java 7 Nov 2002 12:43:19 -0000 1.3
@@ -138,6 +138,14 @@
*/
public void release( final Object service )
{
- m_componentManager.release( (Component)service );
+ if ( service instanceof WrapperServiceSelector )
+ {
+ m_componentManager.
+ release(
((WrapperServiceSelector)service).getWrappedComponentSelector() );
+ }
+ else
+ {
+ m_componentManager.release( (Component)service );
+ }
}
}
1.3 +16 -1
jakarta-avalon/src/java/org/apache/avalon/framework/service/WrapperServiceSelector.java
Index: WrapperServiceSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/service/WrapperServiceSelector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WrapperServiceSelector.java 7 Nov 2002 09:06:13 -0000 1.2
+++ WrapperServiceSelector.java 7 Nov 2002 12:43:19 -0000 1.3
@@ -63,6 +63,9 @@
* This is a {@link ServiceSelector} implementation that can wrap around a legacy
* {@link ComponentSelector} object effectively adapting a {@link ComponentSelector}
* interface to a {@link ServiceSelector} interface.
+ * <p>
+ * This class implements the {@link Component} interface because it is used in
+ * environments which expect all components to implement Component.
*
* @author <a href="mailto:bloritsch@;apache.org">Berin Loritsch</a>
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
@@ -146,5 +149,17 @@
public void release( Object object )
{
m_selector.release( (Component)object );
+ }
+
+ /**
+ * The {@link WrapperServiceManager} wraps ComponentSelectors in
+ * WrapperServiceSelectors when they are looked up. This method
+ * makes it possible to release the original component selector.
+ *
+ * @return The {@link ComponentSelector} being wrapped.
+ */
+ ComponentSelector getWrappedComponentSelector()
+ {
+ return m_selector;
}
}
--
To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>