You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "Streeton, Matt" <ST...@NV.DOE.GOV> on 2008/07/01 20:23:31 UTC

Declarative Service threading issue

I am new at using declarative services to create components and have those
components activated by the SCR. In order to keep my activate functions
brief, I spawn a thread from one of my component¹s activate method (which
has some time consuming processes). For some reason, that thread doesn¹t
seem to actually start until I interact with the Felix console. For example,
Felix starts up, all the bundles are started and activated properly. I don¹t
see the thread activity, however, until I hit the enter key inside the Felix
console. Is there any reason a thread wouldn¹t actually start on its own?

For clarification, I have included my activate method for my component
(which implements Runnable):

    protected void activate(ComponentContext ctxt)
    {
        componentContext = ctxt;

        thisThread = new Thread(this);
        thisThread.start();
    }

Thanks for any help, this has been puzzling!
- Matt

Re: Declarative Service threading issue

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Matt,

This is an interesting observation. Are you sure your component has 
really be activated ? For example, if your component happens to be 
delayed (which is e.g. the case if the immediate attribute is set to 
false or if the immediate attribute is not set at all and a service is 
declared), the activate method is only called when the service provided 
by the component is first retrieved.

Can you provide us with your component declaration for this case ?

Regards
Felix

Streeton, Matt schrieb:
> I am new at using declarative services to create components and have those
> components activated by the SCR. In order to keep my activate functions
> brief, I spawn a thread from one of my component¹s activate method (which
> has some time consuming processes). For some reason, that thread doesn¹t
> seem to actually start until I interact with the Felix console. For example,
> Felix starts up, all the bundles are started and activated properly. I don¹t
> see the thread activity, however, until I hit the enter key inside the Felix
> console. Is there any reason a thread wouldn¹t actually start on its own?
> 
> For clarification, I have included my activate method for my component
> (which implements Runnable):
> 
>     protected void activate(ComponentContext ctxt)
>     {
>         componentContext = ctxt;
> 
>         thisThread = new Thread(this);
>         thisThread.start();
>     }
> 
> Thanks for any help, this has been puzzling!
> - Matt
> 


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


Re: Declarative Service threading issue

Posted by Patrick Forhan <fe...@muddyhorse.com>.
Are you using Eclipse to run Felix by any chance?  We had lots and
lots of strange problems just like yours when we did.  We would have
to hit enter or ps at about 10 different points in our startup.  We
eventually gave up and always run from the command line.

If you need to debug, set up remote debugging like so:

java -Xms512M -Xmx512M
-Dfelix.config.properties=file:conf/my-config.properties -Xdebug
-Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
-jar felixbin\felix.jar

And connect a debugger to 8787.

Pat.


-- 
Defy mediocrity.

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