Thanks for the clarification Guillaume.
I expected @OsgiService to be deprecated in the new release, but it is
working. I guess @OsgiService is prone to service-damping since the
cdi-bean is managed by Weld/OWB. Is that still the case (there were some
discussions on the osgi-dev list)?
Personally I am mostly using DS, but in order to migrate some bigger
JEE-Applications towards OSGi it would be great if the developers could
keep their favored component-model (in our case CDI) and inject services.
Now I am only stuck with PAXCDI-210.
regards
Marc
Am Donnerstag, 6. Oktober 2016 09:05:56 UTC+2 schrieb Guillaume Nodet:
>
>
>
> Le mercredi 5 octobre 2016 18:33:51 UTC+2, Marc Schlegel a écrit :
>>
>> I am still trying to figure out how to use Pax-CDI with JSF in Pax-Web.
>>
>> *When I inject a OSGi-Service in a CDI-Bean I get a IllegalStateException*
>>
>> java.lang.IllegalArgumentException: Beans with @Service, @Component or
>> @Config injection points should be annotated with @Component
>>
>> @RequestScoped
>> @Named("loginController")
>> public class LoginController {
>>
>> private String username;
>> private String password;
>>
>> @Inject
>> @Service
>> private LoginService loginService;
>>
>> How would I inject an OSGi-Service in a scoped bean?
>>
>
> So you have two possibilities:
> * either you annotate the bean with @Component, and eventually with a
> scope in @SingletonScoped, @BundleScoped or @PrototypeScoped. In such a
> case, the lifecycle is managed by pax-cdi and your bean will be created /
> destroyed according to the availability of the LoginService osgi service
> * or you annotated your injection point with the additional @Global
> annotation.
> In such a case, your entire application lifecycle will be conditionned by
> the availability of the LoginService, i.e. it won't start until the service
> is available.
>
> Note that in both cases, you can annotate your injection point with
> @Optional or @Greedy to further modify the behaviour.
>
>
>> I think that was possible with version 0.13.0 by using
>>
>> @Inject @OsgiService
>> private LoginService loginService;
>>
>>
>>
> You should still be able to use this annotation.
>
> Guillaume
>
>
>> Should I file a bug or am I missing something?
>>
>> regards
>> Marc
>>
>
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.