
| Key: |
OSGI-167
|
| Type: |
Improvement
|
| Status: |
Resolved
|
| Resolution: |
Fixed
|
| Priority: |
Critical
|
| Assignee: |
Andy Piper
|
| Reporter: |
Andy Piper
|
| Votes: |
0
|
| Watchers: |
4
|
|
If you were logged in you would be able to see more operations.
|
|
|
|
Issue Links:
|
Related
|
|
|
|
This issue is related to:
|
|
OSGI-103
Listener callbacks should occur after properties have been set.
|
|
|
|
|
|
|
|
Spring-OSGi allows you to add listeners for OSGI services. Unfortunately because the services are exposed through OsgiServiceProxyFactoryBeans, you are prevented on being a listener yourself because this leads to a circular reference.
We need some kind of secret handshake in order to be able to work around this.
Typical usage:
<bean id="foo" class="Bar">
<property name="myservice">
<osgi:reference interface="MyService">
<osgi:listener ref="Bar"/>
</osgi:reference>
</property>
</bean>
|
|
Description
|
Spring-OSGi allows you to add listeners for OSGI services. Unfortunately because the services are exposed through OsgiServiceProxyFactoryBeans, you are prevented on being a listener yourself because this leads to a circular reference.
We need some kind of secret handshake in order to be able to work around this.
Typical usage:
<bean id="foo" class="Bar">
<property name="myservice">
<osgi:reference interface="MyService">
<osgi:listener ref="Bar"/>
</osgi:reference>
</property>
</bean> |
Show » |
|
So what needs to be done here is the following: OsgiServiceProxyFactoryBean needs to be able to expose its object early, i.e. even when "getObject()" gets called before the FactoryBean is fully initialized. If it can do that, it will be able to participate in circles. This will work out of the box with Spring 2.0.2 or higher; it is up to OsgiServiceProxyFactoryBean's implementation whether to support that or not.
Spring itself uses that early exposure mechanism for its ListFactoryBean, SetFactoryBean etc already, allowing such collections to be part of a circle. The actual logic for early exposure sits in AbstractFactoryBean, where the FactoryBean exposes a proxy for a given interface in such a case. Any call on that proxy will be delegated to the target object (that the FactoryBean usually builds), with the actual target object obtained on demand (i.e. only when a method call comes in). The actual interface to expose can be determined by the concrete FactoryBean class.
As a consequence, I'm going to move this issue to the Spring OSGi project.
Juergen