You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Cristiano Costantini <cr...@gmail.com> on 2016/04/01 14:26:12 UTC
Custom shell commands from Karaf 2.x to Karaf 4.x
Hi all,
in my application I've developed some shell command using the now
@Deprecated org.apache.karaf.shell.console.OsgiCommandSupport
Is there any guide or can you suggest me an example on how to implement the
commands with the new API?
Thanks.
Cristiano
Re: Custom shell commands from Karaf 2.x to Karaf 4.x
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
No problem !
Thanks.
Regards
JB
On 04/02/2016 08:33 AM, Cristiano Costantini wrote:
> Hi JB,
> I didn't was aware of the Karaf archetypes and that was an archetype for
> the command, thank you,
>
> For all other, the documentation page is here:
> https://karaf.apache.org/manual/latest/developers-guide/archetypes.html
>
> Bye,
> Cristiano
>
>
>
>
>
> Il giorno ven 1 apr 2016 alle ore 15:49 Jean-Baptiste Onofré
> <jb@nanthrax.net <ma...@nanthrax.net>> ha scritto:
>
> That's it, and it's what you can find in the command archetype ;)
>
> Regards
> JB
>
> On 04/01/2016 03:29 PM, Cristiano Costantini wrote:
> > Hi, yes I confirm it by myself, the @Reference is resolved from
> the OSGi
> > service registry.
> >
> > Specifically, in the old command implementation I was injecting
> inside
> > the commands other beans directly taken from the the same beans.xml
> > file. Now I have to publish as OSGi services.
> >
> >
> > So in summary, previously I was using:
> >
> > <bean id="myService" class="net.cristcost.MyService" />
> >
> > <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
> > <command name="test/hello">
> > <action class="net.cristcost.HelloCommand">
> > <property name="myService" ref="myService" />
> > </action>
> > </command>
> > </command-bundle>
> >
> >
> > Now I've changed the code of net.cristcost.HelloCommand with
> @Service
> > and @Reference on the myService field, plus my blueprint.xml has
> changed
> > into:
> >
> > <bean id="myService" class="net.cristcost.MyService" />
> >
> > <service ref="myService" interface="net.cristcost.MyService" />
> >
> >
> > ...and the instruction <Karaf-Commands>*</Karaf-Commands> on the
> pom.xml !
> >
> > Thank you
> > Cristiano
> >
> >
> >
> >
> > Il giorno ven 1 apr 2016 alle ore 15:11 Cristiano Costantini
> > <cristiano.costantini@gmail.com
> <ma...@gmail.com>
> <mailto:cristiano.costantini@gmail.com
> <ma...@gmail.com>>>
> > ha scritto:
> >
> > Yeah!
> > that's what I'm searching to achieve...
> >
> > I've finally found the documentation page at
> >
> https://karaf.apache.org/manual/latest/developers-guide/extending.html
> >
> > and in my initial attempts, I also was missing that it is
> required
> > to add this instruction on the pom:
> > <plugin>
> >
> > <groupId>org.apache.felix</groupId>
> > <artifactId>maven-bundle-plugin</artifactId>
> > <configuration>
> > <instructions>
> > <Karaf-Commands>*</Karaf-Commands>
> > </instructions>
> > </configuration>
> > </plugin>
> >
> >
> > but I still don't understand how @Reference works... it is not
> > explained on the guide:
> >
> > In the Jdbc command example,
> >
> > @Reference
> > private JdbcService jdbcService;
> >
> > how the JdbcService it injected? is it resolved from OSGi
> services?
> >
> > Thank you
> > Cristiano
> >
> >
> >
> > Il giorno ven 1 apr 2016 alle ore 14:59 Morgan Hautman
> > <morgan.hautman@gmail.com <ma...@gmail.com>
> <mailto:morgan.hautman@gmail.com <ma...@gmail.com>>>
> ha scritto:
> >
> > Hi Christiano,
> >
> > If you mean custom commands, the jdbc command is an example:
> >
> https://github.com/apache/karaf/tree/master/jdbc/src/main/java/org/apache/karaf/jdbc/command
> >
> > Regards,
> > Morgan
> >
> > 2016-04-01 14:26 GMT+02:00 Cristiano Costantini
> > <cristiano.costantini@gmail.com
> <ma...@gmail.com>
> > <mailto:cristiano.costantini@gmail.com
> <ma...@gmail.com>>>:
> >
> > Hi all,
> > in my application I've developed some shell command using
> > the now @Deprecated
> > org.apache.karaf.shell.console.OsgiCommandSupport
> >
> > Is there any guide or can you suggest me an example
> on how
> > to implement the commands with the new API?
> >
> > Thanks.
> > Cristiano
> >
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Custom shell commands from Karaf 2.x to Karaf 4.x
Posted by Cristiano Costantini <cr...@gmail.com>.
Hi JB,
I didn't was aware of the Karaf archetypes and that was an archetype for
the command, thank you,
For all other, the documentation page is here:
https://karaf.apache.org/manual/latest/developers-guide/archetypes.html
Bye,
Cristiano
Il giorno ven 1 apr 2016 alle ore 15:49 Jean-Baptiste Onofré <
jb@nanthrax.net> ha scritto:
> That's it, and it's what you can find in the command archetype ;)
>
> Regards
> JB
>
> On 04/01/2016 03:29 PM, Cristiano Costantini wrote:
> > Hi, yes I confirm it by myself, the @Reference is resolved from the OSGi
> > service registry.
> >
> > Specifically, in the old command implementation I was injecting inside
> > the commands other beans directly taken from the the same beans.xml
> > file. Now I have to publish as OSGi services.
> >
> >
> > So in summary, previously I was using:
> >
> > <bean id="myService" class="net.cristcost.MyService" />
> >
> > <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
> > <command name="test/hello">
> > <action class="net.cristcost.HelloCommand">
> > <property name="myService" ref="myService" />
> > </action>
> > </command>
> > </command-bundle>
> >
> >
> > Now I've changed the code of net.cristcost.HelloCommand with @Service
> > and @Reference on the myService field, plus my blueprint.xml has changed
> > into:
> >
> > <bean id="myService" class="net.cristcost.MyService" />
> >
> > <service ref="myService" interface="net.cristcost.MyService" />
> >
> >
> > ...and the instruction <Karaf-Commands>*</Karaf-Commands> on the pom.xml
> !
> >
> > Thank you
> > Cristiano
> >
> >
> >
> >
> > Il giorno ven 1 apr 2016 alle ore 15:11 Cristiano Costantini
> > <cristiano.costantini@gmail.com <ma...@gmail.com>>
> > ha scritto:
> >
> > Yeah!
> > that's what I'm searching to achieve...
> >
> > I've finally found the documentation page at
> >
> https://karaf.apache.org/manual/latest/developers-guide/extending.html
> >
> > and in my initial attempts, I also was missing that it is required
> > to add this instruction on the pom:
> > <plugin>
> >
> > <groupId>org.apache.felix</groupId>
> > <artifactId>maven-bundle-plugin</artifactId>
> > <configuration>
> > <instructions>
> > <Karaf-Commands>*</Karaf-Commands>
> > </instructions>
> > </configuration>
> > </plugin>
> >
> >
> > but I still don't understand how @Reference works... it is not
> > explained on the guide:
> >
> > In the Jdbc command example,
> >
> > @Reference
> > private JdbcService jdbcService;
> >
> > how the JdbcService it injected? is it resolved from OSGi services?
> >
> > Thank you
> > Cristiano
> >
> >
> >
> > Il giorno ven 1 apr 2016 alle ore 14:59 Morgan Hautman
> > <morgan.hautman@gmail.com <ma...@gmail.com>> ha
> scritto:
> >
> > Hi Christiano,
> >
> > If you mean custom commands, the jdbc command is an example:
> >
> https://github.com/apache/karaf/tree/master/jdbc/src/main/java/org/apache/karaf/jdbc/command
> >
> > Regards,
> > Morgan
> >
> > 2016-04-01 14:26 GMT+02:00 Cristiano Costantini
> > <cristiano.costantini@gmail.com
> > <ma...@gmail.com>>:
> >
> > Hi all,
> > in my application I've developed some shell command using
> > the now @Deprecated
> > org.apache.karaf.shell.console.OsgiCommandSupport
> >
> > Is there any guide or can you suggest me an example on how
> > to implement the commands with the new API?
> >
> > Thanks.
> > Cristiano
> >
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
Re: Custom shell commands from Karaf 2.x to Karaf 4.x
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
That's it, and it's what you can find in the command archetype ;)
Regards
JB
On 04/01/2016 03:29 PM, Cristiano Costantini wrote:
> Hi, yes I confirm it by myself, the @Reference is resolved from the OSGi
> service registry.
>
> Specifically, in the old command implementation I was injecting inside
> the commands other beans directly taken from the the same beans.xml
> file. Now I have to publish as OSGi services.
>
>
> So in summary, previously I was using:
>
> <bean id="myService" class="net.cristcost.MyService" />
>
> <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
> <command name="test/hello">
> <action class="net.cristcost.HelloCommand">
> <property name="myService" ref="myService" />
> </action>
> </command>
> </command-bundle>
>
>
> Now I've changed the code of net.cristcost.HelloCommand with @Service
> and @Reference on the myService field, plus my blueprint.xml has changed
> into:
>
> <bean id="myService" class="net.cristcost.MyService" />
>
> <service ref="myService" interface="net.cristcost.MyService" />
>
>
> ...and the instruction <Karaf-Commands>*</Karaf-Commands> on the pom.xml !
>
> Thank you
> Cristiano
>
>
>
>
> Il giorno ven 1 apr 2016 alle ore 15:11 Cristiano Costantini
> <cristiano.costantini@gmail.com <ma...@gmail.com>>
> ha scritto:
>
> Yeah!
> that's what I'm searching to achieve...
>
> I've finally found the documentation page at
> https://karaf.apache.org/manual/latest/developers-guide/extending.html
>
> and in my initial attempts, I also was missing that it is required
> to add this instruction on the pom:
> <plugin>
>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <configuration>
> <instructions>
> <Karaf-Commands>*</Karaf-Commands>
> </instructions>
> </configuration>
> </plugin>
>
>
> but I still don't understand how @Reference works... it is not
> explained on the guide:
>
> In the Jdbc command example,
>
> @Reference
> private JdbcService jdbcService;
>
> how the JdbcService it injected? is it resolved from OSGi services?
>
> Thank you
> Cristiano
>
>
>
> Il giorno ven 1 apr 2016 alle ore 14:59 Morgan Hautman
> <morgan.hautman@gmail.com <ma...@gmail.com>> ha scritto:
>
> Hi Christiano,
>
> If you mean custom commands, the jdbc command is an example:
> https://github.com/apache/karaf/tree/master/jdbc/src/main/java/org/apache/karaf/jdbc/command
>
> Regards,
> Morgan
>
> 2016-04-01 14:26 GMT+02:00 Cristiano Costantini
> <cristiano.costantini@gmail.com
> <ma...@gmail.com>>:
>
> Hi all,
> in my application I've developed some shell command using
> the now @Deprecated
> org.apache.karaf.shell.console.OsgiCommandSupport
>
> Is there any guide or can you suggest me an example on how
> to implement the commands with the new API?
>
> Thanks.
> Cristiano
>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Custom shell commands from Karaf 2.x to Karaf 4.x
Posted by Cristiano Costantini <cr...@gmail.com>.
Hi, yes I confirm it by myself, the @Reference is resolved from the OSGi
service registry.
Specifically, in the old command implementation I was injecting inside the
commands other beans directly taken from the the same beans.xml file. Now I
have to publish as OSGi services.
So in summary, previously I was using:
<bean id="myService" class="net.cristcost.MyService" />
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="test/hello">
<action class="net.cristcost.HelloCommand">
<property name="myService" ref="myService" />
</action>
</command>
</command-bundle>
Now I've changed the code of net.cristcost.HelloCommand with @Service and
@Reference on the myService field, plus my blueprint.xml has changed into:
<bean id="myService" class="net.cristcost.MyService" />
<service ref="myService" interface="net.cristcost.MyService" />
...and the instruction <Karaf-Commands>*</Karaf-Commands> on the pom.xml !
Thank you
Cristiano
Il giorno ven 1 apr 2016 alle ore 15:11 Cristiano Costantini <
cristiano.costantini@gmail.com> ha scritto:
> Yeah!
> that's what I'm searching to achieve...
>
> I've finally found the documentation page at
> https://karaf.apache.org/manual/latest/developers-guide/extending.html
>
> and in my initial attempts, I also was missing that it is required to add
> this instruction on the pom:
> <plugin>
>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <configuration>
> <instructions>
> <Karaf-Commands>*</Karaf-Commands>
> </instructions>
> </configuration>
> </plugin>
>
>
> but I still don't understand how @Reference works... it is not explained
> on the guide:
>
> In the Jdbc command example,
>
> @Reference
> private JdbcService jdbcService;
>
> how the JdbcService it injected? is it resolved from OSGi services?
>
> Thank you
> Cristiano
>
>
>
> Il giorno ven 1 apr 2016 alle ore 14:59 Morgan Hautman <
> morgan.hautman@gmail.com> ha scritto:
>
>> Hi Christiano,
>>
>> If you mean custom commands, the jdbc command is an example:
>> https://github.com/apache/karaf/tree/master/jdbc/src/main/java/org/apache/karaf/jdbc/command
>>
>> Regards,
>> Morgan
>>
>> 2016-04-01 14:26 GMT+02:00 Cristiano Costantini <
>> cristiano.costantini@gmail.com>:
>>
>>> Hi all,
>>> in my application I've developed some shell command using the now
>>> @Deprecated org.apache.karaf.shell.console.OsgiCommandSupport
>>>
>>> Is there any guide or can you suggest me an example on how to implement
>>> the commands with the new API?
>>>
>>> Thanks.
>>> Cristiano
>>>
>>
>>
Re: Custom shell commands from Karaf 2.x to Karaf 4.x
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
It's a OSGi service: Karaf shell looks for the OSGi service
corresponding to the interface you define by annotation.
Regards
JB
On 04/01/2016 03:11 PM, Cristiano Costantini wrote:
> Yeah!
> that's what I'm searching to achieve...
>
> I've finally found the documentation page at
> https://karaf.apache.org/manual/latest/developers-guide/extending.html
>
> and in my initial attempts, I also was missing that it is required to
> add this instruction on the pom:
> <plugin>
>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <configuration>
> <instructions>
> <Karaf-Commands>*</Karaf-Commands>
> </instructions>
> </configuration>
> </plugin>
>
>
> but I still don't understand how @Reference works... it is not explained
> on the guide:
>
> In the Jdbc command example,
>
> @Reference
> private JdbcService jdbcService;
>
> how the JdbcService it injected? is it resolved from OSGi services?
>
> Thank you
> Cristiano
>
>
>
> Il giorno ven 1 apr 2016 alle ore 14:59 Morgan Hautman
> <morgan.hautman@gmail.com <ma...@gmail.com>> ha scritto:
>
> Hi Christiano,
>
> If you mean custom commands, the jdbc command is an example:
> https://github.com/apache/karaf/tree/master/jdbc/src/main/java/org/apache/karaf/jdbc/command
>
> Regards,
> Morgan
>
> 2016-04-01 14:26 GMT+02:00 Cristiano Costantini
> <cristiano.costantini@gmail.com
> <ma...@gmail.com>>:
>
> Hi all,
> in my application I've developed some shell command using the
> now @Deprecated org.apache.karaf.shell.console.OsgiCommandSupport
>
> Is there any guide or can you suggest me an example on how to
> implement the commands with the new API?
>
> Thanks.
> Cristiano
>
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Custom shell commands from Karaf 2.x to Karaf 4.x
Posted by Cristiano Costantini <cr...@gmail.com>.
Yeah!
that's what I'm searching to achieve...
I've finally found the documentation page at
https://karaf.apache.org/manual/latest/developers-guide/extending.html
and in my initial attempts, I also was missing that it is required to add
this instruction on the pom:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Karaf-Commands>*</Karaf-Commands>
</instructions>
</configuration>
</plugin>
but I still don't understand how @Reference works... it is not explained on
the guide:
In the Jdbc command example,
@Reference
private JdbcService jdbcService;
how the JdbcService it injected? is it resolved from OSGi services?
Thank you
Cristiano
Il giorno ven 1 apr 2016 alle ore 14:59 Morgan Hautman <
morgan.hautman@gmail.com> ha scritto:
> Hi Christiano,
>
> If you mean custom commands, the jdbc command is an example:
> https://github.com/apache/karaf/tree/master/jdbc/src/main/java/org/apache/karaf/jdbc/command
>
> Regards,
> Morgan
>
> 2016-04-01 14:26 GMT+02:00 Cristiano Costantini <
> cristiano.costantini@gmail.com>:
>
>> Hi all,
>> in my application I've developed some shell command using the now
>> @Deprecated org.apache.karaf.shell.console.OsgiCommandSupport
>>
>> Is there any guide or can you suggest me an example on how to implement
>> the commands with the new API?
>>
>> Thanks.
>> Cristiano
>>
>
>
Re: Custom shell commands from Karaf 2.x to Karaf 4.x
Posted by Morgan Hautman <mo...@gmail.com>.
Hi Christiano,
If you mean custom commands, the jdbc command is an example:
https://github.com/apache/karaf/tree/master/jdbc/src/main/java/org/apache/karaf/jdbc/command
Regards,
Morgan
2016-04-01 14:26 GMT+02:00 Cristiano Costantini <
cristiano.costantini@gmail.com>:
> Hi all,
> in my application I've developed some shell command using the now
> @Deprecated org.apache.karaf.shell.console.OsgiCommandSupport
>
> Is there any guide or can you suggest me an example on how to implement
> the commands with the new API?
>
> Thanks.
> Cristiano
>