org.glassfish.osgiweb
Class WebBundleURLStreamHandlerService

java.lang.Object
  extended by java.net.URLStreamHandler
      extended by org.osgi.service.url.AbstractURLStreamHandlerService
          extended by org.glassfish.osgiweb.WebBundleURLStreamHandlerService
All Implemented Interfaces:
org.osgi.service.url.URLStreamHandlerService

public class WebBundleURLStreamHandlerService
extends org.osgi.service.url.AbstractURLStreamHandlerService

A URLStreamHandlerService for webbundle scheme. It is responsible for not only adding necessary OSGi headers to transform a plain vanilla web app to a Web App Bundle (WAB), but also setting appropriate parameters in the URL object to meet spec's requirement as described below:

The java.net.URL object for a webbundle URL must return the String webbundle when the getProtocol method is called. The embedded URL must be returned in full from the getPath method. The parameters for processing manifest must be returned from the getQuery() method.

Some form of embedded URL also contain query parameters and this must be supported. Thus the value returned from getPath may contain a URL query. Any implementation must take care to preserve both the query parameters for the embedded URL as well as the webbundle URL. A question mark must always follow the embedded URL to simplify this processing. The following example shows an HTTP URL with some query parameter:

webbundle:https://localhost:1234/some/path/?war=example.war?Web-ContextPath=/foo

In this case getPath method of the webbundle URL must return: https://localhost:1234/some/path/?war=example.war

All the parameters in the webbundle: URL are optional except for the Web-ContextPath parameter. The parameter names are case insensitive, but their values must be treated as case sensitive. Since Web-ContextPath url parameter is mandatory, the query component can never be empty: webbundle:http://www.acme.com:8021/sales.war?

Author:
Sanjeeb.Sahoo@Sun.COM

Field Summary
 
Fields inherited from class org.osgi.service.url.AbstractURLStreamHandlerService
realHandler
 
Constructor Summary
WebBundleURLStreamHandlerService()
           
 
Method Summary
 java.net.URLConnection openConnection(java.net.URL u)
           
protected  void setURL(java.net.URL u, java.lang.String proto, java.lang.String host, int port, java.lang.String auth, java.lang.String user, java.lang.String path, java.lang.String query, java.lang.String ref)
           
 
Methods inherited from class org.osgi.service.url.AbstractURLStreamHandlerService
equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, parseURL, sameFile, setURL, toExternalForm
 
Methods inherited from class java.net.URLStreamHandler
openConnection, parseURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebBundleURLStreamHandlerService

public WebBundleURLStreamHandlerService()
Method Detail

openConnection

public java.net.URLConnection openConnection(java.net.URL u)
                                      throws java.io.IOException
Specified by:
openConnection in interface org.osgi.service.url.URLStreamHandlerService
Specified by:
openConnection in class org.osgi.service.url.AbstractURLStreamHandlerService
Throws:
java.io.IOException

setURL

protected void setURL(java.net.URL u,
                      java.lang.String proto,
                      java.lang.String host,
                      int port,
                      java.lang.String auth,
                      java.lang.String user,
                      java.lang.String path,
                      java.lang.String query,
                      java.lang.String ref)
Overrides:
setURL in class org.osgi.service.url.AbstractURLStreamHandlerService


Copyright © 2011 GlassFish Community. All Rights Reserved.