Convenient way for installing Sling in another OSGi container?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Convenient way for installing Sling in another OSGi container?

Gert Vanthienen-2
L.S.,

I'm trying to get Sling to run inside the ServiceMix 4 Kernel by looking
at a running Sling /console to determine the list of bundles and
manually copying them to SMX4 Kernel's deploy directory.  Isn't there a
more convenient way to deploy this, e.g. using an OBR/Maven repository
and auto-downloading the dependencies?

Gert

Reply | Threaded
Open this post in threaded view
|

Re: Convenient way for installing Sling in another OSGi container?

Felix Meschberger-2
Hi Gert,

There are multiple options, yet this one is based on OBR:

To make it easy to use the OBR for installation, you might want to use
the sling console, which lists bundles available from the OBR and you
may just select those that you require. So lets start with the sling
console.

(1) Install the Sling Log Bundle unless you already have the OSGi
LogService, SLF4J and Jakarta Commons Logging already available for
Import-Package: Use the SMX kernel methods to install this from your
local maven repository or from the osgi/log target folder.

(2) Install the Jakarte commons-io 1.4 bundle - as of Version 1.4 the
library is built as an OSGi bundle and may be deployed as-is

(3) Deploy the Apache Felix Bundle Repository bundle

(4) Deploy the Sling Assembly bundle - this is currently needed for OBR
support in the console

(6) If the SMX kernel does not provide an HttpService implementation,
grab the Pax Web Service from
http://wiki.ops4j.org/confluence/display/ops4j/Pax+Web and deploy it
using the SMX kernel methods.

(7) Install the sling console: Same as for the log bundle, use the SMX
kernel methods.

Now, the Sling Console should be starting up and be available as /sling.

Next step is to point the Sling Console OSGi Repositories page to your
local maven repository, provided you installed all sling bundles there.
This is the URL to add the repository

  http://localhost:8080/sling/bundlerepo?action=refreshOBR&repository=file://${M2_REPO}/repository.xml

where ${M2_REPO} is the path to your local maven repository, e.g.
${HOME}/.m2/repository and assuming the smx system is available at
localhost:8080.

Now you should be able to select the bundles you want ...

Hope this helps, but I have to admit, that this is a pure theoretical
run-down ;-)

Regards
Felix



Am Mittwoch, den 12.03.2008, 17:01 +0100 schrieb Gert Vanthienen:
> L.S.,
>
> I'm trying to get Sling to run inside the ServiceMix 4 Kernel by looking
> at a running Sling /console to determine the list of bundles and
> manually copying them to SMX4 Kernel's deploy directory.  Isn't there a
> more convenient way to deploy this, e.g. using an OBR/Maven repository
> and auto-downloading the dependencies?
>
> Gert


Reply | Threaded
Open this post in threaded view
|

Re: Convenient way for installing Sling in another OSGi container?

gertv
Felix,

Thanks for the pointers.  Your run-down basically worked, ServiceMix
Kernel was missing a few additional Felix bundles (like event admin and
some of the commons stuff).  I did have to remove the LogService bundles
a few times, because it was installed together with other bundles and
ServiceMix Kernel already has a LogService about.  Is this just 'part of
the game' or is there anything I can change to ServiceMix Kernel to
solve this in the future (or provide a patch for it in Sling off course)?

Secondly, is there any documentation about on writing the ESP pages?  
For now, I always go and take a look at the ScriptableXxxYyy classes to
figure out my options.

Another ESP question: is there a way to get only a limited number of
children of a given node?  For my ServiceMix monitoring solution, I
would prefer to get only the last 50 or so MessageExchanges on the list
by default.  If a user requires older logging, he should be able to look
it up afterwards, but for now a limited list would do fine.

Finally, I'm using the JCR-RMI API to store MessageExchange information
in the JCR, but I suppose I can do it more directly since they are both
running on the same VM.  Haven't been able to find a code example for
how to get a reference to the Repository instance however, although
there probably is an example somewhere in the source code.  Any idea
where I can look?

Gert

Felix Meschberger wrote:

> Hi Gert,
>
> There are multiple options, yet this one is based on OBR:
>
> To make it easy to use the OBR for installation, you might want to use
> the sling console, which lists bundles available from the OBR and you
> may just select those that you require. So lets start with the sling
> console.
>
> (1) Install the Sling Log Bundle unless you already have the OSGi
> LogService, SLF4J and Jakarta Commons Logging already available for
> Import-Package: Use the SMX kernel methods to install this from your
> local maven repository or from the osgi/log target folder.
>
> (2) Install the Jakarte commons-io 1.4 bundle - as of Version 1.4 the
> library is built as an OSGi bundle and may be deployed as-is
>
> (3) Deploy the Apache Felix Bundle Repository bundle
>
> (4) Deploy the Sling Assembly bundle - this is currently needed for OBR
> support in the console
>
> (6) If the SMX kernel does not provide an HttpService implementation,
> grab the Pax Web Service from
> http://wiki.ops4j.org/confluence/display/ops4j/Pax+Web and deploy it
> using the SMX kernel methods.
>
> (7) Install the sling console: Same as for the log bundle, use the SMX
> kernel methods.
>
> Now, the Sling Console should be starting up and be available as /sling.
>
> Next step is to point the Sling Console OSGi Repositories page to your
> local maven repository, provided you installed all sling bundles there.
> This is the URL to add the repository
>
>   http://localhost:8080/sling/bundlerepo?action=refreshOBR&repository=file://${M2_REPO}/repository.xml
>
> where ${M2_REPO} is the path to your local maven repository, e.g.
> ${HOME}/.m2/repository and assuming the smx system is available at
> localhost:8080.
>
> Now you should be able to select the bundles you want ...
>
> Hope this helps, but I have to admit, that this is a pure theoretical
> run-down ;-)
>
> Regards
> Felix
>
>
>
> Am Mittwoch, den 12.03.2008, 17:01 +0100 schrieb Gert Vanthienen:
>  
>> L.S.,
>>
>> I'm trying to get Sling to run inside the ServiceMix 4 Kernel by looking
>> at a running Sling /console to determine the list of bundles and
>> manually copying them to SMX4 Kernel's deploy directory.  Isn't there a
>> more convenient way to deploy this, e.g. using an OBR/Maven repository
>> and auto-downloading the dependencies?
>>
>> Gert
>>    
>
>
>  


Reply | Threaded
Open this post in threaded view
|

Re: Convenient way for installing Sling in another OSGi container?

Felix Meschberger-2
Hi Gertm

Am Dienstag, den 18.03.2008, 12:02 +0100 schrieb Gert Vanthienen:
> Felix,
>
> Thanks for the pointers.  Your run-down basically worked, ServiceMix
> Kernel was missing a few additional Felix bundles (like event admin and
> some of the commons stuff).

Cool. Nice to hear that ...

>  I did have to remove the LogService bundles
> a few times, because it was installed together with other bundles and
> ServiceMix Kernel already has a LogService about.  Is this just 'part of
> the game' or is there anything I can change to ServiceMix Kernel to
> solve this in the future (or provide a patch for it in Sling off course)?

Yes, LogService is tricky ... The Sling LogService exports SLF4J,
Commons Logging and LOG4J APIs in addition to OSGi LogService. If you
have an implementation which also provide these API (e.g. Pax Logging
from ops4j.org) or if you have other bundles exporting these API, you do
not actually need the Sling LogService bundle.

>
> Secondly, is there any documentation about on writing the ESP pages?  
> For now, I always go and take a look at the ScriptableXxxYyy classes to
> figure out my options.

Unfortunately, there is not much yet, except for the test case scripts
in the launchpad/webapp project.

But basically, the Java API should be reflected in JavaScript, hence
ESP. So the request and response objects provide the same API as
described by the SlingHttpServletRequest/Response interfaces.

For the Node and Property objects, the goal is to also have the full JCR
API supported. Because - particularly for Node - we want to add
JavaScript-goody like supporting node["jcr:content"] for
node.getProperty("jcr:content") we have these Scriptable* stuff. We are
constantly extending this support and AFAIK Bertrand is getting close to
fully support.

>
> Another ESP question: is there a way to get only a limited number of
> children of a given node?  For my ServiceMix monitoring solution, I
> would prefer to get only the last 50 or so MessageExchanges on the list
> by default.  If a user requires older logging, he should be able to look
> it up afterwards, but for now a limited list would do fine.

No, there is no such thing. As I said, we just replicate the JCR API.
And because the JCR API has no such functionality, the JavaScript
pendants don't have this functionality either. The only solution is to
iterate over the list upto the children you want to use.

>
> Finally, I'm using the JCR-RMI API to store MessageExchange information
> in the JCR, but I suppose I can do it more directly since they are both
> running on the same VM.  Haven't been able to find a code example for
> how to get a reference to the Repository instance however, although
> there probably is an example somewhere in the source code.  Any idea
> where I can look?

