Hi Kim, Declarative Services is a great choice, and should give you a simple way to do most of the things that you need.
> On 16 May 2016, at 04:52, Chong, Kim Theng <kimtheng.ch...@experian.com> > wrote: > > Hi all, > > Previously we were using Spring DM to perform dependencies injections and > services declaration, and now we would like to migrate to OSGI declarative > services/SCR. May I know is there any ways to perform: > > 1. bean wiring/dependency injection for SCR like Spring DM does? For > example: > > · @line1: We want to expose “myService” as a service. (This should be > achievable by using @Component, @Service, correct me if I am wrong) Which annotation set are you using? The standard annotations do not have an @Service annotation, and I would very strongly suggest that you use the standard annotations. By default using @Component exports all of the directly implemented interfaces of your component class (i.e. the exact list of interfaces after the implements keyword). This can be modified using the service attribute of the annotation. > · @line7: We want to inject “serviceRegistry” dependency to > “myService”. > · Note: “serviceRegistry” is a normal bean class, which does NOT > expose as a service. > > <image002.png> This sort of injection (“private” components) is not supported by Declarative Services, however this isn’t really a problem. You can either: Register the other component in the service registry. If it is using a “private” (i.e. not exported) API then nobody else will find it. Just new up the instance in your activate method. If the serviceRegistry component really is a private detail of a single component then it’s just part of its behaviour. The new operator isn’t always evil! > > 2. Reading properties from a configuration file and binding them into > service? For example > > a. There is a configuration file: service.config with following > properties: > > # service type > service.type = A > > > And we are declaring the service such a way in Spring DM: (the service that > going to be registered is based on the “service.type” value in the config > file). > Is this doable in OSGI declarative services? The @Component annotation has exactly this support using the properties attribute. Best of luck, Tim Ward Chief Technology Officer tim.w...@paremus.com > > <image001.png> > > > Thank you so much for your time. > > Best regards, > Kim > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org <mailto:osgi-dev@mail.osgi.org> > https://mail.osgi.org/mailman/listinfo/osgi-dev > <https://mail.osgi.org/mailman/listinfo/osgi-dev>
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev