Java Reference
In-Depth Information
<reference name="webcontainer"
interface="org.ops4j.pax.web.service.WebContainer"
cardinality="1..1"
policy="static"
bind="bindWebContainer"
unbind="unbindWebContainer"
/>
</component>
You specify the component implementation class and declare the component as
immediate , so an instance is created as soon as the component's dependencies are sat-
isfied. Then you specify a one-to-one dependency on a WebContainer service, which
you want injected into your component using the specified binding methods. We'll
leave it as an exercise for you, but you can trivially extend this to use the Bundle-
Tracker approach from listing 15.2 to track JSP bundles centrally, rather than dupli-
cating binding logic in different bundles.
To see this example running, go into the chapter15/pax-web/ directory of the
topic's companion code. Type ant to build the example and java -jar launcher.jar
bundles to execute it. To see the shopping-cart
application in action, go to http://localhost:
8080/jsps/catalog.jsp. When you do, you should
see a simple shopping cart page. Add a couple of
items to the cart to verify that it works, as shown in
figure 15.4.
We've shown you how to deploy a range of
web-application technologies from static
resources to servlets to JSP s using the HTTP Ser-
vice or its extensions. This may leave you wonder-
ing, “What about my WAR files?” Good question.
In the next section, we'll look at the standard way
to deal with WAR files in OSG i.
Figure 15.4 JSP shopping cart
application running in an OSGi
environment
15.1.2
Using the Web Applications specification
Since the Servlet 2.2 specification came out in August 1999, we've been packaging and
deploying servlets, JSP s, and other web technologies in WAR files. WAR files provide a
standard way to map a range of web technologies to a servlet-container context.
Despite the widespread use of WAR files, until recently there was no standard way to
use WAR files in an OSG i framework. Due to the increasing use of OSG i technology in
the enterprise domain, member companies in the OSG i Alliance are now producing
enterprise-related specifications.
The OSG i R4.2 Enterprise specification is the result of this effort. The Enterprise
specification defines another set of compendium specifications specifically targeting
enterprise technologies. One of these specifications is the Web Applications specifica-
tion, which provides a standard way for servlet and JSP application components to exe-
cute within an OSG i framework by defining a web application bundle ( WAB ).
Search WWH ::




Custom Search