You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Justin Stoecker <js...@gmail.com> on 2011/06/22 00:31:19 UTC

Closing felix when bundle/service is finished

Hi,

I have a "statistics" bundle that provides the service of reading a
file, doing some calculations, and writing a new file. Ideally, I
would like to write a small command-line program inside an executable
JAR (not a bundle) that would be used as follows:

java -jar analyzer.jar file1 file2 file3 ...

The host program in analyzer.jar would then launch an embedded
framework, auto-deploy the statistics bundle, and use the service
interface of that bundle. I read on the felix website that there are
two options for this type of situation: having the service interfaces
inside the host program (not something I want to do, as these bundles
should not depend on this host program) or to use reflection. I am not
sure how to use reflection for this purpose.

As an alternative, I figured I could write a second bundle that reads
a series of files from a fixed location and uses the statistics
bundle, as both would be inside the OSGi container. I can put these
bundles into the bundle directory of the stand-alone felix framework
and this works; however, I don't want felix to keep running after all
the files are processed.

What is the cleanest and easiest way to accomplish the task of
providing input (file names) to a service and having it shutdown when
finished?

Thanks,
Justin

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


Re: Closing felix when bundle/service is finished

Posted by Karl Pauls <ka...@gmail.com>.
You could also see whether PojoSR works for you:

http://code.google.com/p/pojosr/wiki/Usage

regards,

Karl

On Wed, Jun 22, 2011 at 2:33 AM, Justin Stoecker <js...@gmail.com> wrote:
> Ah, perfect. Thanks for your help.
>
> Justin
>
> On Tue, Jun 21, 2011 at 7:20 PM, Donald Whytock <dw...@gmail.com> wrote:
>> Okay.  If you have access to the framework, you can use
>> bundlecontext.getBundle(0).stop(); that should shut down the
>> framework.
>>
>> Don
>>
>> On Tue, Jun 21, 2011 at 6:43 PM, Justin Stoecker <js...@gmail.com> wrote:
>>> Hi Don,
>>>
>>> It's not *absolutely* necessary. The statistics bundle actually
>>> depends on other bundles, all of which I could use directly, but it
>>> would be desirable and/or interesting for learning purposes.
>>>
>>> Justin
>>>
>>> On Tue, Jun 21, 2011 at 6:36 PM, Donald Whytock <dw...@gmail.com> wrote:
>>>> Do you absolutely need the statistics bundle to run in a Felix
>>>> framework?  Or could you just include the bundle's .jar on your
>>>> classpath, instantiate the service object and run the method directly?
>>>>
>>>> Don
>>>>
>>>> On Tue, Jun 21, 2011 at 6:31 PM, Justin Stoecker <js...@gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>> I have a "statistics" bundle that provides the service of reading a
>>>>> file, doing some calculations, and writing a new file. Ideally, I
>>>>> would like to write a small command-line program inside an executable
>>>>> JAR (not a bundle) that would be used as follows:
>>>>>
>>>>> java -jar analyzer.jar file1 file2 file3 ...
>>>>>
>>>>> The host program in analyzer.jar would then launch an embedded
>>>>> framework, auto-deploy the statistics bundle, and use the service
>>>>> interface of that bundle. I read on the felix website that there are
>>>>> two options for this type of situation: having the service interfaces
>>>>> inside the host program (not something I want to do, as these bundles
>>>>> should not depend on this host program) or to use reflection. I am not
>>>>> sure how to use reflection for this purpose.
>>>>>
>>>>> As an alternative, I figured I could write a second bundle that reads
>>>>> a series of files from a fixed location and uses the statistics
>>>>> bundle, as both would be inside the OSGi container. I can put these
>>>>> bundles into the bundle directory of the stand-alone felix framework
>>>>> and this works; however, I don't want felix to keep running after all
>>>>> the files are processed.
>>>>>
>>>>> What is the cleanest and easiest way to accomplish the task of
>>>>> providing input (file names) to a service and having it shutdown when
>>>>> finished?
>>>>>
>>>>> Thanks,
>>>>> Justin
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>
>



-- 
Karl Pauls
karlpauls@gmail.com
http://twitter.com/karlpauls
http://www.linkedin.com/in/karlpauls
https://profiles.google.com/karlpauls

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


