|
|
|
|
Re: javax.servlet.http.HttpServlet [message #670162 is a reply to message #670136] |
Thu, 12 May 2011 22:30 |
rshelley Messages: 59 Registered: April 2010 |
Member |
|
|
Hi Violeta, that WAR does work.
I'm essentially trying to get RESTful services from RESTEasy to work in the OSGI container. I read a blog that was posted some time last year that suggested taking the RESTEasy JARs, turning them into an OSGI bundle, then there was a sample bundle with an Activator. I have yet to get that to work as expected. In the Activator, it tries to get the HttpService from the context, but gets a null, which then blows up:
private class HttpServiceTracker extends ServiceTracker {
public HttpServiceTracker(BundleContext context) {
super(context, HttpService.class.getName(), null);
}
public Object addingService(ServiceReference reference) {
// RESULTS IN A NULL
HttpService httpService = (HttpService) context.getService(reference);
Maybe you can help shed some light on whether this is even possible, and I'll try to do the heavy lifting from there.
1) Create a common WAR that supports RESTEasy (although, there is no OSGI bundle for RE), which creates the Servlet context and starts listening for bundles to be registered
2) Create individual bundles (JARs) that contain RESTEasy endpoints and registers with OSGI when they are loaded
3) The common WAR bundle listener catches REST bundles and starts forwarding HTTP requests to their respective endpoints
Maybe there's another way I'm not thinking of, but ideally, I'd like to get my developers away from writing WARs for every set of APIs they want to provide. Instead, I want to give them the ability to create service bundles that are registered with the WAR and can start receiving requests without having to worry about the implementation of the web service and container. Phase 1 would be to just let them create their own bundles that provide the JAX-RS annotations on methods and then I could register those into the RE Servlet (if possible) and future phases would be a little more dynamic about it (not needing annotations).
Thoughts? Thanks!
|
|
|
Re: javax.servlet.http.HttpServlet [message #670167 is a reply to message #670162] |
Thu, 12 May 2011 22:46 |
rshelley Messages: 59 Registered: April 2010 |
Member |
|
|
Oh, and to answer a few other of your questions
I attached the source for my RESTEasy Activator/Service (that I got from a blog, and tweaked to get to build)
Virgo Version - 2.1.1.RELEASE
RESTEasy Artifacts - I took the libs from 1.1.0.GA and put them in a JAR with a manifest that looks like this (which loads into Virgo fine) - this file is too large to attach here unfortunately:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RESTEasy OSGI
Bundle-SymbolicName: org.jboss.resteasy
Bundle-Version: 1.1.0.GA
Bundle-ClassPath: .
Export-Package: org.jboss.resteasy.core,
org.jboss.resteasy.plugins.server.servlet,
org.jboss.resteasy.spi
I then created (well, took from a blog) another bundle that has an Activator, Service and a Servlet, and this one is the one that fails when trying to get HttpService (see the attached ZIP)
Manifest-Version: 1.0
Export-Package: org.jboss.resteasy.plugins.server.osgi;version="1.1.0.
GA"
Unversioned-Imports: *
Bundle-Classpath: .
Built-By: rshelley
Bundle-Name: RESTEasy OSGi plugin
Created-By: Apache Maven
Bundle-Vendor: Davi Baldin H. Tavares
Build-Jdk: 1.6.0_24
Bundle-Version: 1.1.0.GA
Spring-DM-Version: 1.1.0-SNAPSHOT
Bundle-Activator: org.jboss.resteasy.plugins.server.osgi.internal.Acti
vator
Bundle-ManifestVersion: 2
Import-Package: javax.servlet;version="[0,2.5.0]",javax.servlet.http;v
ersion="[0,2.5.0]",org.apache.log4j,org.jboss.resteasy.core,org.jboss
.resteasy.plugins.server.servlet,org.jboss.resteasy.spi,org.osgi.fram
ework,org.osgi.service.http,org.osgi.util.tracker
Bundle-SymbolicName: org.jboss.resteasy.plugins.server.osgi
Archiver-Version: Plexus Archiver
So it's the attached ZIP (if you unzip and then "mvn clean install" on it, you should get a JAR) and it's this one that fails to load.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03285 seconds