You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Guo Zhenhua <je...@gmail.com> on 2009/12/09 17:33:31 UTC

Run sling within independent container without using OSGi?

I want to run Sling in tomcat without using OSGi. Is that possible?
Thanks

Gerald

Re: Run sling within independent container without using OSGi?

Posted by Guo Zhenhua <je...@gmail.com>.
The reason is that Sling is kinda independent of another part in our
project. If I put them all into a single web app, it may be too
bloated. What I want to do is separate main part in our project from
Sling and figure out how they can communicate with each other.

Gerald

On Wed, Dec 9, 2009 at 11:51 AM, Justin Edelson <ju...@gmail.com> wrote:
> Hmmm. I didn't think the servlet spec permitted this. Why do you want to do it?
>
> Justin
>
> On Dec 9, 2009, at 11:44 AM, Guo Zhenhua wrote:
>
>> Thanks. I see.
>> If I want to call Sling APIs from another webapp within the same
>> container, will it be different from regular case because of OSGi used
>> by Sling web app?
>>
>> Gerald
>>
>> On Wed, Dec 9, 2009 at 11:39 AM, Bertrand Delacretaz
>> <bd...@apache.org> wrote:
>>> Hi,
>>>
>>> On Wed, Dec 9, 2009 at 5:33 PM, Guo Zhenhua <je...@gmail.com> wrote:
>>>> I want to run Sling in tomcat without using OSGi. Is that possible?...
>>>
>>> You can run the Sling webapp (launchpad/webapp) directly into a
>>> servlet container.
>>>
>>> The webapp provides its own embedded OSGi framework.
>>>
>>> Running without that is not possible.
>>>
>>> -Bertrand
>>>
>
>

Re: Run sling within independent container without using OSGi?

Posted by Justin Edelson <ju...@gmail.com>.
Hmmm. I didn't think the servlet spec permitted this. Why do you want to do it?

Justin

On Dec 9, 2009, at 11:44 AM, Guo Zhenhua wrote:

> Thanks. I see.
> If I want to call Sling APIs from another webapp within the same
> container, will it be different from regular case because of OSGi used
> by Sling web app?
> 
> Gerald
> 
> On Wed, Dec 9, 2009 at 11:39 AM, Bertrand Delacretaz
> <bd...@apache.org> wrote:
>> Hi,
>> 
>> On Wed, Dec 9, 2009 at 5:33 PM, Guo Zhenhua <je...@gmail.com> wrote:
>>> I want to run Sling in tomcat without using OSGi. Is that possible?...
>> 
>> You can run the Sling webapp (launchpad/webapp) directly into a
>> servlet container.
>> 
>> The webapp provides its own embedded OSGi framework.
>> 
>> Running without that is not possible.
>> 
>> -Bertrand
>> 


Re: Run sling within independent container without using OSGi?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Dec 9, 2009 at 8:57 PM, Guo Zhenhua <je...@gmail.com> wrote:
> Continuing my question. If I want to run my code in the same webapp
> with Sling, my code needs to written according to OSGi or regular code
> works fine?

If it's java code you'll have to use (a bit of) OSGi to access the
Sling interfaces.

If it's scripting, you can get at Sling services quite easily.

The samples/espblog sample has examples of both java and scripted
(esp) code, if you look at the pom.xml and the single java class you
can see the the OSGi part is fairly simple.

-Bertrand

Re: Run sling within independent container without using OSGi?

Posted by Carsten Ziegeler <cz...@apache.org>.
Guo Zhenhua wrote:
> Continuing my question. If I want to run my code in the same webapp
> with Sling, my code needs to written according to OSGi or regular code
> works fine?
> 
It depends on what exactly you want to do :)
If Sling runs in a webapp the main entry point is a servlet which embeds
the OSGi container and Sling runs inside this container. The servlet is
just a proxy forwarding all requests to Sling.
But as this is a regular webapp you can run other servlets at the same
time and these servlets don't have to use OSGi. In addition you can
forward or include from these servlets to Sling.

Carsten
-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Run sling within independent container without using OSGi?

Posted by Guo Zhenhua <je...@gmail.com>.
Continuing my question. If I want to run my code in the same webapp
with Sling, my code needs to written according to OSGi or regular code
works fine?

Gerald

On Wed, Dec 9, 2009 at 11:53 AM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> On Wed, Dec 9, 2009 at 5:44 PM, Guo Zhenhua <je...@gmail.com> wrote:
>> ...If I want to call Sling APIs from another webapp within the same
>> container, will it be different from regular case because of OSGi used
>> by Sling web app?...
>
> That might be tricky - if you want to call Sling APIs from another
> webapp, the API classes must come from the container's classloader.
>
> You'd have to make the required APIs globally available, and not load
> the corresponding API jars in the OSGi container used by Sling.
>
> I'm not sure if that's worth the effort, it might be simpler to run
> your code in the same webapp/container, or access Sling via its HTTP
> interface.
>
> -Bertrand
>

Re: Run sling within independent container without using OSGi?

Posted by Guo Zhenhua <je...@gmail.com>.
Thanks for your reply. It really makes sense.

Gerald

On Wed, Dec 9, 2009 at 11:53 AM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> On Wed, Dec 9, 2009 at 5:44 PM, Guo Zhenhua <je...@gmail.com> wrote:
>> ...If I want to call Sling APIs from another webapp within the same
>> container, will it be different from regular case because of OSGi used
>> by Sling web app?...
>
> That might be tricky - if you want to call Sling APIs from another
> webapp, the API classes must come from the container's classloader.
>
> You'd have to make the required APIs globally available, and not load
> the corresponding API jars in the OSGi container used by Sling.
>
> I'm not sure if that's worth the effort, it might be simpler to run
> your code in the same webapp/container, or access Sling via its HTTP
> interface.
>
> -Bertrand
>

Re: Run sling within independent container without using OSGi?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Dec 9, 2009 at 5:44 PM, Guo Zhenhua <je...@gmail.com> wrote:
> ...If I want to call Sling APIs from another webapp within the same
> container, will it be different from regular case because of OSGi used
> by Sling web app?...

That might be tricky - if you want to call Sling APIs from another
webapp, the API classes must come from the container's classloader.

You'd have to make the required APIs globally available, and not load
the corresponding API jars in the OSGi container used by Sling.

I'm not sure if that's worth the effort, it might be simpler to run
your code in the same webapp/container, or access Sling via its HTTP
interface.

-Bertrand

Re: Run sling within independent container without using OSGi?

Posted by Guo Zhenhua <je...@gmail.com>.
Thanks. I see.
If I want to call Sling APIs from another webapp within the same
container, will it be different from regular case because of OSGi used
by Sling web app?

Gerald

On Wed, Dec 9, 2009 at 11:39 AM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> Hi,
>
> On Wed, Dec 9, 2009 at 5:33 PM, Guo Zhenhua <je...@gmail.com> wrote:
>> I want to run Sling in tomcat without using OSGi. Is that possible?...
>
> You can run the Sling webapp (launchpad/webapp) directly into a
> servlet container.
>
> The webapp provides its own embedded OSGi framework.
>
> Running without that is not possible.
>
> -Bertrand
>

Re: Run sling within independent container without using OSGi?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Wed, Dec 9, 2009 at 5:33 PM, Guo Zhenhua <je...@gmail.com> wrote:
> I want to run Sling in tomcat without using OSGi. Is that possible?...

You can run the Sling webapp (launchpad/webapp) directly into a
servlet container.

The webapp provides its own embedded OSGi framework.

Running without that is not possible.

-Bertrand