You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Artem Zhirkov <az...@develdynamic.com> on 2015/01/20 11:53:19 UTC

Getting a reference to a declarative service

Hello,

I want to include more than one service into a bundle, so it seems like 
I have to make a use of declarative services.

I'm building a test bundle with maven + maven-bundle-plugin and 
generating the ds descriptor with maven-scr-plugin, so it looks like this:

<?xml version="1.0" encoding="UTF-8"?><components 
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
     <scr:component name="ru.multicabinet.gateway.ExampleDS">
         <implementation class="ru.multicabinet.gateway.ExampleDS"/>
         <service servicefactory="false">
             <provide interface="ru.multicabinet.gateway.SimpleI"/>
         </service>
         <property name="service.pid" 
value="ru.multicabinet.gateway.ExampleDS"/>
     </scr:component>
</components>

After installing the test bundle into my osgi container I'm trying to 
get a list of all services in the test bundle by calling 
bundle.getRegisteredServices(), but it'd always return null.

What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a 
reference to ds service?

Thanks


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


Re: Gogo output not always showing

Posted by Derek Baum <de...@baums.org.uk>.
just add the command to start telnet to gosh.args:

java -Dgosh.args='--nointeractive -c telnetd start' -jar bin/felix.jar


Note: if you are using Java 8, you need gogo.shell (0.12.0) to fix FELIX-4425

—
Derek



> On 21 Jan 2015, at 08:12, Bulu <bu...@romandie.com> wrote:
> 
> Hello Derek
>>> I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes (rarely), certain of my commands do no longer output to the shell, instead the output is really going to the std-out of the java application. Note that at the same time, other of my own commands in the same bundle still work as expected and output to the gogo shell.
>>> 
>> The Felix remote shell was designed to work before gogo was introduced.
>> 
>> gogo has its own simple telnet daemon:
>> 
>> Welcome to Apache Felix Gogo
>> 
>> g! type telnetd
>> telnetd is void gogo:telnetd(String[])
>> true
>> g! telnetd -?
>> telnetd - start simple telnet server
>> Usage: telnetd [-i ip] [-p port] start | stop | status
>>   -i --ip=INTERFACE        listen interface (default=127.0.0.1)
>>   -p --port=PORT           listen port (default=2019)
>>   -? --help                show help
>> g! telnetd start
>> telnetd is running on 127.0.0.1:2019
>> g!
>> 
> Thanks - I wasn't aware of that internal telnet daemon. I currently start the framework in non-interactive mode (gosh.args=--nointeractive) and rely on the telnet daemon to connect to the shell. How can I make gogo's telnetd start by itself?
> 
> Regards Philipp
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Gogo output not always showing

Posted by Bulu <bu...@romandie.com>.
OK, so one fix would be to run my command in a new thread created from 
within the gogo command and thus inheriting its ThreadLocals. I can't 
use ExecutorService, but that's not a big blocker.
Will try that...

Regards Philipp




On 21.01.2015 13:35, Derek Baum wrote:
> I’ve thought more about this.
>
> The gogo telnet daemon creates a new CommandSession, using the IO streams to the telnet client,
> which has the expected result of re-directing IO to the telnet client.
>
> gogo’s ThreadIO uses InheritableThreadLocal to manage the per-thread IO,
> so that any new thread that inherits from the initial gogo thread will also have its IO redirected to the telnet client.
>
>
> However, in your case, the command that writes to System.out is NOT run in a thread inherited from gogo, and thus appears on the default JVM console.
>
>
> A possible solution is to change the signature of your command to include CommandSession as the first argument,
> you can then use session.getConsole() to get the output stream used to create the session i.e. the telnet client.
>
> However, doing this will mean that you can’t pipe the output of your command, as it will always write to the console.
>
>
> —
> Derek
>
>
>
>
>
>> On 21 Jan 2015, at 11:42, Bulu <bu...@romandie.com> wrote:
>>
>> My command is not doing anything fancy with System.out - just calling println(). Also I couldn't find any call to System.setOut() in my code.
>>
>> If the System.out is set globally how is it possible that some commands write to gogo shell while, at the same time, others write to the java std-out? It should really be the same for all, no?
>>
>> Also, regarding your grep example: if you execute a command with grep (lb | grep "foo") but at the same time another thread writes to the System.out (say some console logging), this will also be "grepped" right?
>>
>> As System.setOut() is a native call, maybe it's a JVM problem? I'm on Oracle VM 1.7.0_60 on ARM v7.
>>
>> Regards Philipp
>>
>>
>>
>>
>>
>> On 21.01.2015 12:15, Derek Baum wrote:
>>> System.out is global within the JVM.
>>>
>>> The ThreadIO classes in gogo manage System.out (and System.in & System.err) on a per-thread basis using System.setOut(PrintStream out) etc.
>>>
>>> This allows commands to simply read and write System.in & System.out and work accordingly.
>>>
>>> For example:
>>>
>>> g! lb -s
>>>
>>> The lb command write to System.out is actually written to the console
>>>
>>> g! lb -s | grep gogo
>>>
>>> The lb command write to System.out is actually written to a pipe created by gogo.
>>>
>>>
>>> For this to work, no other bundles must be attempting a similar thing.
>>>
>>> i.e. if a bundle caches the value of System.out and later uses it in a call to System.setOut() then it could upset gogo’s ThreadIO mechanism.
>>>
>>>
>>> I suggest examining your problem command to see exactly how System.out is obtained and whether there are any calls to System.setOut().
>>>
>>> —
>>> Derek
>>>
>>>
>>>
>>>
>>>> On 21 Jan 2015, at 08:54, Bulu <bu...@romandie.com> wrote:
>>>>
>>>> Hello again
>>>>
>>>> Using the internal telnetd does not fix the problem, output of this one command is still going to the java exe std-out instead of the gogo shell.
>>>> But the command giving me problems is maybe not very standard:
>>>> For one, it executes in a separate thread (not the shell/gogo thread). This thread comes from a ExecutorService.newFixedThreadPool(1).
>>>> Second, the actual command (and its System.out.println) are implemented in a separate service (not the bundle which exports the gogo command).
>>>>
>>>> Could any of these create the problem as described?
>>>>
>>>> Regards Philipp
>>>>
>>>>
>>>>
>>>>
>>>> On 21.01.2015 09:12, Bulu wrote:
>>>>> Hello Derek
>>>>>>> I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes (rarely), certain of my commands do no longer output to the shell, instead the output is really going to the std-out of the java application. Note that at the same time, other of my own commands in the same bundle still work as expected and output to the gogo shell.
>>>>>>>
>>>>>> The Felix remote shell was designed to work before gogo was introduced.
>>>>>>
>>>>>> gogo has its own simple telnet daemon:
>>>>>>
>>>>>> Welcome to Apache Felix Gogo
>>>>>>
>>>>>> g! type telnetd
>>>>>> telnetd is void gogo:telnetd(String[])
>>>>>> true
>>>>>> g! telnetd -?
>>>>>> telnetd - start simple telnet server
>>>>>> Usage: telnetd [-i ip] [-p port] start | stop | status
>>>>>>    -i --ip=INTERFACE        listen interface (default=127.0.0.1)
>>>>>>    -p --port=PORT           listen port (default=2019)
>>>>>>    -? --help                show help
>>>>>> g! telnetd start
>>>>>> telnetd is running on 127.0.0.1:2019
>>>>>> g!
>>>>>>
>>>>> Thanks - I wasn't aware of that internal telnet daemon. I currently start the framework in non-interactive mode (gosh.args=--nointeractive) and rely on the telnet daemon to connect to the shell. How can I make gogo's telnetd start by itself?
>>>>>
>>>>> Regards Philipp
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


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


Re: Gogo output not always showing

Posted by Derek Baum <de...@baums.org.uk>.
I’ve thought more about this.

The gogo telnet daemon creates a new CommandSession, using the IO streams to the telnet client,
which has the expected result of re-directing IO to the telnet client.

gogo’s ThreadIO uses InheritableThreadLocal to manage the per-thread IO,
so that any new thread that inherits from the initial gogo thread will also have its IO redirected to the telnet client.


However, in your case, the command that writes to System.out is NOT run in a thread inherited from gogo, and thus appears on the default JVM console.


A possible solution is to change the signature of your command to include CommandSession as the first argument,
you can then use session.getConsole() to get the output stream used to create the session i.e. the telnet client.

However, doing this will mean that you can’t pipe the output of your command, as it will always write to the console.


—
Derek





> On 21 Jan 2015, at 11:42, Bulu <bu...@romandie.com> wrote:
> 
> My command is not doing anything fancy with System.out - just calling println(). Also I couldn't find any call to System.setOut() in my code.
> 
> If the System.out is set globally how is it possible that some commands write to gogo shell while, at the same time, others write to the java std-out? It should really be the same for all, no?
> 
> Also, regarding your grep example: if you execute a command with grep (lb | grep "foo") but at the same time another thread writes to the System.out (say some console logging), this will also be "grepped" right?
> 
> As System.setOut() is a native call, maybe it's a JVM problem? I'm on Oracle VM 1.7.0_60 on ARM v7.
> 
> Regards Philipp
> 
> 
> 
> 
> 
> On 21.01.2015 12:15, Derek Baum wrote:
>> System.out is global within the JVM.
>> 
>> The ThreadIO classes in gogo manage System.out (and System.in & System.err) on a per-thread basis using System.setOut(PrintStream out) etc.
>> 
>> This allows commands to simply read and write System.in & System.out and work accordingly.
>> 
>> For example:
>> 
>> g! lb -s
>> 
>> The lb command write to System.out is actually written to the console
>> 
>> g! lb -s | grep gogo
>> 
>> The lb command write to System.out is actually written to a pipe created by gogo.
>> 
>> 
>> For this to work, no other bundles must be attempting a similar thing.
>> 
>> i.e. if a bundle caches the value of System.out and later uses it in a call to System.setOut() then it could upset gogo’s ThreadIO mechanism.
>> 
>> 
>> I suggest examining your problem command to see exactly how System.out is obtained and whether there are any calls to System.setOut().
>> 
>> —
>> Derek
>> 
>> 
>> 
>> 
>>> On 21 Jan 2015, at 08:54, Bulu <bu...@romandie.com> wrote:
>>> 
>>> Hello again
>>> 
>>> Using the internal telnetd does not fix the problem, output of this one command is still going to the java exe std-out instead of the gogo shell.
>>> But the command giving me problems is maybe not very standard:
>>> For one, it executes in a separate thread (not the shell/gogo thread). This thread comes from a ExecutorService.newFixedThreadPool(1).
>>> Second, the actual command (and its System.out.println) are implemented in a separate service (not the bundle which exports the gogo command).
>>> 
>>> Could any of these create the problem as described?
>>> 
>>> Regards Philipp
>>> 
>>> 
>>> 
>>> 
>>> On 21.01.2015 09:12, Bulu wrote:
>>>> Hello Derek
>>>>>> I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes (rarely), certain of my commands do no longer output to the shell, instead the output is really going to the std-out of the java application. Note that at the same time, other of my own commands in the same bundle still work as expected and output to the gogo shell.
>>>>>> 
>>>>> The Felix remote shell was designed to work before gogo was introduced.
>>>>> 
>>>>> gogo has its own simple telnet daemon:
>>>>> 
>>>>> Welcome to Apache Felix Gogo
>>>>> 
>>>>> g! type telnetd
>>>>> telnetd is void gogo:telnetd(String[])
>>>>> true
>>>>> g! telnetd -?
>>>>> telnetd - start simple telnet server
>>>>> Usage: telnetd [-i ip] [-p port] start | stop | status
>>>>>   -i --ip=INTERFACE        listen interface (default=127.0.0.1)
>>>>>   -p --port=PORT           listen port (default=2019)
>>>>>   -? --help                show help
>>>>> g! telnetd start
>>>>> telnetd is running on 127.0.0.1:2019
>>>>> g!
>>>>> 
>>>> Thanks - I wasn't aware of that internal telnet daemon. I currently start the framework in non-interactive mode (gosh.args=--nointeractive) and rely on the telnet daemon to connect to the shell. How can I make gogo's telnetd start by itself?
>>>> 
>>>> Regards Philipp
>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Gogo output not always showing

Posted by Bulu <bu...@romandie.com>.
My command is not doing anything fancy with System.out - just calling 
println(). Also I couldn't find any call to System.setOut() in my code.

If the System.out is set globally how is it possible that some commands 
write to gogo shell while, at the same time, others write to the java 
std-out? It should really be the same for all, no?

Also, regarding your grep example: if you execute a command with grep 
(lb | grep "foo") but at the same time another thread writes to the 
System.out (say some console logging), this will also be "grepped" right?

As System.setOut() is a native call, maybe it's a JVM problem? I'm on 
Oracle VM 1.7.0_60 on ARM v7.

Regards Philipp





On 21.01.2015 12:15, Derek Baum wrote:
> System.out is global within the JVM.
>
> The ThreadIO classes in gogo manage System.out (and System.in & System.err) on a per-thread basis using System.setOut(PrintStream out) etc.
>
> This allows commands to simply read and write System.in & System.out and work accordingly.
>
> For example:
>
> g! lb -s
>
> The lb command write to System.out is actually written to the console
>
> g! lb -s | grep gogo
>
> The lb command write to System.out is actually written to a pipe created by gogo.
>
>
> For this to work, no other bundles must be attempting a similar thing.
>
> i.e. if a bundle caches the value of System.out and later uses it in a call to System.setOut() then it could upset gogo’s ThreadIO mechanism.
>
>
> I suggest examining your problem command to see exactly how System.out is obtained and whether there are any calls to System.setOut().
>
> —
> Derek
>
>
>
>
>> On 21 Jan 2015, at 08:54, Bulu <bu...@romandie.com> wrote:
>>
>> Hello again
>>
>> Using the internal telnetd does not fix the problem, output of this one command is still going to the java exe std-out instead of the gogo shell.
>> But the command giving me problems is maybe not very standard:
>> For one, it executes in a separate thread (not the shell/gogo thread). This thread comes from a ExecutorService.newFixedThreadPool(1).
>> Second, the actual command (and its System.out.println) are implemented in a separate service (not the bundle which exports the gogo command).
>>
>> Could any of these create the problem as described?
>>
>> Regards Philipp
>>
>>
>>
>>
>> On 21.01.2015 09:12, Bulu wrote:
>>> Hello Derek
>>>>> I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes (rarely), certain of my commands do no longer output to the shell, instead the output is really going to the std-out of the java application. Note that at the same time, other of my own commands in the same bundle still work as expected and output to the gogo shell.
>>>>>
>>>> The Felix remote shell was designed to work before gogo was introduced.
>>>>
>>>> gogo has its own simple telnet daemon:
>>>>
>>>> Welcome to Apache Felix Gogo
>>>>
>>>> g! type telnetd
>>>> telnetd is void gogo:telnetd(String[])
>>>> true
>>>> g! telnetd -?
>>>> telnetd - start simple telnet server
>>>> Usage: telnetd [-i ip] [-p port] start | stop | status
>>>>    -i --ip=INTERFACE        listen interface (default=127.0.0.1)
>>>>    -p --port=PORT           listen port (default=2019)
>>>>    -? --help                show help
>>>> g! telnetd start
>>>> telnetd is running on 127.0.0.1:2019
>>>> g!
>>>>
>>> Thanks - I wasn't aware of that internal telnet daemon. I currently start the framework in non-interactive mode (gosh.args=--nointeractive) and rely on the telnet daemon to connect to the shell. How can I make gogo's telnetd start by itself?
>>>
>>> Regards Philipp
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>


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


Re: Gogo output not always showing

Posted by Derek Baum <de...@baums.org.uk>.
System.out is global within the JVM.

The ThreadIO classes in gogo manage System.out (and System.in & System.err) on a per-thread basis using System.setOut(PrintStream out) etc.

This allows commands to simply read and write System.in & System.out and work accordingly.

For example:

g! lb -s

The lb command write to System.out is actually written to the console

g! lb -s | grep gogo

The lb command write to System.out is actually written to a pipe created by gogo.


For this to work, no other bundles must be attempting a similar thing.

i.e. if a bundle caches the value of System.out and later uses it in a call to System.setOut() then it could upset gogo’s ThreadIO mechanism.


I suggest examining your problem command to see exactly how System.out is obtained and whether there are any calls to System.setOut().

—
Derek




> On 21 Jan 2015, at 08:54, Bulu <bu...@romandie.com> wrote:
> 
> Hello again
> 
> Using the internal telnetd does not fix the problem, output of this one command is still going to the java exe std-out instead of the gogo shell.
> But the command giving me problems is maybe not very standard:
> For one, it executes in a separate thread (not the shell/gogo thread). This thread comes from a ExecutorService.newFixedThreadPool(1).
> Second, the actual command (and its System.out.println) are implemented in a separate service (not the bundle which exports the gogo command).
> 
> Could any of these create the problem as described?
> 
> Regards Philipp
> 
> 
> 
> 
> On 21.01.2015 09:12, Bulu wrote:
>> Hello Derek
>>>> I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes (rarely), certain of my commands do no longer output to the shell, instead the output is really going to the std-out of the java application. Note that at the same time, other of my own commands in the same bundle still work as expected and output to the gogo shell.
>>>> 
>>> The Felix remote shell was designed to work before gogo was introduced.
>>> 
>>> gogo has its own simple telnet daemon:
>>> 
>>> Welcome to Apache Felix Gogo
>>> 
>>> g! type telnetd
>>> telnetd is void gogo:telnetd(String[])
>>> true
>>> g! telnetd -?
>>> telnetd - start simple telnet server
>>> Usage: telnetd [-i ip] [-p port] start | stop | status
>>>   -i --ip=INTERFACE        listen interface (default=127.0.0.1)
>>>   -p --port=PORT           listen port (default=2019)
>>>   -? --help                show help
>>> g! telnetd start
>>> telnetd is running on 127.0.0.1:2019
>>> g!
>>> 
>> Thanks - I wasn't aware of that internal telnet daemon. I currently start the framework in non-interactive mode (gosh.args=--nointeractive) and rely on the telnet daemon to connect to the shell. How can I make gogo's telnetd start by itself?
>> 
>> Regards Philipp
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


