Hi all,
last year I filed bug162132: [server] webapp extension point for
org.eclipse.equinox.http.registry<https://bugs.eclipse.org/bugs/show_bug.cgi?id=162132>
.
I've made progress in the last few weeks, and recently have made an initial
implementation publicly available.
The basic idea is to provide easy support for web applications using
servlets, JSP's, filters, mime-types, welcome-files, declarative security,
etc. based on OSGi HttpService (and its implementations, e.g. Jetty based,
ServletBridge, Knopflerfish, Felix). The web deployment descriptor
(/WEB-INF/web.xml) will be parsed, all configured stuff will be
transparently wrapped onto the HttpService, resources will be registered
automatically, etc.
The current implementation is structured as 3 components (bundles):
1. org.eclipse.equinox.webapp.service
public interface WebAppService {
public Object registerWebApp(String webContext, Bundle bundle,
String bundleResourcePath, String webXml, Dictionary
options)
throws WebContextException;
public void unregisterWebApp(Object handle);
}
This service will be registered in the OSGi service registry, where you can
programmatically register and unregister a web application, e.g.
// when service tracker get WebAppService added
Object handle = webAppService.registerWebApp("/demo",
bundleContext.getBundle(),
"/WebContent", null /* defaults to /WebContent/WEB-INF/web.xml" */,
null);
// when service tracker get WebAppService removed
webAppService.unregisterWebApp(handle);
and handle the web application lifecycle as required by your application.
2. org.eclipse.equinox.webapp.registry
Alternately a web application can be contributed via an Eclipse extension
point:
<plugin>
<extension
id="webapp"
name="Demo Application"
point="org.eclipse.equinox.webapp.registry.webapp">
<webapp
alias="/demo"
path="/WebContent">
<!-- webXml defaults to /WebContent/WEB-INF/web.xml -->
</webapp>
</extension>
</plugin>
The bundle lifecycle follows the extension point lifecycle, so install /
uninstall will contribute / remove the web application to/from OSGi
HttpService.
3. org.eclipse.equinox.webapp.extender
The extender implementation will observe all bundles started or stopped
within the OSGi platform. If the extender file (here /WEB-INF/web.xml) is
available, the bundle is treated as a web application, and seamlessly
registered with the HttpService.
This is quite cool, as it allows for easy deployment of existing web
applications (WAR file), with the only need to OSGi'fy the WAR file as an
OSGi bundle (use bnd tool from Peter Kriens).
For example, the demo application is structured this way
demo.jar (bundle, OSGi'fyed version of demo.war)
/index.jsp
/META-INF/manifest.mf (an OSGi bundle, e.g. with)
...
Bundle-ClassPath: .,/WEB-INF/classes,/WEB-INF/lib/mylib.jar
...
/jsp/demo.jsp
/styles/base.css
/WEB-INF/web.xml
/WEB-INF/classes/*.class
/WEB-INF/lib/mylib.jar
...
The current state of implementation:
Supported features are:
- servlet and filter support
- JSP support
- welcome files
- mime-types
- a default deployment descriptor org.eclipse.equinox.webapp.service
/OSGI-INF/default-web.xml (like the catalina/conf/web.xml), where
standard servlets, mime-types etc. will be added to all web applications.
This eliminates the need to adapt the web.xml for OSGi specific
deployment, e.g. registering the JspServlet, add all the standard
mime-mappings.
The implementation requires bugfixing, more refactoring, more test cases
(lifecycle, correct registering orders, ...). Declarative security is
completely missing.
I am just starting to write some docs, adding a tutorial, sample
application, but this needs a little bit more time...
The contributed code to the bug 162132 is of 2007-09-14 is now slightly
out-of-date. If you want to give it a try, I'd encourage you to use the CVS
version, as the code is still evolving. Currently the implementation is
hosted in CVS at project sse-examples at SourceForge.net, at
:pserver:[EMAIL PROTECTED]:/cvsroot/sse-examples,
webapp-incubator
You can also use a project set file with implementation, test bundles, test
cases, few docs:
http://sse-examples.cvs.sourceforge.net/*checkout*/sse-examples/webapp-incubator/org.eclipse.equinox.webapp.docs/docs/org.eclipse.equinox.webapp-HEAD.psf?revision=1.2
Feedback is appreciated and welcome.
Regards, Jochen
_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev