org.eclipse.jetty.osgi.boot.internal.webapp
Class WebBundleDeployerHelper

java.lang.Object
  extended by org.eclipse.jetty.osgi.boot.internal.webapp.WebBundleDeployerHelper
All Implemented Interfaces:
IWebBundleDeployerHelper

public class WebBundleDeployerHelper
extends Object
implements IWebBundleDeployerHelper

Bridges the jetty deployers with the OSGi lifecycle where applications are managed inside OSGi-bundles.

This class should be called as a consequence of the activation of a new service that is a ContextHandler.
This way the new webapps are exposed as OSGi services.

Helper methods to register a bundle that is a web-application or a context.

Limitations:


Field Summary
static BundleClassLoaderHelper BUNDLE_CLASS_LOADER_HELPER
          By default set to: DefaultBundleClassLoaderHelper.
static BundleFileLocatorHelper BUNDLE_FILE_LOCATOR_HELPER
          By default set to: DefaultBundleClassLoaderHelper.
static Collection<WebappRegistrationCustomizer> JSP_REGISTRATION_HELPERS
          By default set to: DefaultBundleClassLoaderHelper.
 
Fields inherited from interface org.eclipse.jetty.osgi.boot.internal.webapp.IWebBundleDeployerHelper
INTERNAL_SERVICE_PROP_UNKNOWN_CONTEXT_HANDLER_TYPE
 
Constructor Summary
WebBundleDeployerHelper(ServerInstanceWrapper wrapper)
           
 
Method Summary
protected  void configureWebappClassLoader(org.osgi.framework.Bundle contributor, ContextHandler context, OSGiWebappClassLoader webappClassLoader)
          Configure a classloader onto the context.
protected  void configureWebAppContext(ContextHandler wah, org.osgi.framework.Bundle contributor, String requireTldBundle)
          Applies the properties of WebAppDeployer as defined in jetty.xml.
protected  ContextHandler createContextHandler(ContextHandler handlerToConfigure, org.osgi.framework.Bundle bundle, File contextFile, String extraClasspath, String overrideBundleInstallLocation, String requireTldBundle)
           
protected  ContextHandler createContextHandler(ContextHandler handlerToConfigure, org.osgi.framework.Bundle bundle, InputStream contextInputStream, String extraClasspath, String overrideBundleInstallLocation, String requireTldBundle)
           
protected  OSGiWebappClassLoader createWebappClassLoader(org.osgi.framework.Bundle contributor)
          No matter what the type of webapp, we create a WebappClassLoader.
 ContextHandler registerContext(org.osgi.framework.Bundle contributor, String contextFileRelativePath, String extraClasspath, String overrideBundleInstallLocation, String requireTldBundle, ContextHandler handler)
          This type of registration relies on jetty's complete context xml file.
 WebAppContext registerWebapplication(org.osgi.framework.Bundle bundle, String webappFolderPath, String contextPath, String extraClasspath, String overrideBundleInstallLocation, String requireTldBundle, String webXmlPath, String defaultWebXmlPath, WebAppContext webAppContext)
          Deploy a new web application on the jetty server.
static void staticInit()
           
 void unregister(ContextHandler contextHandler)
          Stop a ContextHandler and remove it from the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUNDLE_CLASS_LOADER_HELPER

public static BundleClassLoaderHelper BUNDLE_CLASS_LOADER_HELPER
By default set to: DefaultBundleClassLoaderHelper. It supports equinox and apache-felix fragment bundles that are specific to an OSGi implementation should set a different implementation.


BUNDLE_FILE_LOCATOR_HELPER

public static BundleFileLocatorHelper BUNDLE_FILE_LOCATOR_HELPER
By default set to: DefaultBundleClassLoaderHelper. It supports equinox and apache-felix fragment bundles that are specific to an OSGi implementation should set a different implementation.


JSP_REGISTRATION_HELPERS

public static Collection<WebappRegistrationCustomizer> JSP_REGISTRATION_HELPERS
By default set to: DefaultBundleClassLoaderHelper. It supports equinox and apache-felix fragment bundles that are specific to an OSGi implementation should set a different implementation.

Several of those objects can be added here: For example we could have an optional fragment that setups a specific implementation of JSF for the whole of jetty-osgi.

Constructor Detail

WebBundleDeployerHelper

