Paul,
I have now minimized the code that I call via REST:
@Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
private PersonService personService;
@GET
@Path("/test")
public String test() {
System.out.println("personService null" + (personService ==
null));
return "test";
}
The personService remains null, so no DI.
I enabled DEBUG in the log.
I only see DEBUG messages for " org.eclipse.jetty.util".
Not for anything else.
Nevertheless, feature:list | grep jax
Results in:
aries-jax-rs-whiteboard │ 2.0.2 │ │ Started
│ aries-jax-rs-2.0.2 │
aries-jax-rs-whiteboard-jackson │ 2.0.2 │ │ Started
│ aries-jax-rs-2.0.2 │
aries-jax-rs-whiteboard-jettison │ 2.0.2 │ │
Uninstalled │ aries-jax-rs-2.0.2 │
aries-jax-rs-whiteboard-openapi │ 2.0.2 │ │
Uninstalled │ aries-jax-rs-2.0.2 │
aries-jax-rs-whiteboard-rest-management │ 2.0.2 │ │
Uninstalled │ aries-jax-rs-2.0.2 │
aries-jax-rs-whiteboard-shiro │ 2.0.2 │ │
Uninstalled │ aries-jax-rs-2.0.2 │
jaxb │ 2.3.2.3 │ │
Uninstalled │ specs-4.4.3 │
jaxrs │ 2.1.0 │ │
Uninstalled │ specs-4.4.3 │
jaxws │ 2.3.0 │ │
Uninstalled │ specs-4.4.3 │
jackson-jaxrs │ 2.14.1 │ │
Uninstalled │ specs-4.4.3 │
cxf-jaxb │ 3.5.5 │ │
Uninstalled │ cxf-3.5.5 │
cxf-jaxws │ 3.5.5 │ │
Uninstalled │ cxf-3.5.5 │
cxf-jaxrs │ 3.5.5 │ │ Started
│ cxf-3.5.5 │
cxf-databinding-jaxb │ 3.5.5 │ │
Uninstalled │ cxf-3.5.5 │
cxf-jaxrs-cdi │ 3.5.5 │ │
Uninstalled │ cxf-3.5.5 │
karaf@root()>
This gives me the impression that the whitenboard stuff is working.
-- Jaap
> -----Original Message-----
> From: Paul Spencer <[email protected]>
> Sent: maandag 23 januari 2023 21:19
> To: [email protected]
> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not
> with DS
>
> Jaap,
> Something is missing. The @Referenece should prevent the component
> from becoming Active when a PeopleService does not exist.
> Look in Karaf.log for clues.
>
> Paul Spencer
>
> > On Jan 23, 2023, at 3:14 PM, Jaap Gordijn <[email protected]> wrote:
> >
> > Paul,
> >
> > I tried also the @Reference annotation.
> > This doesn't work, the variable remains null.
> > No injection is happening.
> >
> > -- Jaap
> >
> >> -----Original Message-----
> >> From: Paul Spencer <[email protected]>
> >> Sent: maandag 23 januari 2023 21:09
> >> To: [email protected]
> >> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
> >> works not with DS
> >>
> >> Jaap,
> >> In the code I posted, there was not constructor. I moved the
> >> injection of personService to an @Reference annotated field. The
> >> @Activator annotation is for a method, which you may not need based on
> your example.
> >>
> >> Paul Spencer
> >>
> >>
> >>> On Jan 23, 2023, at 2:30 PM, Jaap Gordijn <[email protected]> wrote:
> >>>
> >>> Hi Paul,
> >>>
> >>> That constructor is called, but only if I disable
> >>> @@JaxrsApplicationSelect.
> >>>
> >>> If I enable it, only the default constructor is called (Rest() in my case.
> >>> And no DS.
> >>>
> >>> -- Jaap
> >>>
> >>>> -----Original Message-----
> >>>> From: Paul Spencer <[email protected]>
> >>>> Sent: maandag 23 januari 2023 18:59
> >>>> To: [email protected]
> >>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
> >>>> works not with DS
> >>>>
> >>>> Jaap,
> >>>> Your @Activate annotation is incorrect.
> >>>> Try the following.
> >>>>
> >>>>
> >>>> …
> >>>> public class Rest() {
> >>>>
> >>>> @Reference
> >>>> private PersonService personService;
> >>>>
> >>>> @Activate
> >>>> public void activate(Map <String,?> properties) {
> >>>> ...
> >>>> }
> >>>>
> >>>> }
> >>>>
> >>>> Paul Spencer
> >>>>
> >>>>
> >>>>> On Jan 23, 2023, at 12:40 PM, Jaap Gordijn <[email protected]> wrote:
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> I use an Application object (with @JaxrsApplicationSelect),
> >>>>> injection via DS does not work:
> >>>>>
> >>>>> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
> >>>>> @JaxrsResource @JaxrsApplicationSelect("(" +
> >>>>> JaxrsWhiteboardConstants.JAX_RS_NAME +
> >>>>> "=MyApplication)")
> >>>>> @JSONRequired
> >>>>> @Produces(MediaType.APPLICATION_JSON)
> >>>>> public class Rest {
> >>>>>
> >>>>> private PersonService personService;
> >>>>>
> >>>>> /*
> >>>>> public Rest() {
> >>>>> System.out.println("Constructing REST");
> >>>>> this.personService = new PersonServiceImpl();
> >>>>> }
> >>>>> */
> >>>>>
> >>>>> @Activate
> >>>>> public Rest(final @Reference PersonService personService) {
> >>>>> System.out.println("Constructing REST");
> >>>>> this.personService = personService; }
> >>>>>
> >>>>> @GET
> >>>>> @Path("/person")
> >>>>> public List<PersonDto> listPersons() {
> >>>>> return personService.select();
> >>>>> }
> >>>>>
> >>>>> @GET
> >>>>> @Path("/test")
> >>>>> public String test() {
> >>>>> return "test";
> >>>>> }
> >>>>> }
> >>>>>
> >>>>> The @Activate constructor is not called. If I enable the Rest()
> >>>>> constructor that one is called.
> >>>>> if I disable @JaxrsApplicationSelect, the personService is injected.
> >>>>>
> >>>>> It seems that once an Application class is used (see below), DS is
> >>>>> not working.
> >>>>> This leads to the question what I have to set up for the
> >>>>> Application
> >> object:
> >>>>>
> >>>>> @Component(service=Application.class, property =
> >>>>> {"servlet.init.hide-service-list-page=true"} )
> >>>>> @JaxrsApplicationBase("example")
> >>>>> @JaxrsName("MyApplication")
> >>>>> public class MyApplication extends Application {
> >>>>>
> >>>>> public Set<Class<?>> getClasses() {
> >>>>> HashSet<Class<?>> set = new HashSet<Class<?>>();
> >>>>> set.add(Rest.class);
> >>>>> return set;
> >>>>> }
> >>>>>
> >>>>> }
> >>>>>
> >>>>> Jax-rs-whiteboard 2.02
> >>>>> Karaf 4.4.3
> >>>>>
> >>>>> Thanks,
> >>>>>
> >>>>> -- Jaap
> >>>>>
> >>>>>
> >>>
> >>>
> >
> >