It sounds like you have a basic misunderstanding. The SERVICE strategy
implements the OSGi Service Factory concept and automatically creates a
unique service object instance for each bundle that requests the
service. It doesn't mean that each requesting bundle will become the
provider of the unique service instance. The provider is always the
provider.
-> richard
On 5/9/12 10:24 , Adrian Mörchen wrote:
Hi,
I want to create a separate instance of a service with the bundles symbolic
name as field.
I've read somewhere that this should be possible using "SERVICE" as strategy:
@Component
@Provides(strategy = "SERVICE")
@Instantiate
public class MyServiceImpl implements MyService {
private final String symbolicName;
/**
* Constructor.
*
* @param context
* Context of the current bundle.
*/
public MyServiceImpl(BundleContext context) {
this.symbolicName = context.getBundle().getSymbolicName();
}
...
}
Unfortunately this doesn't work . The bundle context is always the context of
the bundle providing the service,
but I want it to be the context of the bundle requiring the context.
Any hints, how to solve this?
· The only more specific tutorial on this I found:
http://ipojo-dark-side.blogspot.de/2009/04/customized-service-object-creation-with.html
o But it's quite old and
o Not a full working example, which makes it hard to understand
· Also a custom factory method doesn't work.
Thanks,
Adrian
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]