I assume you are using the jackrabbit-server bundle to embed the
repository ? In this case you may easily get the
org.apache.sling.jcr.api.SlingRepository (or javax.jcr.Repository)
service, which gives you the repository. And you don't care how this
service got there.

Hope this helps.

Regards
Felix

>
> Gert
>
> Felix Meschberger wrote:
> > Hi Gert,
> >
> > There are multiple options, yet this one is based on OBR:
> >
> > To make it easy to use the OBR for installation, you might want to use
> > the sling console, which lists bundles available from the OBR and you
> > may just select those that you require. So lets start with the sling
> > console.
> >
> > (1) Install the Sling Log Bundle unless you already have the OSGi
> > LogService, SLF4J and Jakarta Commons Logging already available for
> > Import-Package: Use the SMX kernel methods to install this from your
> > local maven repository or from the osgi/log target folder.
> >
> > (2) Install the Jakarte commons-io 1.4 bundle - as of Version 1.4 the
> > library is built as an OSGi bundle and may be deployed as-is
> >
> > (3) Deploy the Apache Felix Bundle Repository bundle
> >
> > (4) Deploy the Sling Assembly bundle - this is currently needed for OBR
> > support in the console
> >
> > (6) If the SMX kernel does not provide an HttpService implementation,
> > grab the Pax Web Service from
> > http://wiki.ops4j.org/confluence/display/ops4j/Pax+Web and deploy it
> > using the SMX kernel methods.
> >
> > (7) Install the sling console: Same as for the log bundle, use the SMX
> > kernel methods.
> >
> > Now, the Sling Console should be starting up and be available as /sling.
> >
> > Next step is to point the Sling Console OSGi Repositories page to your
> > local maven repository, provided you installed all sling bundles there.
> > This is the URL to add the repository
> >
> >   http://localhost:8080/sling/bundlerepo?action=refreshOBR&repository=file://${M2_REPO}/repository.xml
> >
> > where ${M2_REPO} is the path to your local maven repository, e.g.
> > ${HOME}/.m2/repository and assuming the smx system is available at
> > localhost:8080.
> >
> > Now you should be able to select the bundles you want ...
> >
> > Hope this helps, but I have to admit, that this is a pure theoretical
> > run-down ;-)
> >
> > Regards
> > Felix
> >
> >
> >
> > Am Mittwoch, den 12.03.2008, 17:01 +0100 schrieb Gert Vanthienen:
> >  
> >> L.S.,
> >>
> >> I'm trying to get Sling to run inside the ServiceMix 4 Kernel by looking
> >> at a running Sling /console to determine the list of bundles and
> >> manually copying them to SMX4 Kernel's deploy directory.  Isn't there a
> >> more convenient way to deploy this, e.g. using an OBR/Maven repository
> >> and auto-downloading the dependencies?
> >>
> >> Gert
> >>    
> >
> >
> >  
>


Reply | Threaded
Open this post in threaded view
|

Re: Convenient way for installing Sling in another OSGi container?

gertv
Felix,

Thanks for your answers.  Just one additional question on the following...

>> Another ESP question: is there a way to get only a limited number of
>> children of a given node?  For my ServiceMix monitoring solution, I
>> would prefer to get only the last 50 or so MessageExchanges on the list
>> by default.  If a user requires older logging, he should be able to look
>> it up afterwards, but for now a limited list would do fine.
>>    
>
> No, there is no such thing. As I said, we just replicate the JCR API.
> And because the JCR API has no such functionality, the JavaScript
> pendants don't have this functionality either. The only solution is to
> iterate over the list upto the children you want to use
I suppose iterating is the only solution as didn't find a way to access
the list of nodes as if it were an array,  Is there perhaps a way to
specify the order for the nodes being retrieved -- just trying to avoid
having to iterate over a lot of nodes we don't need?

Gert

Reply | Threaded
Open this post in threaded view
|

Re: Convenient way for installing Sling in another OSGi container?

Felix Meschberger-2
Hi Gert,

Am Mittwoch, den 19.03.2008, 20:16 +0100 schrieb Gert Vanthienen:

