Thank you, but how can I inject services like I do in SCR? Or do I need that to do manually via the BundleContext?
-------
@Reference
private ParserService parseService;
-------
Regards, Erwin.
On Wednesday, April 13, 2016 08:57:47 PM Jean-Baptiste Onofré wrote:
> Hi,
>
> You don't need SCR if you use the command annotation.
>
> Just use the plugin:
>
> <plugin>
> <groupId>org.apache.karaf.tooling</groupId>
> <artifactId>karaf-services-maven-plugin</artifactId>
> </plugin>
>
>
> And no need to use @Component.
>
> Regards
> JB
>
> On 04/13/2016 08:49 PM, Erwin Müller wrote:
> > Hello,
> >
> > I setup an OSGi application with Felix SCR and Karaf. But how can I use
> > the
> > SCR annotations for Karaf commands? I tried the example command from the
> > Karaf manual and it works fine, but if I add the Felix SCR annotations,
> > the command is not working anymore in Karaf.
> >
> > I'm pretty new to OSGi but I got everything working (Karaf, Pax Exam,
> > Sling), I'm only stuck
> >
> > ----------
> > @Command(scope = "sscontrol", name = "parse", description = "Parses the
> > specified resource and checks for eventual errors.")
> > @Service
> > @Component
> > public class ParseCommand implements Action {
> >
> > @Argument(name = "resource", description = "The resource URI to be
> >
> > parsed.", required = true, multiValued = false)
> >
> > private String resource;
> >
> > @Reference
> > private ParserService parseService;
> >
> > @Override
> > public Object execute() throws Exception {
> >
> > Parser parser = parseService.create();
> > SscontrolScript script = parser.parse(toUri(resource));
> > return script;
> >
> > }
> >
> > private URI toUri(String resource) throws URISyntaxException {
> >
> > return new URI(resource);
> >
> > }
> >
> > }
> > --------
--
Erwin Müller - [email protected]
Software Entwickler - (+49) 01577-9505569
Pgp - https://pgp.mit.edu/pks/lookup?op=get&search=0x02E820911DD910FD
Meine Seite - http://www.mueller-public.de/
ANRI - http://www.anr-institute.com/
signature.asc
Description: This is a digitally signed message part.
