| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>4.2 Creating PARs and Web Applications</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. Developing Applications"><link rel="prev" href="ch04.html" title="4. Developing Applications"><link rel="next" href="ch04s03.html" title="4.3 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 Creating PARs and Web Applications</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04.html">Prev</a> </td><th width="60%" align="center">4. Developing Applications</th><td width="20%" align="right"> <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 Creating PARs and Web Applications</h2></div></div></div><p> |
| Virgo supports two OSGi-oriented ways of packaging applications: the PAR format |
| and application bundles (including web bundles). The VTS also supports three |
| distinct WAR deployment and packaging formats: standard Java EE WAR, Shared Libraries WAR, Shared Services WAR. |
| </p><p> |
| Virgo 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 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. |
| See <a class="link" href="ch04s03.html#developing-applications-plans-scoping" title="Plans and Scoping">Plans and Scoping</a> for more on scoping. |
| </li><li>Since a PAR is scoped, its artifacts 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 bundles in a PAR file using the thread context class loader.</li><li>A PAR file is visible to management interfaces.</li><li>A PAR file can be undeployed and redeployed as a unit.</li><li> |
| A PAR file is <span class="emphasis"><em>atomic</em></span> in that it ties together the lifecycle of its artifacts. If you start, stop, or uninstall |
| one of a PAR's artifacts, Virgo escalates the operation to the whole PAR file. |
| So Virgo prevents artifacts of a PAR from being in inconsistent states. |
| For example, if one artifact should fail to start, then Virgo stops all artifacts in the PAR. |
| </li></ul></div><p> |
| See <a class="link" href="ch04s03.html#developing-applications-plans-scoping" title="Plans and Scoping">Plans and Scoping</a> for more information on scoping. |
| </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 4.1. 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’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-web-application-bundles"></a>Web Application Bundles</h3></div></div></div><p> |
| Virgo Server for Apache Tomcat supports Web Application Bundles that are compliant with the OSGi Web Applications specification. |
| The defining property of a Bundle that makes it a Web Application Bundle is a manifest header, <code class="literal">Web-ContextPath</code>. |
| This defines the context path the web application will be registered under. |
| </p><p> |
| See <a class="link" href="ch04s05.html" title="4.5 Using Spring, Spring DM, and Blueprint">Using Spring and Spring DM</a> for information on using Spring or Spring DM in a Web Application Bundle. |
| </p></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> </td><td width="20%" align="center"><a accesskey="u" href="ch04.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch04s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4. Developing Applications </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4.3 Creating Plans</td></tr></table></div></body></html> |