Re: Closing felix when bundle/service is finished

Posted by Justin Stoecker <js...@gmail.com>.
Ah, perfect. Thanks for your help.

Justin

On Tue, Jun 21, 2011 at 7:20 PM, Donald Whytock <dw...@gmail.com> wrote:
> Okay.  If you have access to the framework, you can use
> bundlecontext.getBundle(0).stop(); that should shut down the
> framework.
>
> Don
>
> On Tue, Jun 21, 2011 at 6:43 PM, Justin Stoecker <js...@gmail.com> wrote:
>> Hi Don,
>>
>> It's not *absolutely* necessary. The statistics bundle actually
>> depends on other bundles, all of which I could use directly, but it
>> would be desirable and/or interesting for learning purposes.
>>
>> Justin
>>
>> On Tue, Jun 21, 2011 at 6:36 PM, Donald Whytock <dw...@gmail.com> wrote:
>>> Do you absolutely need the statistics bundle to run in a Felix
>>> framework?  Or could you just include the bundle's .jar on your
>>> classpath, instantiate the service object and run the method directly?
>>>
>>> Don
>>>
>>> On Tue, Jun 21, 2011 at 6:31 PM, Justin Stoecker <js...@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> I have a "statistics" bundle that provides the service of reading a
>>>> file, doing some calculations, and writing a new file. Ideally, I
>>>> would like to write a small command-line program inside an executable
>>>> JAR (not a bundle) that would be used as follows:
>>>>
>>>> java -jar analyzer.jar file1 file2 file3 ...
>>>>
>>>> The host program in analyzer.jar would then launch an embedded
>>>> framework, auto-deploy the statistics bundle, and use the service
>>>> interface of that bundle. I read on the felix website that there are
>>>> two options for this type of situation: having the service interfaces
>>>> inside the host program (not something I want to do, as these bundles
>>>> should not depend on this host program) or to use reflection. I am not
>>>> sure how to use reflection for this purpose.
>>>>
>>>> As an alternative, I figured I could write a second bundle that reads
>>>> a series of files from a fixed location and uses the statistics
>>>> bundle, as both would be inside the OSGi container. I can put these
>>>> bundles into the bundle directory of the stand-alone felix framework
>>>> and this works; however, I don't want felix to keep running after all
>>>> the files are processed.
>>>>
>>>> What is the cleanest and easiest way to accomplish the task of
>>>> providing input (file names) to a service and having it shutdown when
>>>> finished?
>>>>
>>>> Thanks,
>>>> Justin
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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: Closing felix when bundle/service is finished

Posted by Donald Whytock <dw...@gmail.com>.
Okay.  If you have access to the framework, you can use
bundlecontext.getBundle(0).stop(); that should shut down the
framework.

Don

On Tue, Jun 21, 2011 at 6:43 PM, Justin Stoecker <js...@gmail.com> wrote:
> Hi Don,
>
> It's not *absolutely* necessary. The statistics bundle actually
> depends on other bundles, all of which I could use directly, but it
> would be desirable and/or interesting for learning purposes.
>
> Justin
>
> On Tue, Jun 21, 2011 at 6:36 PM, Donald Whytock <dw...@gmail.com> wrote:
>> Do you absolutely need the statistics bundle to run in a Felix
>> framework?  Or could you just include the bundle's .jar on your
>> classpath, instantiate the service object and run the method directly?
>>
>> Don
>>
>> On Tue, Jun 21, 2011 at 6:31 PM, Justin Stoecker <js...@gmail.com> wrote:
>>> Hi,
>>>
>>> I have a "statistics" bundle that provides the service of reading a
>>> file, doing some calculations, and writing a new file. Ideally, I
>>> would like to write a small command-line program inside an executable
>>> JAR (not a bundle) that would be used as follows:
>>>
>>> java -jar analyzer.jar file1 file2 file3 ...
>>>
>>> The host program in analyzer.jar would then launch an embedded
>>> framework, auto-deploy the statistics bundle, and use the service
>>> interface of that bundle. I read on the felix website that there are
>>> two options for this type of situation: having the service interfaces
>>> inside the host program (not something I want to do, as these bundles
>>> should not depend on this host program) or to use reflection. I am not
>>> sure how to use reflection for this purpose.
>>>
>>> As an alternative, I figured I could write a second bundle that reads
>>> a series of files from a fixed location and uses the statistics
>>> bundle, as both would be inside the OSGi container. I can put these
>>> bundles into the bundle directory of the stand-alone felix framework
>>> and this works; however, I don't want felix to keep running after all
>>> the files are processed.
>>>
>>> What is the cleanest and easiest way to accomplish the task of
>>> providing input (file names) to a service and having it shutdown when
>>> finished?
>>>
>>> Thanks,
>>> Justin
>>>
>>> ---------------------------------------------------------------------
>>> 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: Closing felix when bundle/service is finished

