Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gemini-dev] using managed-service-factory inner bean as a reference-listener

Hi all!

I've encountered a case which is not yet supported as it seems. Please see the context:

<osgi:list id="extensions" interface="com.foo.MyServiceExtension">
<osgi:reference-listener bind-method="registerExtension" unbind-method="unregisterExtension" ref="???" />
</osgi:list>
<osgix:managed-service-factory id="myServiceFactory" factory-pid="my-service-factory" autowire-on-update="true">
<osgix:interfaces>
<value>com.foo.MyService</value>
</osgix:interfaces>
<bean id="myService" class="com.foo.MyServiceImpl" />
</osgix:managed-service-factory>

where com.foo.Myservice interface has, among others, methods

public void registerExtension(MyServiceExtension extension, Map<?,?> properties);
public void unregisterExtension(MyServiceExtension extension, Map<?,?> properties);

So here's the case. My managed service factory is registering bean instances of MyService, and I need to use these bean instances as reference listeners (so that they can obtain MyServiceExtensions). The problem is what to put in the ref attribute of reference-listener declaraion. There are two possibilities which both turn out wrong:

1. ref="myService" -- fails because myService bean is an inner one, so it's id is not private
2. ref="myServiceFactory" -- fails because myServiceFactory is not a MyService instance and thus doesn't have required bind/unbind methods.

Now, I understand that this is not a minor feature request and I am willing to help and write some code, tests etc. All I need is a starting point in source code and a few words on what is the right way to support this functionality.

My proposal is that we use ref="myServiceFactory" and the handler (or whatever piece of code does this) treats this case (when ref points to a managed service factory) in a specific way: it waits for MyService instances to be constructed and then does to them whatever he would do if MyService was in a ref in the beginning.

Please feel free to correct my view. And thanks in advance.

Back to the top