Re: Gogo output not always showing

Posted by Bulu <bu...@romandie.com>.
Hello again

Using the internal telnetd does not fix the problem, output of this one 
command is still going to the java exe std-out instead of the gogo shell.
But the command giving me problems is maybe not very standard:
For one, it executes in a separate thread (not the shell/gogo thread). 
This thread comes from a ExecutorService.newFixedThreadPool(1).
Second, the actual command (and its System.out.println) are implemented 
in a separate service (not the bundle which exports the gogo command).

Could any of these create the problem as described?

Regards Philipp




On 21.01.2015 09:12, Bulu wrote:
> Hello Derek
>>> I then access gogo through telnet (Felix Remote Shell 1.1.2). 
>>> Sometimes (rarely), certain of my commands do no longer output to 
>>> the shell, instead the output is really going to the std-out of the 
>>> java application. Note that at the same time, other of my own 
>>> commands in the same bundle still work as expected and output to the 
>>> gogo shell.
>>>
>> The Felix remote shell was designed to work before gogo was introduced.
>>
>> gogo has its own simple telnet daemon:
>>
>> Welcome to Apache Felix Gogo
>>
>> g! type telnetd
>> telnetd is void gogo:telnetd(String[])
>> true
>> g! telnetd -?
>> telnetd - start simple telnet server
>> Usage: telnetd [-i ip] [-p port] start | stop | status
>>    -i --ip=INTERFACE        listen interface (default=127.0.0.1)
>>    -p --port=PORT           listen port (default=2019)
>>    -? --help                show help
>> g! telnetd start
>> telnetd is running on 127.0.0.1:2019
>> g!
>>
> Thanks - I wasn't aware of that internal telnet daemon. I currently 
> start the framework in non-interactive mode 
> (gosh.args=--nointeractive) and rely on the telnet daemon to connect 
> to the shell. How can I make gogo's telnetd start by itself?
>
> Regards Philipp
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


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


Re: Gogo output not always showing

Posted by Bulu <bu...@romandie.com>.
Hello Derek
>> I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes (rarely), certain of my commands do no longer output to the shell, instead the output is really going to the std-out of the java application. Note that at the same time, other of my own commands in the same bundle still work as expected and output to the gogo shell.
>>
> The Felix remote shell was designed to work before gogo was introduced.
>
> gogo has its own simple telnet daemon:
>
> Welcome to Apache Felix Gogo
>
> g! type telnetd
> telnetd is void gogo:telnetd(String[])
> true
> g! telnetd -?
> telnetd - start simple telnet server
> Usage: telnetd [-i ip] [-p port] start | stop | status
>    -i --ip=INTERFACE        listen interface (default=127.0.0.1)
>    -p --port=PORT           listen port (default=2019)
>    -? --help                show help
> g! telnetd start
> telnetd is running on 127.0.0.1:2019
> g!
>
Thanks - I wasn't aware of that internal telnet daemon. I currently 
start the framework in non-interactive mode (gosh.args=--nointeractive) 
and rely on the telnet daemon to connect to the shell. How can I make 
gogo's telnetd start by itself?

Regards Philipp



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


Re: Gogo output not always showing

Posted by Derek Baum <de...@baums.org.uk>.
> On 20 Jan 2015, at 15:24, Bulu <bu...@romandie.com> wrote:
> 
> Hello
> 
> In my gogo commands, I use simple System.println(...) calls to output things to the gogo shell. (is that the correct way?)

Yes, goo is designed so commands can simply use System.out.println(…)



> 
> I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes (rarely), certain of my commands do no longer output to the shell, instead the output is really going to the std-out of the java application. Note that at the same time, other of my own commands in the same bundle still work as expected and output to the gogo shell.
> 

The Felix remote shell was designed to work before gogo was introduced.

gogo has its own simple telnet daemon:

Welcome to Apache Felix Gogo

g! type telnetd
telnetd is void gogo:telnetd(String[])
true
g! telnetd -?
telnetd - start simple telnet server
Usage: telnetd [-i ip] [-p port] start | stop | status
  -i --ip=INTERFACE        listen interface (default=127.0.0.1)
  -p --port=PORT           listen port (default=2019)
  -? --help                show help
g! telnetd start
telnetd is running on 127.0.0.1:2019
g!


—
Derek

Gogo output not always showing

Posted by Bulu <bu...@romandie.com>.
Hello

In my gogo commands, I use simple System.println(...) calls to output 
things to the gogo shell. (is that the correct way?)

I then access gogo through telnet (Felix Remote Shell 1.1.2). Sometimes 
(rarely), certain of my commands do no longer output to the shell, 
instead the output is really going to the std-out of the java 
application. Note that at the same time, other of my own commands in the 
same bundle still work as expected and output to the gogo shell.

Stopping and restarting the bundle which exports those commands does not 
fix the problem.

What could cause this behavior and how should I fix it?

Thanks & regards
   Philipp

Versions:
     0|Active     |    0|System Bundle (4.2.1)
     1|Active     |    1|Apache Felix Gogo Command (0.14.0)
     2|Active     |    1|Apache Felix Gogo Runtime (0.12.1)
     3|Active     |    1|Apache Felix Gogo Shell (0.10.0)
     4|Active     |    1|Apache Felix Remote Shell (1.1.2)


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


