[ 
https://issues.apache.org/jira/browse/SHINDIG-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779377#action_12779377
 ] 

Mikhail Kotelnikov commented on SHINDIG-1225:
---------------------------------------------

The problem is that by default the OSGi environment does not support war files. 
The OSGi spec defines just the org.osgi.service.http.HttpService interface 
which used to register servlets and resources. That is all.  In classical web 
applications (packaged as wars) Guice Injectors are stored in ServletContexts 
which are configured via web.xml files. In the OSGi environment we don't have 
direct access to the ServletContext - it is created under the hood by the 
HttpService implementation. But we could define our own 
org.osgi.service.http.HttpContext instance (it is an another interface defined 
by the OSGi spec). The specification guaranties us that all servlets registered 
with the same instance of HttpContext share the same ServletContext (created 
under the hood, as I said). 

So we are using this feature of OSGi in the following way:
* We create our own HttpContext. All servlets registered with this HttpContext 
will share the same ServletContext.  
* We create and register a fake servlet with this HttpContext *before* all 
other Shindig servlets. The init(ServletContext) method of this servlet just 
creates a new Guice injector, configures it and sets in the ServletContext 
(already available in the init(ServletContext) method). 
* When the first fake servet finish his job in the init(ServletContext) method 
we can register all other Shindig servlets. They have already access to the 
configured Guice Injector in the previous step.

As you can see this registration of a fake servlet is required to make all 
stuff working. So we (unfortunately) need this URL path mapping - otherwise we 
could not register this  servlet in the HttpService.

- Mikhail

> Make Shindig jars available as OSGi bundles
> -------------------------------------------
>
>                 Key: SHINDIG-1225
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1225
>             Project: Shindig
>          Issue Type: Improvement
>          Components: Java
>            Reporter: David Johnson
>         Attachments: ShindigActivator.java
>
>
> Make changes to the Shindig-Java build process so that the Shindig Jars are 
> each available as OSGi bundles.
> See also: 
>    November 2009 thread: Shindig and OSGi
>    http://markmail.org/thread/hrozofu6mkyj3bm4
>    May 2009 thread: Shindig as an OSGi Bundle
>    http://markmail.org/thread/fqechw5ek7uxnehw

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to