> Felix,
>
> Thanks for your answers.  Just one additional question on the following...
>
> >> Another ESP question: is there a way to get only a limited number of
> >> children of a given node?  For my ServiceMix monitoring solution, I
> >> would prefer to get only the last 50 or so MessageExchanges on the list
> >> by default.  If a user requires older logging, he should be able to look
> >> it up afterwards, but for now a limited list would do fine.
> >>    
> >
> > No, there is no such thing. As I said, we just replicate the JCR API.
> > And because the JCR API has no such functionality, the JavaScript
> > pendants don't have this functionality either. The only solution is to
> > iterate over the list upto the children you want to use
> I suppose iterating is the only solution as didn't find a way to access
> the list of nodes as if it were an array,  Is there perhaps a way to
> specify the order for the nodes being retrieved -- just trying to avoid
> having to iterate over a lot of nodes we don't need?

The JCR API defines the Node.getNodes() method which returns a
NodeIterator over all child nodes. Generally the order of the nodes is
the order of addition, that is first nodes first. (If the parent node
has orderable child nodes, the node order may be changed, but this is
probably not the case here).

There is no direct way of reversing that order and so you have to
iterate over all nodes and just use those you like - that is ignore the
first nodes in the iterator.

Regards
Felix


Reply | Threaded
Open this post in threaded view
|

Re: Convenient way for installing Sling in another OSGi container?

gertv
In reply to this post by Felix Meschberger-2
Felix,

Thanks for your help!  You can find the end result of my experiments on
http://servicemix.apache.org/SMX4KNL/running-apache-sling-on-servicemix-kernel.html 
-- it can be done simpler but we also intended to show off some of the
deployment possibilities of the Kernel in the same document.

Regards,

Gert

Felix Meschberger wrote:

> Hi Gert,
>
> There are multiple options, yet this one is based on OBR:
>
> To make it easy to use the OBR for installation, you might want to use
> the sling console, which lists bundles available from the OBR and you
> may just select those that you require. So lets start with the sling
> console.
>
> (1) Install the Sling Log Bundle unless you already have the OSGi
> LogService, SLF4J and Jakarta Commons Logging already available for
> Import-Package: Use the SMX kernel methods to install this from your
> local maven repository or from the osgi/log target folder.
>
> (2) Install the Jakarte commons-io 1.4 bundle - as of Version 1.4 the
> library is built as an OSGi bundle and may be deployed as-is
>
> (3) Deploy the Apache Felix Bundle Repository bundle
>
> (4) Deploy the Sling Assembly bundle - this is currently needed for OBR
> support in the console
>
> (6) If the SMX kernel does not provide an HttpService implementation,
> grab the Pax Web Service from
> http://wiki.ops4j.org/confluence/display/ops4j/Pax+Web and deploy it
> using the SMX kernel methods.
>
> (7) Install the sling console: Same as for the log bundle, use the SMX
> kernel methods.
>
> Now, the Sling Console should be starting up and be available as /sling.
>
> Next step is to point the Sling Console OSGi Repositories page to your
> local maven repository, provided you installed all sling bundles there.
> This is the URL to add the repository
>
>   http://localhost:8080/sling/bundlerepo?action=refreshOBR&repository=file://${M2_REPO}/repository.xml
>
> where ${M2_REPO} is the path to your local maven repository, e.g.
> ${HOME}/.m2/repository and assuming the smx system is available at
> localhost:8080.
>
> Now you should be able to select the bundles you want ...
>
> Hope this helps, but I have to admit, that this is a pure theoretical
> run-down ;-)
>
> Regards
> Felix
>
>
>
> Am Mittwoch, den 12.03.2008, 17:01 +0100 schrieb Gert Vanthienen:
>  
>> L.S.,
>>
>> I'm trying to get Sling to run inside the ServiceMix 4 Kernel by looking
>> at a running Sling /console to determine the list of bundles and
>> manually copying them to SMX4 Kernel's deploy directory.  Isn't there a
>> more convenient way to deploy this, e.g. using an OBR/Maven repository
>> and auto-downloading the dependencies?
>>
>> Gert
>>    
>
>
>  


Reply | Threaded
Open this post in threaded view
|

Re: Convenient way for installing Sling in another OSGi container?

Felix Meschberger-2
Hi Gert,

Am Dienstag, den 22.04.2008, 08:49 +0200 schrieb Gert Vanthienen:
> Thanks for your help!  You can find the end result of my experiments on
> http://servicemix.apache.org/SMX4KNL/running-apache-sling-on-servicemix-kernel.html 
> -- it can be done simpler but we also intended to show off some of the
> deployment possibilities of the Kernel in the same document.

Thanks for the feedback. I added a link to this page on our Links page.

Regards
Felix