You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Michael Bachran <mb...@voiceobjects.com> on 2003/02/10 16:27:27 UTC

ECM-Bug: proxiing services that do not implement Component fails ...

Hi,

The above mentioned proxiing seems to work fine for ThreadSafe or SingleThreaded components (that do not use Selector) in my place.
As I wanted to get rid of deprecations (not moving to Fortress or Merlin yet) I tried to remove the Component interface.
Two problems arose from this:

1. When using a Selector the role is AbcSelector for implementation Abc but no class AbcSelector exists (of course) -> ClassNotFoundException ...
I think this can be fixed by the following patch (DefaultComponentFactory; line 300):


+        final String role;
+        if ( m_role.endsWith( "Selector" ) )
+        {
+            role = m_role.substring( 0, m_role.indexOf( "Selector" ) );
+        }
+        else
+        {
+            role = m_role;
+        }

(or just: final String role = m_role.substring( 0, m_role.indexOf( "Selector" ) );)

+        returnableComponent = m_proxyGenerator.getProxy( role, component );
-         returnableComponent = m_proxyGenerator.getProxy( m_role, component );


2. When a component is poolable the pool needs to cast it after getting it from the component factory but the proxy cannot be cast. 
As it is just a markup interface the proxy might be extended in this case by one more interface (ComponentProxyGenerator; line 105):


+        final Class[] proxiedInterfaces;
+        if ( service instanceof Poolable )
+        {
+            proxiedInterfaces = new Class[]{Component.class, Poolable.class, serviceInterface};
+        }
+        else
+        {
+            proxiedInterfaces = new Class[]{Component.class, serviceInterface};
+        }

+        return (Component)Proxy.newProxyInstance( m_classLoader,
+                proxiedInterfaces,
+                new ComponentInvocationHandler( service ) );


-         return (Component)Proxy.newProxyInstance( m_classLoader,
-                 new Class[]{Component.class, serviceInterface},
-                 new ComponentInvocationHandler( service ) );


Have a nice day,

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: ECM-Bug: proxiing services that do not implement Component fails ...

Posted by Berin Loritsch <bl...@apache.org>.
Michael Bachran wrote:
> Hi,
> 
> The above mentioned proxiing seems to work fine for ThreadSafe or SingleThreaded components (that do not use Selector) in my place.
> As I wanted to get rid of deprecations (not moving to Fortress or Merlin yet) I tried to remove the Component interface.
> Two problems arose from this:
> 
> 1. When using a Selector the role is AbcSelector for implementation Abc but no class AbcSelector exists (of course) -> ClassNotFoundException ...
> I think this can be fixed by the following patch (DefaultComponentFactory; line 300):


Good catch.

I can backport a utility class I wrote to parse the role, and then we
can apply a patch that uses it....



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org