Dysoweb
A Dysoweb application is at the same time an OSGi bundle and a mini "Web archive" (War) with some specificities (at least for the structure of the Web application)
OSGi Bundle
An OSGi bundle is usually a Jar file (altough at least Equinox and Felix support bundles as exploded directories) that contains some specific information in the manifest.
Therefore, a Dysoweb application will get the following from its bundle structure:
- META-INF/MANIFEST.MF
Contains the Bundle name, symbolic name, and version.
Activator : A java class that will be called when the application is started (see extensive OSGi litterature on the subject)
The activator must declare a "WebAppService" that will be used by the Dysoweb processor to register the application:
/*
- (non-Javadoc)
- @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
fWebApp = context.registerService(WebAppService.class.getName(),
new WebAppService(context.getBundle()) { },
null);
}
/*
- (non-Javadoc)
- @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
unregister the web app service
fWebApp.unregister();
fWebApp = null;
}
Class path
This is an important point, since WEB apps and OSGi bundles have a different way of specifiying which classes should be loaded.
In DysoWeb, the classes and librairies (jar) are loaded according to the OSGi spec, and are '''NOT loaded from WEB-INF/classes or WEB-INF/lib'''. They are loaded from the regular bundle class path (by default .), but it can be specified by the "Bundle-ClassPath" header in the manifest of the bundle.
Manifest Example
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test Plug-in
Bundle-SymbolicName: com.requea.test
Bundle-Version: 1.0.0
Bundle-Activator: com.requea.test.Activator
Import-Package: com.requea.dysoweb,
org.osgi.framework;version="1.3.0"
Bundle-ClassPath: bin/,
.,
lib/commons-lang-2.1.jar,
lib/commons-resources.jar
Web App
The Web application content (static files, JSP, TLD, WEB-INF/web.xml) are put in the webapp directory in the bundle:
Therefore, the structure of a Dysoweb app looks like:
web.xml
The web.xml defined in webapp/WEB-INF/web.xml has a typical servlet application structure. You can define servlets, servlets mappings, filter and filter mappings.
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<display-name>Demo4 WebApp</display-name>
<servlet>
<servlet-name>voteServlet</servlet-name>
<servlet-class>com.requea.dysoweb.demo4.VoteServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>voteServlet</servlet-name>
<url-pattern>/demo4/vote</url-pattern>
</servlet-mapping>
</web-app>