Blueprint xml registration of a servlet to HttpService (AS7)
jrantav Dec 10, 2012 8:19 AMWhat should be done to get a servlet within wab bundle registered with blueprint (xml configuration) to httpservice, thus responding to http requests?
Or, how should I enable blueprint for a wab bundle?
I have been trying with aries blueprint and gemini blueprint, with AS 7.1 and 7.2 snapshot, with no luck.
My main questions are:
- how should my war manifest look like
- do I need to register some generic httpservice servlet in web.xml, like it needs to be done for IBM WAS
- do I need to reference HttpService in blueprint configuration
Currently, I have this in web.xml
<?xml version="1.0" encoding="ASCII"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>Hello World WAB (Web Application Bundle)</display-name> <servlet> <servlet-name>AnotherHelloWorldServlet</servlet-name> <servlet-class>fi.eis.applications.jboss.poc.wab.AnotherHelloWorldServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>AnotherHelloWorldServlet</servlet-name> <url-pattern>/hi_to_osgi</url-pattern> </servlet-mapping> </web-app>
this in blueprint config.xml
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd" > <bean id="AnotherHelloWorldServlet" class="fi.eis.applications.jboss.poc.wab.AnotherHelloWorldServlet"> <property name="MessageService" ref="MessageServiceRef"/> </bean> <service ref="helloworldservletservice" interface="javax.servlet.http.HttpServlet" depends-on="MessageServiceRef">foofoo </service> <reference id="MessageServiceRef" interface="fi.eis.applications.jboss.poc.osgiservice.api.MessageService" availability="mandatory" > <reference-listener bind-method="setMessageService" unbind-method="unsetMessageService"> <ref component-id="helloworldservletservice"/> </reference-listener> </reference> </blueprint>
and this in the manifest (gemini blueprint version).
Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Bundle Plugin Built-By: user Build-Jdk: 1.7.0_09 Export-Package: fi.eis.applications.jboss.poc.wab;uses:="javax.servlet ,fi.eis.applications.jboss.poc.osgiservice.api,org.osgi.util.tracker, org.osgi.framework,org.jboss.logging,javax.servlet.http,org.osgi.serv ice.http" Embed-Directory: WEB-INF/lib Ignore-Package: org.osgi.service.blueprint Bundle-ClassPath: .,WEB-INF/classes Tool: Bnd-1.15.0 Bundle-Name: poc: osgi web app with gemini Web-ContextPath: /osgi-webapp-gemini Export-Service: javax.servlet.Servlet Import-Service: fi.eis.applications.jboss.poc.osgiservice.api.MessageS ervice Bundle-Version: 0.0.1.SNAPSHOT Bnd-LastModified: 1355136810246 Embed-Transitive: true Bundle-Activator: fi.eis.applications.jboss.poc.wab.HttpActivator Bundle-ManifestVersion: 2 Bundle-Description: poc: osgi web app with gemini Embed-Dependency: *;scope=compile|runtime Bundle-SymbolicName: osgi-web-app-gemini Import-Package: fi.eis.applications.jboss.poc.osgiservice.api;version= "[0.0,1)",javax.annotation,javax.servlet;version="[2.5,3.0]",javax.se rvlet.http;version="[2.5,3.0]",org.eclipse.gemini.blueprint,org.jboss .logging;version="[3.0,4.0)",org.osgi.framework;version="[1.5,2.0)",o rg.osgi.service.http;version="[1.2,2)",org.osgi.util.tracker;version= "[1.4,2)"
or (aries blueprint version)
Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Bundle Plugin Built-By: user Build-Jdk: 1.7.0_09 Export-Package: fi.eis.applications.jboss.poc.wab;uses:="javax.servlet ,fi.eis.applications.jboss.poc.osgiservice.api,org.osgi.util.tracker, org.osgi.framework,org.jboss.logging,javax.servlet.http,javax.annotat ion,org.osgi.service.http" Embed-Directory: WEB-INF/lib Bundle-ClassPath: .,WEB-INF/classes Tool: Bnd-1.15.0 Bundle-Name: poc: osgi web app with blueprint Web-ContextPath: /osgi-webapp-blueprint Export-Service: javax.servlet.http.HttpServlet Import-Service: fi.eis.applications.jboss.poc.osgiservice.api.MessageS ervice Bundle-Version: 0.0.1.SNAPSHOT Bnd-LastModified: 1355144028281 Embed-Transitive: true Bundle-Activator: fi.eis.applications.jboss.poc.wab.HttpActivator Bundle-ManifestVersion: 2 Bundle-Description: poc: osgi web app with blueprint Embed-Dependency: *;scope=compile|runtime Import-Package: fi.eis.applications.jboss.poc.osgiservice.api;version= "[0.0,1)",javax.annotation,javax.servlet;version="[2.5,3.0]",javax.se rvlet.http;version="[2.5,3.0]",org.jboss.logging;version="[3.0,4.0)", org.osgi.framework;version="[1.5,2.0)",org.osgi.service.blueprint;ver sion="[1.0.0,2.0.0)",org.osgi.service.http;version="[1.2,2)",org.osgi .util.tracker;version="[1.4,2)" Bundle-SymbolicName: osgi-web-app-blueprint
But it seems blueprint configuration is not even read.