blob: c320c16b5e81aa658c09ca78683a09d5c4aad233 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>4.2&nbsp;Creating PARs and WARs</title><link rel="stylesheet" href="css/stylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="Virgo Programmer Guide"><link rel="up" href="ch04.html" title="4.&nbsp;Developing Applications"><link rel="prev" href="ch04.html" title="4.&nbsp;Developing Applications"><link rel="next" href="ch04s03.html" title="4.3&nbsp;Creating Plans"><!--Begin Google Analytics code--><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
var pageTracker = _gat._getTracker("UA-2728886-3");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
</script><!--End Google Analytics code--></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.2&nbsp;Creating PARs and WARs</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04.html">Prev</a>&nbsp;</td><th width="60%" align="center">4.&nbsp;Developing Applications</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ch04s03.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="developing-applications-packaging"></a>4.2&nbsp;Creating PARs and WARs</h2></div></div></div><p>
The Virgo Web Server supports two OSGi-oriented ways of packaging applications: the PAR format
and application bundles (including web bundles). The VWS also supports three
distinct WAR deployment and packaging formats: standard Java EE WAR, Shared Libraries WAR, Shared Services WAR.
</p><p>
The VWS also supports plans as a way to describe an application. This method is similar to a PAR
in that it encapsulates all the artifacts of an application as a single unit, but differs in that a plan simply
lists the bundles in an XML file rather than packaging all the bundles in a single JAR file. The use of plans
offers additional benefits to using PARs; for this reason, we recommend their use. For details, see
<a class="link" href="ch04s03.html" title="4.3&nbsp;Creating Plans">Creating Plans</a>.
</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="developing-applications-packaging-par"></a>PARs</h3></div></div></div><p>
An OSGi application is packaged as a JAR file, with extension <code class="literal">.par</code>. A PAR artifact offers several benefits:
</p><div class="itemizedlist"><ul type="disc"><li>A PAR file has an application name, version, symbolic name, and description.</li><li>The artifacts of a PAR file are scoped so that they cannot
be shared accidentally by other applications. The scope forms a boundary for automatic
propagation of load time weaving and bundle refresh.</li><li>The artifacts of a PAR have their exported packages imported by the
synthetic context bundle which is used for thread context class loading. So,
for example, hibernate will be able to load classes of any of the exported
packages of the artifacts in a PAR file using <code class="code">Class.forName()</code> (or equivalent).</li><li>The PAR file is visible to management interfaces.</li><li>The PAR file can be undeployed and redeployed as a unit.</li></ul></div><p>
</p><p>
A PAR includes one or more application bundles and its manifest specifies the following
manifest headers:
</p><div class="table"><a name="developing-applications-packaging-par-headers-table"></a><p class="title"><b>Table&nbsp;4.1.&nbsp;PAR file headers</b></p><div class="table-contents"><table summary="PAR file headers" style="border-collapse: collapse;border-top: 1.0pt solid ; border-bottom: 1.0pt solid ; border-left: 1.0pt solid ; border-right: 1.0pt solid ; "><colgroup><col><col></colgroup><thead><tr><th style="border-right: 1.0pt solid ; border-bottom: 1.0pt solid ; ">Header</th><th style="border-bottom: 1.0pt solid ; ">Description</th></tr></thead><tbody><tr><td style="border-right: 1.0pt solid ; border-bottom: 1.0pt solid ; "><code class="literal">Application-SymbolicName</code></td><td style="border-bottom: 1.0pt solid ; ">Identifier for the application which, in combination with Application-Version, uniquely identifies an application</td></tr><tr><td style="border-right: 1.0pt solid ; border-bottom: 1.0pt solid ; "><code class="literal">Application-Name</code></td><td style="border-bottom: 1.0pt solid ; ">Human readable name of the application</td></tr><tr><td style="border-right: 1.0pt solid ; border-bottom: 1.0pt solid ; "><code class="literal">Application-Version</code></td><td style="border-bottom: 1.0pt solid ; ">Version of the application</td></tr><tr><td style="border-right: 1.0pt solid ; "><code class="literal">Application-Description</code></td><td style="">Short description of the application</td></tr></tbody></table></div></div><p><br class="table-break">
</p><p>
The following code shows an example MANIFEST.MF in a PAR file:
</p><pre class="programlisting"><span class="bold"><strong>Application-SymbolicName</strong></span>: com.example.shop
<span class="bold"><strong>Application-Version</strong></span>: 1.0
<span class="bold"><strong>Application-Name</strong></span>: Online Shop
<span class="bold"><strong>Application-Description</strong></span>: Example.com&#8217;s Online Shopping Application</pre><p>
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="developing-applications-packaging-web-modules"></a>Web Modules</h3></div></div></div><p>
As discussed earlier, Web Modules are no longer supported in VWS. Instead, we recommend that you
use Shared Service WARs or Web Application Bundles that are compliant with the OSGi Web Applications specification.
</p><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="developing-applications-packaging-web-module-to-war"></a>Migrating to a Web Application Bundle from a Web Module</h4></div></div></div><p>
To move from a Web Module to a Web Container-compliant Web Bundle you need to follow these four steps:
</p><div class="orderedlist"><ol type="1"><li>Remove the <code class="literal">Module-Type</code> manifest header</li><li>Replace any <code class="literal">Web-DispatcherServletUrlPatterns</code> header with the corresponding
servlet entries in <code class="literal">web.xml</code></li><li>Replace any <code class="literal">Web-FilterMappings</code> header with the corresponding filter
entries in <code class="literal">web.xml</code></li><li>Move all content in <code class="literal">MODULE-INF</code> to the root of the WAR</li></ol></div><p>
</p><div class="section" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="developing-applications-packaging-web-module-to-war-ds"></a>Removing <code class="literal">Web-DispatcherServletUrlPatterns</code></h5></div></div></div><p>
To remove a <code class="literal">Web-DispatcherServletUrlPatterns</code> header such as
<code class="literal">Web-DispatcherServletUrlPatterns: *.htm</code>, start by declaring
a <code class="classname">DispatcherServlet</code> in <code class="literal">web.xml</code>:
</p><pre class="programlisting">&lt;servlet&gt;
&lt;servlet-name&gt;dispatcher.myapp&lt;/servlet-name&gt;
&lt;servlet-<span class="hl-keyword">class</span>&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-<span class="hl-keyword">class</span>&gt;
&lt;/servlet&gt;</pre><p>
For every mapping in the <code class="literal">DispatcherServletUrlPatterns</code> header, create the
corresponding <code class="literal">servlet-mapping</code>:
</p><pre class="programlisting">&lt;servlet-mapping&gt;
&lt;servlet-name&gt;dispatcher.myapp&lt;/servlet-name&gt;
&lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h5 class="title"><a name="developing-applications-packaging-web-module-to-war-filter"></a>Removing <code class="literal">Web-FilterMappings</code></h5></div></div></div><p>
To remove a <code class="literal">Web-FilterMappings</code> header such as
<code class="literal">Web-FilterMappings: myfilter;url-patterns:="*.htm"</code>, start by declaring
<code class="classname">DelegatingFilterProxy</code> in <code class="literal">web.xml</code> for each filter listed:
</p><pre class="programlisting">&lt;filter&gt;
&lt;filter-name&gt;myfilter&lt;/filter-name&gt;
&lt;filter-<span class="hl-keyword">class</span>&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-<span class="hl-keyword">class</span>&gt;
&lt;/filter&gt;</pre><p>
For every mapping listed for the filter create the
corresponding <code class="literal">filter-mapping</code>:
</p><pre class="programlisting">&lt;filter-mapping&gt;
&lt;filter-name&gt;myfilter&lt;/filter-name&gt;
&lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;</pre></div></div></div></div><!--Begin LoopFuse code--><script src="http://loopfuse.net/webrecorder/js/listen.js" type="text/javascript"></script><script type="text/javascript">
_lf_cid = "LF_48be82fa";
_lf_remora();
</script><!--End LoopFuse code--><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ch04.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ch04s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.&nbsp;Developing Applications&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;4.3&nbsp;Creating Plans</td></tr></table></div></body></html>