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);
}
}
--------
--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com