felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@adobe.com>
Subject Re: Apache Felix with pax-create-project and scr-annotations
Date Mon, 15 Oct 2012 11:49:15 GMT
Hi,

Am 10.10.2012 um 14:05 schrieb Kjell Otto:

> I've tried to use the scr annotations with apache felix and it worked out
> after a bit of a hassle with where to put
> what and how to configure it(reference:
> http://stackoverflow.com/questions/12642706/how-to-use-org-apache-felix-scr-annotations-for-a-bundle-from-scratch/12660778#12660778).
> But now it works and my components are running.
> 
> Now I wanted to get started with the command line extension. I have googled
> arround and found more options then I would like to have. None of them
> seems to be applicable for my setup. I would like to provide a new command
> scope for my components to live in and be able to call them from the
> command line.
> Since as I already read from the mailing list, the new shell will be gogo,
> how would I then integrate my commands into the gogo shell with annotations
> from scr? Is there a way or to I need to refactor scr out and put blueprint
> in?

Extending Gogo is extremely simple: You just register a service (the actual service type does
not matter) and declare two service registration properties:

  * osgi.command.scope defining the namespace prefix
  * osgi.command.function defining the command functions

The osgi.command.function is a String[] listing public methods turned into commands. These
methods are analyzed through reflection.

As for annotations, all that's needed is something like:

  @Property(name="osgi.command.scope", value="sample")
  @Property(name="osgi.command.function", value={"c1", "c2"})

This defines two commands sample:c1 and sample:c2.

As an example of such a command class you might look at the DS ScrCommand [1] (this uses raw
OSGi API to register the service and not DS but the priniciple for defining commands is the
same)

Hope this helps.

Regards
Felix

[1] http://svn.apache.org/repos/asf/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java

> 
> There is not much documentation out there on how to integrate best now...
> Shouldn't the old material be deleted by the time? Or flagged?
> I would appreciate all hints and tips, thanks a lot.
> 
> Greetings,
> Kjellski


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message