Re: Getting a reference to a declarative service

Posted by Artem Zhirkov <az...@develdynamic.com>.
I managed to resolve this by running my grails application (which works 
as an osgi container) without dynamic code reloading feature, which 
seems to rely on spring loaded.

There are no dependencies on anything remotely related to spring in my 
bundles.

On 20.01.2015 21:43, Neil Bartlett wrote:
> Felix SCR does not interfere with Spring loading. SCR has nothing to do with Spring. This error has come from your own class in your bundle… by installing SCR you have now for the first time loaded the class (or rather, attempted to load it), so now you see the problem for the first time.
>
> The stack trace suggests that you have a dependency on the ‘org.springsource.loaded.ri’ package, and therefore need to list it in your Import-Package statement.
>
> Regards,
> Neil
>
>> On 20 Jan 2015, at 18:27, Artem Zhirkov <az...@develdynamic.com> wrote:
>>
>> I installed felix scr bundle into my host osgi application and tried to obtain a list of active services by visiting a controller of my spring application which calls osgi code and it threw the following error:
>>
>> | Error java.lang.NoClassDefFoundError: org/springsource/loaded/ri/ReflectiveInterceptor
>> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:253)
>> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:127)
>> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:871)
>> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:838)
>> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:777)
>> | Error     at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:320)
>> | Error     at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:231)
>> | Error     at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:327)
>>
>> Full stack trace available at http://paste.ubuntu.com/9796839/
>>
>>
>> It seems like felix scr interferes with spring loaded? Is it possible to avoid this?
>>
>>
>> Thanks
>>
>> On 20.01.2015 18:08, Artem Zhirkov wrote:
>>> Neil,
>>> bundle is active, but I dont have any DS implementation bundle installed...I thought the framework itself contains the implementation.
>>>
>>> On 01/20/2015 03:19 PM, Neil Bartlett wrote:
>>>> Dirk: I don’t think Artem was asking about activation of the component, he has a problem with service registration. So whether the component is immediate or delayed seems to be irrelevant.
>>>>
>>>> Artem: there are a few things you need to check. Is your bundle active? Do you have a DS implementation bundle (such as org.apache.felix.scr, or org.eclipse.equinox.ds) installed and active?
>>>>
>>>> Regards,
>>>> Neil
>>>>
>>>>
>>>>> On 20 Jan 2015, at 11:09, Dirk Rudolph <di...@netcentric.biz> wrote:
>>>>>
>>>>> Try to add immediate=“true” to your component definition. This should result in something like
>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>>>>    <scr:component immediate=“true” name="ru.multicabinet.gateway.ExampleDS">
>>>>>>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>>>>        <service servicefactory="false">
>>>>>>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>>>>        </service>
>>>>>>        <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>>>>>    </scr:component>
>>>>>> </components>
>>>>> and causes the component to be started immediately after it has been registered.
>>>>>
>>>>> Kind regards,
>>>>> Dirk Rudolph | Senior Software Engineer
>>>>>
>>>>> Netcentric AG
>>>>>
>>>>> M: +41 79 642 37 11
>>>>> D: +49 174 966 84 34
>>>>>
>>>>> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
>>>>>> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I want to include more than one service into a bundle, so it seems like I have to make a use of declarative services.
>>>>>>
>>>>>> I'm building a test bundle with maven + maven-bundle-plugin and generating the ds descriptor with maven-scr-plugin, so it looks like this:
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>>>>    <scr:component name="ru.multicabinet.gateway.ExampleDS">
>>>>>>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>>>>        <service servicefactory="false">
>>>>>>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>>>>        </service>
>>>>>>        <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>>>>>    </scr:component>
>>>>>> </components>
>>>>>>
>>>>>> After installing the test bundle into my osgi container I'm trying to get a list of all services in the test bundle by calling bundle.getRegisteredServices(), but it'd always return null.
>>>>>>
>>>>>> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a reference to ds service?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>



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


Re: Getting a reference to a declarative service

Posted by Neil Bartlett <nj...@gmail.com>.
Felix SCR does not interfere with Spring loading. SCR has nothing to do with Spring. This error has come from your own class in your bundle… by installing SCR you have now for the first time loaded the class (or rather, attempted to load it), so now you see the problem for the first time.

The stack trace suggests that you have a dependency on the ‘org.springsource.loaded.ri’ package, and therefore need to list it in your Import-Package statement.

Regards,
Neil

