You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by peterg <pe...@gmail.com> on 2012/03/06 14:27:15 UTC

Embedding Karaf in a Java application

Hi all,

what would be the easiest way to embed a Karaf instance within an existing
Java application?
- using/deriving from org.apache.karaf.main.Main?
- using PaxExam Karaf?
- something else...?

Ideally, I would like to just start an instance of my own Karaf distribution
(available as a Maven artifact in my own repository) and interact with it
(accessing/invoking bundles and services, for example).

best regards, Peter

--
View this message in context: http://karaf.922171.n3.nabble.com/Embedding-Karaf-in-a-Java-application-tp3803560p3803560.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Embedding Karaf in a Java application

Posted by Peter Gardfjäll <pe...@gmail.com>.
Thanks JB,

I'll have a closer look at the Karaf Main and Bootstap classes.

regards, Peter


On Tue, Mar 6, 2012 at 2:59 PM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> Hi Peter,
>
> If I right understood, you want to ship Karaf in your application, and
> start Karaf with your application.
>
> In that case, you can use Main or Bootstrap (in the main module).
> Just be careful with the in/out stream (depending what you want to do with
> the Karaf shell console).
>
> Regards
> JB
>
>
> On 03/06/2012 02:57 PM, Peter Gardfjäll wrote:
>
>> Thanks JB,
>>
>> I actually already have my own Karaf distribution (sorry for being
>> unclear on that point) so I was mostly interested in the wrapping part.
>>
>> Do you know if there are any nice examples of using the
>> org.apache.karaf.main.Main class (maybe Main.main() is the best one)?
>>
>> Regarding PaxExam Karaf, I am already using it for integration tests.
>> I'm just wondering if that project supports running Karaf outside of a
>> JUnit context similar to the following PaxExam example:
>> https://github.com/tonit/**Learn-PaxExam/blob/master/**
>> lesson-servermode/src/main/**java/org/ops4j/pax/exam/**
>> servermode/SimpleServer.java<https://github.com/tonit/Learn-PaxExam/blob/master/lesson-servermode/src/main/java/org/ops4j/pax/exam/servermode/SimpleServer.java>
>>
>> best regards, Peter
>>
>>
>> On Tue, Mar 6, 2012 at 2:37 PM, Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> wrote:
>>
>>    Hi Peter,
>>
>>    I would create my own distribution of Karaf.
>>
>>    If you want to hide/wrap it in your application, Main could be a way
>>    to achieve that.
>>
>>    Pax-Exam-Karaf is designed more for the itests.
>>
>>    Regards
>>    JB
>>
>>
>>    On 03/06/2012 02:27 PM, peterg wrote:
>>
>>        Hi all,
>>
>>        what would be the easiest way to embed a Karaf instance within
>>        an existing
>>        Java application?
>>        - using/deriving from org.apache.karaf.main.Main?
>>        - using PaxExam Karaf?
>>        - something else...?
>>
>>        Ideally, I would like to just start an instance of my own Karaf
>>        distribution
>>        (available as a Maven artifact in my own repository) and
>>        interact with it
>>        (accessing/invoking bundles and services, for example).
>>
>>        best regards, Peter
>>
>>        --
>>        View this message in context:
>>        http://karaf.922171.n3.nabble.**__com/Embedding-Karaf-in-a-**
>> Java-__application-**tp3803560p3803560.__html
>>
>>        <http://karaf.922171.n3.**nabble.com/Embedding-Karaf-in-**
>> a-Java-application-**tp3803560p3803560.html<http://karaf.922171.n3.nabble.com/Embedding-Karaf-in-a-Java-application-tp3803560p3803560.html>
>> >
>>        Sent from the Karaf - User mailing list archive at Nabble.com.
>>
>>
>>    --
>>    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: Embedding Karaf in a Java application

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Peter,

If I right understood, you want to ship Karaf in your application, and 
start Karaf with your application.

In that case, you can use Main or Bootstrap (in the main module).
Just be careful with the in/out stream (depending what you want to do 
with the Karaf shell console).

Regards
JB

On 03/06/2012 02:57 PM, Peter Gardfjäll wrote:
> Thanks JB,
>
> I actually already have my own Karaf distribution (sorry for being
> unclear on that point) so I was mostly interested in the wrapping part.
>
> Do you know if there are any nice examples of using the
> org.apache.karaf.main.Main class (maybe Main.main() is the best one)?
>
> Regarding PaxExam Karaf, I am already using it for integration tests.
> I'm just wondering if that project supports running Karaf outside of a
> JUnit context similar to the following PaxExam example:
> https://github.com/tonit/Learn-PaxExam/blob/master/lesson-servermode/src/main/java/org/ops4j/pax/exam/servermode/SimpleServer.java
>
> best regards, Peter
>
>
> On Tue, Mar 6, 2012 at 2:37 PM, Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
>     Hi Peter,
>
>     I would create my own distribution of Karaf.
>
>     If you want to hide/wrap it in your application, Main could be a way
>     to achieve that.
>
>     Pax-Exam-Karaf is designed more for the itests.
>
>     Regards
>     JB
>
>
>     On 03/06/2012 02:27 PM, peterg wrote:
>
>         Hi all,
>
>         what would be the easiest way to embed a Karaf instance within
>         an existing
>         Java application?
>         - using/deriving from org.apache.karaf.main.Main?
>         - using PaxExam Karaf?
>         - something else...?
>
>         Ideally, I would like to just start an instance of my own Karaf
>         distribution
>         (available as a Maven artifact in my own repository) and
>         interact with it
>         (accessing/invoking bundles and services, for example).
>
>         best regards, Peter
>
>         --
>         View this message in context:
>         http://karaf.922171.n3.nabble.__com/Embedding-Karaf-in-a-Java-__application-tp3803560p3803560.__html
>         <http://karaf.922171.n3.nabble.com/Embedding-Karaf-in-a-Java-application-tp3803560p3803560.html>
>         Sent from the Karaf - User mailing list archive at Nabble.com.
>
>
>     --
>     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: Embedding Karaf in a Java application

Posted by Andreas Pieber <an...@gmail.com>.
OK I've missed that example. But I'm not quite sure if it's that
useful for paxexam-karaf. Typically your options section is pretty
minimal (compared to other exam tests). Therefore I'm not quite sure
about the use. In addition pax-exam starts the process always in a new
VM which might be neither what you like. If this is what you desire to
do you might want to give the various runners here [1] a shot.

Kind regards,
Andreas

[1] https://svn.apache.org/repos/asf/karaf/trunk/tooling/exam/container/src/main/java/org/apache/karaf/tooling/exam/container/internal/runner/

2012/3/6 Peter Gardfjäll <pe...@gmail.com>:
> Thanks JB,
>
> I actually already have my own Karaf distribution (sorry for being unclear
> on that point) so I was mostly interested in the wrapping part.
>
> Do you know if there are any nice examples of using the
> org.apache.karaf.main.Main class (maybe Main.main() is the best one)?
>
> Regarding PaxExam Karaf, I am already using it for integration tests.
> I'm just wondering if that project supports running Karaf outside of a JUnit
> context similar to the following PaxExam example:
>
> https://github.com/tonit/Learn-PaxExam/blob/master/lesson-servermode/src/main/java/org/ops4j/pax/exam/servermode/SimpleServer.java
>
> best regards, Peter
>
>
>
> On Tue, Mar 6, 2012 at 2:37 PM, Jean-Baptiste Onofré <jb...@nanthrax.net>
> wrote:
>>
>> Hi Peter,
>>
>> I would create my own distribution of Karaf.
>>
>> If you want to hide/wrap it in your application, Main could be a way to
>> achieve that.
>>
>> Pax-Exam-Karaf is designed more for the itests.
>>
>> Regards
>> JB
>>
>>
>> On 03/06/2012 02:27 PM, peterg wrote:
>>>
>>> Hi all,
>>>
>>> what would be the easiest way to embed a Karaf instance within an
>>> existing
>>> Java application?
>>> - using/deriving from org.apache.karaf.main.Main?
>>> - using PaxExam Karaf?
>>> - something else...?
>>>
>>> Ideally, I would like to just start an instance of my own Karaf
>>> distribution
>>> (available as a Maven artifact in my own repository) and interact with it
>>> (accessing/invoking bundles and services, for example).
>>>
>>> best regards, Peter
>>>
>>> --
>>> View this message in context:
>>> http://karaf.922171.n3.nabble.com/Embedding-Karaf-in-a-Java-application-tp3803560p3803560.html
>>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>
>>
>> --
>> Jean-Baptiste Onofré
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>
>

Re: Embedding Karaf in a Java application

Posted by Peter Gardfjäll <pe...@gmail.com>.
Thanks JB,

I actually already have my own Karaf distribution (sorry for being unclear
on that point) so I was mostly interested in the wrapping part.

Do you know if there are any nice examples of using the
org.apache.karaf.main.Main class (maybe Main.main() is the best one)?

Regarding PaxExam Karaf, I am already using it for integration tests.
I'm just wondering if that project supports running Karaf outside of a
JUnit context similar to the following PaxExam example:

https://github.com/tonit/Learn-PaxExam/blob/master/lesson-servermode/src/main/java/org/ops4j/pax/exam/servermode/SimpleServer.java

best regards, Peter


On Tue, Mar 6, 2012 at 2:37 PM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> Hi Peter,
>
> I would create my own distribution of Karaf.
>
> If you want to hide/wrap it in your application, Main could be a way to
> achieve that.
>
> Pax-Exam-Karaf is designed more for the itests.
>
> Regards
> JB
>
>
> On 03/06/2012 02:27 PM, peterg wrote:
>
>> Hi all,
>>
>> what would be the easiest way to embed a Karaf instance within an existing
>> Java application?
>> - using/deriving from org.apache.karaf.main.Main?
>> - using PaxExam Karaf?
>> - something else...?
>>
>> Ideally, I would like to just start an instance of my own Karaf
>> distribution
>> (available as a Maven artifact in my own repository) and interact with it
>> (accessing/invoking bundles and services, for example).
>>
>> best regards, Peter
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.**
>> com/Embedding-Karaf-in-a-Java-**application-tp3803560p3803560.**html<http://karaf.922171.n3.nabble.com/Embedding-Karaf-in-a-Java-application-tp3803560p3803560.html>
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Embedding Karaf in a Java application

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Peter,

I would create my own distribution of Karaf.

If you want to hide/wrap it in your application, Main could be a way to 
achieve that.

Pax-Exam-Karaf is designed more for the itests.

Regards
JB

On 03/06/2012 02:27 PM, peterg wrote:
> Hi all,
>
> what would be the easiest way to embed a Karaf instance within an existing
> Java application?
> - using/deriving from org.apache.karaf.main.Main?
> - using PaxExam Karaf?
> - something else...?
>
> Ideally, I would like to just start an instance of my own Karaf distribution
> (available as a Maven artifact in my own repository) and interact with it
> (accessing/invoking bundles and services, for example).
>
> best regards, Peter
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Embedding-Karaf-in-a-Java-application-tp3803560p3803560.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com