You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "David Johnson (JIRA)" <ji...@apache.org> on 2009/11/12 19:54:39 UTC
[jira] Created: (SHINDIG-1225) Make Shindig jars available as OSGi
bundles
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
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.
[jira] Issue Comment Edited: (SHINDIG-1225) Make Shindig jars
available as OSGi bundles
Posted by "Mikhail Kotelnikov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779377#action_12779377 ]
Mikhail Kotelnikov edited comment on SHINDIG-1225 at 11/18/09 9:29 AM:
-----------------------------------------------------------------------
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(ServletConfig)" method of this servlet just creates a new Guice injector, configures it and sets in the ServletContext (already available in the init(ServletConfig) method via ServletConfig#getServletContext()).
* When the first fake servet finish his job in the init(ServletConfig) 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
was (Author: mkotelnikov):
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.
[jira] Commented: (SHINDIG-1225) Make Shindig jars available as
OSGi bundles
Posted by "Mikhail Kotelnikov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12777943#action_12777943 ]
Mikhail Kotelnikov commented on SHINDIG-1225:
---------------------------------------------
It seems that Shindig was already integrated in the following OSGi-based open source applications:
* OSW2 (http://wso2.org - Apache 2.0 license)
* Shindig POM file generating a bundle integrating the whole instance of Shindig: http://svn.wso2.org/repos/wso2/trunk/carbon-orbit/shindig/pom.xml
* Nuxeo ECM (http://www.nuxeo.org - LGPL)
* A list of tasks related to OpenSocial: http://jira.nuxeo.org/secure/IssueNavigator.jspa?reset=true&customfield_10080=OpenSocial_521. I don't found the source code/ Maven configurations related to such an integration...
> 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
>
> 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.
[jira] Updated: (SHINDIG-1225) Make Shindig jars available as OSGi
bundles
Posted by "Mikhail Kotelnikov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mikhail Kotelnikov updated SHINDIG-1225:
----------------------------------------
Attachment: ShindigActivator.java
OSGi activator used to register all Shindig-specific servlets. It provides a workaround for Guice injectors in the OSGi environment.
> 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.
[jira] Commented: (SHINDIG-1225) Make Shindig jars available as
OSGi bundles
Posted by "Mikhail Kotelnikov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12777953#action_12777953 ]
Mikhail Kotelnikov commented on SHINDIG-1225:
---------------------------------------------
Some times ago we tried to use Shindig under OSGi...
We could not find a clean solution. Our workaround was:
* Package all Shindig jar files in one bundle. All jars were in the "/lib" folder of this bundle
* This bundle imported some packages defined in separate bundles: like javax.servlet, org.apache.commons.logging, log4j and so on
* The activator of this bundle explicitly listens the HttpService OSGi service and creates, configures and registers all Shindig-specific servlets. To avoid the problem described here http://markmail.org/thread/fqechw5ek7uxnehw we use a fake configuration servlet used to create a Guice injector and register it in a HttpContext common for all Shindig servlets.
You can find our OSGi activator class in the attachment below.
> 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
>
> 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.
[jira] Commented: (SHINDIG-1225) Make Shindig jars available as
OSGi bundles
Posted by "David Johnson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779026#action_12779026 ]
David Johnson commented on SHINDIG-1225:
----------------------------------------
Mikhail, thanks for the very useful comments.
Is it really necessary to do the URL path to Servlet mapping in the Activator that you attached? Couldn't one add the Shindig Servlets and Filters directly to the target web application's web.xml file?
- Dave
> 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.
[jira] Commented: (SHINDIG-1225) Make Shindig jars available as
OSGi bundles
Posted by "Mikhail Kotelnikov (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Commented: (SHINDIG-1225) Make Shindig jars available as
OSGi bundles
Posted by "Nuwan Bandara (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791277#action_12791277 ]
Nuwan Bandara commented on SHINDIG-1225:
----------------------------------------
To host XML gadgets at WSO2 we use shindig as our container/environment. in-order to make it pug-able to the existing OSGI environment what we use at WSO2 (CARBON), we bundled up shindig as an OSGI bundle. However the gadgets are hosted using another OSGI component (Dashboard). Hence we registered the shindig servlets when the Dashboard component deploys in the OSGI environment. At the moment Shindig is sitting as a OSGI bundle in Carbon OSGI space.
Related code can be found at
http://svn.wso2.org/repos/wso2/trunk/carbon-orbit/shindig
https://svn.wso2.org/repos/wso2/trunk/carbon-components/dashboard/org.wso2.carbon.dashboard.ui/
https://svn.wso2.org/repos/wso2/trunk/carbon-components/dashboard/org.wso2.carbon.dashboard.ui/src/main/java/org/wso2/carbon/dashboard/ui/internal/DashboardUiServiceComponent.java
> 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.