felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Mörchen <adrian.moerc...@communote.com>
Subject Problem creating separate service for each bundle
Date Wed, 09 May 2012 14:24:33 GMT
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





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message