> On 20 Jan 2015, at 18:27, Artem Zhirkov <az...@develdynamic.com> wrote:
> 
> I installed felix scr bundle into my host osgi application and tried to obtain a list of active services by visiting a controller of my spring application which calls osgi code and it threw the following error:
> 
> | Error java.lang.NoClassDefFoundError: org/springsource/loaded/ri/ReflectiveInterceptor
> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:253)
> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:127)
> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:871)
> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:838)
> | Error     at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:777)
> | Error     at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:320)
> | Error     at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:231)
> | Error     at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:327)
> 
> Full stack trace available at http://paste.ubuntu.com/9796839/
> 
> 
> It seems like felix scr interferes with spring loaded? Is it possible to avoid this?
> 
> 
> Thanks
> 
> On 20.01.2015 18:08, Artem Zhirkov wrote:
>> Neil,
>> bundle is active, but I dont have any DS implementation bundle installed...I thought the framework itself contains the implementation.
>> 
>> On 01/20/2015 03:19 PM, Neil Bartlett wrote:
>>> Dirk: I don’t think Artem was asking about activation of the component, he has a problem with service registration. So whether the component is immediate or delayed seems to be irrelevant.
>>> 
>>> Artem: there are a few things you need to check. Is your bundle active? Do you have a DS implementation bundle (such as org.apache.felix.scr, or org.eclipse.equinox.ds) installed and active?
>>> 
>>> Regards,
>>> Neil
>>> 
>>> 
>>>> On 20 Jan 2015, at 11:09, Dirk Rudolph <di...@netcentric.biz> wrote:
>>>> 
>>>> Try to add immediate=“true” to your component definition. This should result in something like
>>>> 
>>>>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>>>   <scr:component immediate=“true” name="ru.multicabinet.gateway.ExampleDS">
>>>>>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>>>       <service servicefactory="false">
>>>>>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>>>       </service>
>>>>>       <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>>>>   </scr:component>
>>>>> </components>
>>>> and causes the component to be started immediately after it has been registered.
>>>> 
>>>> Kind regards,
>>>> Dirk Rudolph | Senior Software Engineer
>>>> 
>>>> Netcentric AG
>>>> 
>>>> M: +41 79 642 37 11
>>>> D: +49 174 966 84 34
>>>> 
>>>> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
>>>>> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
>>>>> 
>>>>> Hello,
>>>>> 
>>>>> I want to include more than one service into a bundle, so it seems like I have to make a use of declarative services.
>>>>> 
>>>>> I'm building a test bundle with maven + maven-bundle-plugin and generating the ds descriptor with maven-scr-plugin, so it looks like this:
>>>>> 
>>>>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>>>   <scr:component name="ru.multicabinet.gateway.ExampleDS">
>>>>>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>>>       <service servicefactory="false">
>>>>>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>>>       </service>
>>>>>       <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>>>>   </scr:component>
>>>>> </components>
>>>>> 
>>>>> After installing the test bundle into my osgi container I'm trying to get a list of all services in the test bundle by calling bundle.getRegisteredServices(), but it'd always return null.
>>>>> 
>>>>> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a reference to ds service?
>>>>> 
>>>>> Thanks
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Getting a reference to a declarative service

Posted by Artem Zhirkov <az...@develdynamic.com>.
I installed felix scr bundle into my host osgi application and tried to 
obtain a list of active services by visiting a controller of my spring 
application which calls osgi code and it threw the following error:

| Error java.lang.NoClassDefFoundError: 
org/springsource/loaded/ri/ReflectiveInterceptor
| Error     at 
org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:253)
| Error     at 
org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:127)
| Error     at 
org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:871)
| Error     at 
org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:838)
| Error     at 
org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:777)
| Error     at 
org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:320)
| Error     at 
org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:231)
| Error     at 
org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:327)

Full stack trace available at http://paste.ubuntu.com/9796839/


It seems like felix scr interferes with spring loaded? Is it possible to 
avoid this?


Thanks

On 20.01.2015 18:08, Artem Zhirkov wrote:
> Neil,
> bundle is active, but I dont have any DS implementation bundle 
> installed...I thought the framework itself contains the implementation.
>
> On 01/20/2015 03:19 PM, Neil Bartlett wrote:
>> Dirk: I don’t think Artem was asking about activation of the 
>> component, he has a problem with service registration. So whether the 
>> component is immediate or delayed seems to be irrelevant.
>>
>> Artem: there are a few things you need to check. Is your bundle 
>> active? Do you have a DS implementation bundle (such as 
>> org.apache.felix.scr, or org.eclipse.equinox.ds) installed and active?
>>
>> Regards,
>> Neil
>>
>>
>>> On 20 Jan 2015, at 11:09, Dirk Rudolph <di...@netcentric.biz> 
>>> wrote:
>>>
>>> Try to add immediate=“true” to your component definition. This 
>>> should result in something like
>>>
>>>> <?xml version="1.0" encoding="UTF-8"?><components 
>>>> xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>>    <scr:component immediate=“true” 
>>>> name="ru.multicabinet.gateway.ExampleDS">
>>>>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>>        <service servicefactory="false">
>>>>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>>        </service>
>>>>        <property name="service.pid" 
>>>> value="ru.multicabinet.gateway.ExampleDS"/>
>>>>    </scr:component>
>>>> </components>
>>> and causes the component to be started immediately after it has been 
>>> registered.
>>>
>>> Kind regards,
>>> Dirk Rudolph | Senior Software Engineer
>>>
>>> Netcentric AG
>>>
>>> M: +41 79 642 37 11
>>> D: +49 174 966 84 34
>>>
>>> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | 
>>> www.netcentric.biz <http://www.netcentric.biz/>
>>>> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I want to include more than one service into a bundle, so it seems 
>>>> like I have to make a use of declarative services.
>>>>
>>>> I'm building a test bundle with maven + maven-bundle-plugin and 
>>>> generating the ds descriptor with maven-scr-plugin, so it looks 
>>>> like this:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?><components 
>>>> xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>>    <scr:component name="ru.multicabinet.gateway.ExampleDS">
>>>>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>>        <service servicefactory="false">
>>>>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>>        </service>
>>>>        <property name="service.pid" 
>>>> value="ru.multicabinet.gateway.ExampleDS"/>
>>>>    </scr:component>
>>>> </components>
>>>>
>>>> After installing the test bundle into my osgi container I'm trying 
>>>> to get a list of all services in the test bundle by calling 
>>>> bundle.getRegisteredServices(), but it'd always return null.
>>>>
>>>> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain 
>>>> a reference to ds service?
>>>>
>>>> Thanks
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>



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


Re: Getting a reference to a declarative service

Posted by Artem Zhirkov <az...@develdynamic.com>.
Neil,
bundle is active, but I dont have any DS implementation bundle 
installed...I thought the framework itself contains the implementation.

On 01/20/2015 03:19 PM, Neil Bartlett wrote:
> Dirk: I don’t think Artem was asking about activation of the component, he has a problem with service registration. So whether the component is immediate or delayed seems to be irrelevant.
>
> Artem: there are a few things you need to check. Is your bundle active? Do you have a DS implementation bundle (such as org.apache.felix.scr, or org.eclipse.equinox.ds) installed and active?
>
> Regards,
> Neil
>
>
>> On 20 Jan 2015, at 11:09, Dirk Rudolph <di...@netcentric.biz> wrote:
>>
>> Try to add immediate=“true” to your component definition. This should result in something like
>>
>>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>    <scr:component immediate=“true” name="ru.multicabinet.gateway.ExampleDS">
>>>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>        <service servicefactory="false">
>>>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>        </service>
>>>        <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>>    </scr:component>
>>> </components>
>> and causes the component to be started immediately after it has been registered.
>>
>> Kind regards,
>> Dirk Rudolph | Senior Software Engineer
>>
>> Netcentric AG
>>
>> M: +41 79 642 37 11
>> D: +49 174 966 84 34
>>
>> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
>>> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
>>>
>>> Hello,
>>>
>>> I want to include more than one service into a bundle, so it seems like I have to make a use of declarative services.
>>>
>>> I'm building a test bundle with maven + maven-bundle-plugin and generating the ds descriptor with maven-scr-plugin, so it looks like this:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>>    <scr:component name="ru.multicabinet.gateway.ExampleDS">
>>>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>>        <service servicefactory="false">
>>>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>>        </service>
>>>        <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>>    </scr:component>
>>> </components>
>>>
>>> After installing the test bundle into my osgi container I'm trying to get a list of all services in the test bundle by calling bundle.getRegisteredServices(), but it'd always return null.
>>>
>>> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a reference to ds service?
>>>
>>> Thanks
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>



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


Re: Getting a reference to a declarative service

Posted by Dirk Rudolph <di...@netcentric.biz>.
Neil: You are right. The service gets registered also when the Component is
not yet active.

(See OSGI Enterprise Spec R4 112.2.2/112.2.3)

On Tue, Jan 20, 2015 at 1:39 PM, Milen Dyankov <mi...@gmail.com>
wrote:

> Also make sure that apart from generating the descriptor(s) it adds the
> correct 'Service-Component' header in your manifest. I recall some problems
> when both 'maven-bundle-plugin' and 'maven-scr-plugin' are used together. I
> personally try to avoid using 'maven-scr-plugin' and add
> '<_dsannotations>*</_dsannotations>' to 'maven-bundle-plugin' configuration
> instead!
>
> Best,
> Milen
>
> On Tue, Jan 20, 2015 at 1:19 PM, Neil Bartlett <nj...@gmail.com>
> wrote:
>
> > Dirk: I don’t think Artem was asking about activation of the component,
> he
> > has a problem with service registration. So whether the component is
> > immediate or delayed seems to be irrelevant.
> >
> > Artem: there are a few things you need to check. Is your bundle active?
> Do
> > you have a DS implementation bundle (such as org.apache.felix.scr, or
> > org.eclipse.equinox.ds) installed and active?
> >
> > Regards,
> > Neil
> >
> >
> > > On 20 Jan 2015, at 11:09, Dirk Rudolph <di...@netcentric.biz>
> > wrote:
> > >
> > > Try to add immediate=“true” to your component definition. This should
> > result in something like
> > >
> > >> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="
> > http://www.osgi.org/xmlns/scr/v1.0.0">
> > >>   <scr:component immediate=“true”
> > name="ru.multicabinet.gateway.ExampleDS">
> > >>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
> > >>       <service servicefactory="false">
> > >>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
> > >>       </service>
> > >>       <property name="service.pid"
> > value="ru.multicabinet.gateway.ExampleDS"/>
> > >>   </scr:component>
> > >> </components>
> > >
> > > and causes the component to be started immediately after it has been
> > registered.
> > >
> > > Kind regards,
> > > Dirk Rudolph | Senior Software Engineer
> > >
> > > Netcentric AG
> > >
> > > M: +41 79 642 37 11
> > > D: +49 174 966 84 34
> > >
> > > dirk.rudolph@netcentric.biz <ma...@netcentric.biz> |
> > www.netcentric.biz <http://www.netcentric.biz/>
> > >> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
> > >>
> > >> Hello,
> > >>
> > >> I want to include more than one service into a bundle, so it seems
> like
> > I have to make a use of declarative services.
> > >>
> > >> I'm building a test bundle with maven + maven-bundle-plugin and
> > generating the ds descriptor with maven-scr-plugin, so it looks like
> this:
> > >>
> > >> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="
> > http://www.osgi.org/xmlns/scr/v1.0.0">
> > >>   <scr:component name="ru.multicabinet.gateway.ExampleDS">
> > >>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
> > >>       <service servicefactory="false">
> > >>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
> > >>       </service>
> > >>       <property name="service.pid"
> > value="ru.multicabinet.gateway.ExampleDS"/>
> > >>   </scr:component>
> > >> </components>
> > >>
> > >> After installing the test bundle into my osgi container I'm trying to
> > get a list of all services in the test bundle by calling
> > bundle.getRegisteredServices(), but it'd always return null.
> > >>
> > >> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a
> > reference to ds service?
> > >>
> > >> Thanks
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > >> For additional commands, e-mail: users-help@felix.apache.org
> > >>
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >
>
>
> --
> http://about.me/milen
>



-- 

Dirk Rudolph | Senior Software Engineer

Netcentric AG

M: +41 79 642 37 11
D: +49 174 966 84 34

dirk.rudolph@netcentric.biz | www.netcentric.biz

Re: Getting a reference to a declarative service

Posted by Milen Dyankov <mi...@gmail.com>.
Also make sure that apart from generating the descriptor(s) it adds the
correct 'Service-Component' header in your manifest. I recall some problems
when both 'maven-bundle-plugin' and 'maven-scr-plugin' are used together. I
personally try to avoid using 'maven-scr-plugin' and add
'<_dsannotations>*</_dsannotations>' to 'maven-bundle-plugin' configuration
instead!

Best,
Milen

On Tue, Jan 20, 2015 at 1:19 PM, Neil Bartlett <nj...@gmail.com> wrote:

> Dirk: I don’t think Artem was asking about activation of the component, he
> has a problem with service registration. So whether the component is
> immediate or delayed seems to be irrelevant.
>
> Artem: there are a few things you need to check. Is your bundle active? Do
> you have a DS implementation bundle (such as org.apache.felix.scr, or
> org.eclipse.equinox.ds) installed and active?
>
> Regards,
> Neil
>
>
> > On 20 Jan 2015, at 11:09, Dirk Rudolph <di...@netcentric.biz>
> wrote:
> >
> > Try to add immediate=“true” to your component definition. This should
> result in something like
> >
> >> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="
> http://www.osgi.org/xmlns/scr/v1.0.0">
> >>   <scr:component immediate=“true”
> name="ru.multicabinet.gateway.ExampleDS">
> >>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
> >>       <service servicefactory="false">
> >>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
> >>       </service>
> >>       <property name="service.pid"
> value="ru.multicabinet.gateway.ExampleDS"/>
> >>   </scr:component>
> >> </components>
> >
> > and causes the component to be started immediately after it has been
> registered.
> >
> > Kind regards,
> > Dirk Rudolph | Senior Software Engineer
> >
> > Netcentric AG
> >
> > M: +41 79 642 37 11
> > D: +49 174 966 84 34
> >
> > dirk.rudolph@netcentric.biz <ma...@netcentric.biz> |
> www.netcentric.biz <http://www.netcentric.biz/>
> >> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
> >>
> >> Hello,
> >>
> >> I want to include more than one service into a bundle, so it seems like
> I have to make a use of declarative services.
> >>
> >> I'm building a test bundle with maven + maven-bundle-plugin and
> generating the ds descriptor with maven-scr-plugin, so it looks like this:
> >>
> >> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="
> http://www.osgi.org/xmlns/scr/v1.0.0">
> >>   <scr:component name="ru.multicabinet.gateway.ExampleDS">
> >>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
> >>       <service servicefactory="false">
> >>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
> >>       </service>
> >>       <property name="service.pid"
> value="ru.multicabinet.gateway.ExampleDS"/>
> >>   </scr:component>
> >> </components>
> >>
> >> After installing the test bundle into my osgi container I'm trying to
> get a list of all services in the test bundle by calling
> bundle.getRegisteredServices(), but it'd always return null.
> >>
> >> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a
> reference to ds service?
> >>
> >> Thanks
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >> For additional commands, e-mail: users-help@felix.apache.org
> >>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
http://about.me/milen

Re: Getting a reference to a declarative service

Posted by Neil Bartlett <nj...@gmail.com>.
Dirk: I don’t think Artem was asking about activation of the component, he has a problem with service registration. So whether the component is immediate or delayed seems to be irrelevant.

Artem: there are a few things you need to check. Is your bundle active? Do you have a DS implementation bundle (such as org.apache.felix.scr, or org.eclipse.equinox.ds) installed and active?

Regards,
Neil


> On 20 Jan 2015, at 11:09, Dirk Rudolph <di...@netcentric.biz> wrote:
> 
> Try to add immediate=“true” to your component definition. This should result in something like
> 
>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>   <scr:component immediate=“true” name="ru.multicabinet.gateway.ExampleDS">
>>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>       <service servicefactory="false">
>>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>       </service>
>>       <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>   </scr:component>
>> </components>
> 
> and causes the component to be started immediately after it has been registered.
> 
> Kind regards,
> Dirk Rudolph | Senior Software Engineer
> 
> Netcentric AG
> 
> M: +41 79 642 37 11
> D: +49 174 966 84 34
> 
> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
>> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
>> 
>> Hello,
>> 
>> I want to include more than one service into a bundle, so it seems like I have to make a use of declarative services.
>> 
>> I'm building a test bundle with maven + maven-bundle-plugin and generating the ds descriptor with maven-scr-plugin, so it looks like this:
>> 
>> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>>   <scr:component name="ru.multicabinet.gateway.ExampleDS">
>>       <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>>       <service servicefactory="false">
>>           <provide interface="ru.multicabinet.gateway.SimpleI"/>
>>       </service>
>>       <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>>   </scr:component>
>> </components>
>> 
>> After installing the test bundle into my osgi container I'm trying to get a list of all services in the test bundle by calling bundle.getRegisteredServices(), but it'd always return null.
>> 
>> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a reference to ds service?
>> 
>> Thanks
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 


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


Re: Getting a reference to a declarative service

Posted by Dirk Rudolph <di...@netcentric.biz>.
Try to add immediate=“true” to your component definition. This should result in something like

> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>    <scr:component immediate=“true” name="ru.multicabinet.gateway.ExampleDS">
>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>        <service servicefactory="false">
>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>        </service>
>        <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>    </scr:component>
> </components>

and causes the component to be started immediately after it has been registered.

Kind regards,
Dirk Rudolph | Senior Software Engineer

Netcentric AG

M: +41 79 642 37 11
D: +49 174 966 84 34

dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
> On 20 Jan 2015, at 11:53, Artem Zhirkov <az...@develdynamic.com> wrote:
> 
> Hello,
> 
> I want to include more than one service into a bundle, so it seems like I have to make a use of declarative services.
> 
> I'm building a test bundle with maven + maven-bundle-plugin and generating the ds descriptor with maven-scr-plugin, so it looks like this:
> 
> <?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>    <scr:component name="ru.multicabinet.gateway.ExampleDS">
>        <implementation class="ru.multicabinet.gateway.ExampleDS"/>
>        <service servicefactory="false">
>            <provide interface="ru.multicabinet.gateway.SimpleI"/>
>        </service>
>        <property name="service.pid" value="ru.multicabinet.gateway.ExampleDS"/>
>    </scr:component>
> </components>
> 
> After installing the test bundle into my osgi container I'm trying to get a list of all services in the test bundle by calling bundle.getRegisteredServices(), but it'd always return null.
> 
> What I'm doing wrong? Maybe  I should use ServiceTracker to obtain a reference to ds service?
> 
> Thanks
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>