Posted by Justin Stoecker <js...@gmail.com>.
Hi Don,

It's not *absolutely* necessary. The statistics bundle actually
depends on other bundles, all of which I could use directly, but it
would be desirable and/or interesting for learning purposes.

Justin

On Tue, Jun 21, 2011 at 6:36 PM, Donald Whytock <dw...@gmail.com> wrote:
> Do you absolutely need the statistics bundle to run in a Felix
> framework?  Or could you just include the bundle's .jar on your
> classpath, instantiate the service object and run the method directly?
>
> Don
>
> On Tue, Jun 21, 2011 at 6:31 PM, Justin Stoecker <js...@gmail.com> wrote:
>> Hi,
>>
>> I have a "statistics" bundle that provides the service of reading a
>> file, doing some calculations, and writing a new file. Ideally, I
>> would like to write a small command-line program inside an executable
>> JAR (not a bundle) that would be used as follows:
>>
>> java -jar analyzer.jar file1 file2 file3 ...
>>
>> The host program in analyzer.jar would then launch an embedded
>> framework, auto-deploy the statistics bundle, and use the service
>> interface of that bundle. I read on the felix website that there are
>> two options for this type of situation: having the service interfaces
>> inside the host program (not something I want to do, as these bundles
>> should not depend on this host program) or to use reflection. I am not
>> sure how to use reflection for this purpose.
>>
>> As an alternative, I figured I could write a second bundle that reads
>> a series of files from a fixed location and uses the statistics
>> bundle, as both would be inside the OSGi container. I can put these
>> bundles into the bundle directory of the stand-alone felix framework
>> and this works; however, I don't want felix to keep running after all
>> the files are processed.
>>
>> What is the cleanest and easiest way to accomplish the task of
>> providing input (file names) to a service and having it shutdown when
>> finished?
>>
>> Thanks,
>> Justin
>>
>> ---------------------------------------------------------------------
>> 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: Closing felix when bundle/service is finished

Posted by Donald Whytock <dw...@gmail.com>.
Do you absolutely need the statistics bundle to run in a Felix
framework?  Or could you just include the bundle's .jar on your
classpath, instantiate the service object and run the method directly?

Don

On Tue, Jun 21, 2011 at 6:31 PM, Justin Stoecker <js...@gmail.com> wrote:
> Hi,
>
> I have a "statistics" bundle that provides the service of reading a
> file, doing some calculations, and writing a new file. Ideally, I
> would like to write a small command-line program inside an executable
> JAR (not a bundle) that would be used as follows:
>
> java -jar analyzer.jar file1 file2 file3 ...
>
> The host program in analyzer.jar would then launch an embedded
> framework, auto-deploy the statistics bundle, and use the service
> interface of that bundle. I read on the felix website that there are
> two options for this type of situation: having the service interfaces
> inside the host program (not something I want to do, as these bundles
> should not depend on this host program) or to use reflection. I am not
> sure how to use reflection for this purpose.
>
> As an alternative, I figured I could write a second bundle that reads
> a series of files from a fixed location and uses the statistics
> bundle, as both would be inside the OSGi container. I can put these
> bundles into the bundle directory of the stand-alone felix framework
> and this works; however, I don't want felix to keep running after all
> the files are processed.
>
> What is the cleanest and easiest way to accomplish the task of
> providing input (file names) to a service and having it shutdown when
> finished?
>
> Thanks,
> Justin
>
> ---------------------------------------------------------------------
> 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