public WebBundleDeployerHelper(ServerInstanceWrapper wrapper)
Method Detail

staticInit

public static void staticInit()

registerWebapplication

public WebAppContext registerWebapplication(org.osgi.framework.Bundle bundle,
                                            String webappFolderPath,
                                            String contextPath,
                                            String extraClasspath,
                                            String overrideBundleInstallLocation,
                                            String requireTldBundle,
                                            String webXmlPath,
                                            String defaultWebXmlPath,
                                            WebAppContext webAppContext)
                                     throws Exception
Deploy a new web application on the jetty server.

Specified by:
registerWebapplication in interface IWebBundleDeployerHelper
Parameters:
bundle - The bundle
webappFolderPath - The path to the root of the webapp. Must be a path relative to bundle; either an absolute path.
contextPath - The context path. Must start with "/"
extraClasspath -
overrideBundleInstallLocation -
requireTldBundle - The list of bundles's symbolic names that contain tld files that are required by this WAB.
webXmlPath -
defaultWebXmlPath - TODO: parameter description
Returns:
The contexthandler created and started
Throws:
Exception

unregister

public void unregister(ContextHandler contextHandler)
                throws Exception
Description copied from interface: IWebBundleDeployerHelper
Stop a ContextHandler and remove it from the collection.

Specified by:
unregister in interface IWebBundleDeployerHelper
Throws:
Exception
See Also:
ContextDeployer.undeploy(java.lang.String)

registerContext

public ContextHandler registerContext(org.osgi.framework.Bundle contributor,
                                      String contextFileRelativePath,
                                      String extraClasspath,
                                      String overrideBundleInstallLocation,
                                      String requireTldBundle,
                                      ContextHandler handler)
                               throws Exception
Description copied from interface: IWebBundleDeployerHelper
This type of registration relies on jetty's complete context xml file. Context encompasses jndi and all other things. This makes the definition of the webapp a lot more self-contained.

Specified by:
registerContext in interface IWebBundleDeployerHelper
requireTldBundle - The list of bundles'symbolic name that contain tld files for this webapp.
handler - the context handler passed in the server reference that will be configured, deployed and started.
Returns:
The contexthandler created and started
Throws:
Exception

configureWebAppContext

protected void configureWebAppContext(ContextHandler wah,
                                      org.osgi.framework.Bundle contributor,
                                      String requireTldBundle)
Applies the properties of WebAppDeployer as defined in jetty.xml.

See Also:
around the comment // configure it

createContextHandler

protected ContextHandler createContextHandler(ContextHandler handlerToConfigure,
                                              org.osgi.framework.Bundle bundle,
                                              File contextFile,
                                              String extraClasspath,
                                              String overrideBundleInstallLocation,
                                              String requireTldBundle)
Parameters:
contextFile -
Returns:

createContextHandler

protected ContextHandler createContextHandler(ContextHandler handlerToConfigure,
                                              org.osgi.framework.Bundle bundle,
                                              InputStream contextInputStream,
                                              String extraClasspath,
                                              String overrideBundleInstallLocation,
                                              String requireTldBundle)
Parameters:
contextFile -
Returns:

configureWebappClassLoader

protected void configureWebappClassLoader(org.osgi.framework.Bundle contributor,
                                          ContextHandler context,
                                          OSGiWebappClassLoader webappClassLoader)
                                   throws Exception
Configure a classloader onto the context. If the context is a WebAppContext, build a WebAppClassLoader that has access to all the jetty classes thanks to the classloader of the JettyBootStrapper bundle and also has access to the classloader of the bundle that defines this context.

If the context is not a WebAppContext, same but with a simpler URLClassLoader. Note that the URLClassLoader is pretty much fake: it delegate all actual classloading to the parent classloaders.

The URL[] returned by the URLClassLoader create contained specifically the jars that some j2ee tools expect and look into. For example the jars that contain tld files for jasper's jstl support.

Also as the jars in the lib folder and the classes in the classes folder might already be in the OSGi classloader we filter them out of the WebAppClassLoader

Parameters:
context -
contributor -
webapp -
contextPath -
classInBundle -
Throws:
Exception

createWebappClassLoader

protected OSGiWebappClassLoader createWebappClassLoader(org.osgi.framework.Bundle contributor)
                                                 throws Exception
No matter what the type of webapp, we create a WebappClassLoader.

Throws:
Exception


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.