Java Reference
In-Depth Information
WAB is pretty much a standard WAR file that has been converted into a bundle. More
specifically, it's a WAR file that adheres to the Servlet 2.5 and JSP 2.1 specifications and
additionally declares its dependencies using the standard OSG i metadata. To demon-
strate the process of creating a WAB , you'll take the stock-watcher application from the
GWT tutorial and convert it to run in an OSG i context. You can use bnd to convert the
WAR file generated by the GWT build into a bundle using the following Ant target:
<target name="osgi">
<path id="bnd.class.path">
<fileset dir="${root.dir}/lib" includes="osgi.*.jar"/>
<fileset dir="build" includes="*.war"/>
</path>
<mkdir dir="../bundles" />
<pathconvert pathsep=":" property="bnd.cp" refid="bnd.class.path"/>
<bnd files="build.properties" classpath="${bnd.cp}" exceptions="true"/>
</target>
Bnd takes its configuration properties from the build.properties file in the same direc-
tory, which contains the following:
Bundle-SymbolicName: com.google.gwt.sample.stockwatcher
Bundle-ClassPath: WEB-INF/lib/gwt-servlet.jar,WEB-INF/classes
Include-Resource: war
Import-Package: \
com.google.gwt.benchmarks;resolution:=optional,\
junit.framework;resolution:=optional,\
*
Web-ContextPath: /stockwatcher/stockPrices
Most of these headers look similar to those introduced in chapter 2; if you aren't
familiar with bnd syntax, refer to appendix A. Briefly, you first specify the bundle sym-
bolic name for your WAB . Next, you set up the bundle class path to include the gwt-
servlet.jar file, which is embedded in the WAR file, and the WEB-INF /classes directory,
which contains the classes of your application. You embed the various resources used
by this application, including JavaScript files and images. Then you specify two
optional package imports that are only used in testing scenarios.
The only new header here is Web-ContextPath . It's used to identify the bundle as a
WAB . The header is used by the web container extender bundle. This bundle is defined in
the Web Application specification; it uses the extender pattern, which we discussed in
chapter 3, to track bundles with the Web-ContextPath header and register the servlet
resources specified in these WAB s as a web application, similar to the previous exam-
ples in this chapter. The value of this header specifies the context root that the web
container uses to register the web application. All web-accessible resources in the bun-
dle are served up relative to this path.
Before we delve any further into the inner workings of WAB files, let's launch the
GWT application to show it in action. Go into the chapter15/gwtapp/ directory of the
topic's companion code. Type ant to build the example and java -jar launcher.jar
bundles to execute it. Browse to http://localhost:8080/stockwatcher/stockPrices/,
which should look something like figure 15.5.
Search WWH ::




Custom Search