| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>6.3 Form Tags Shared Libraries WAR</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="ch06.html" title="6. Case Study: Migrating the Form Tags Sample Application"><link rel="prev" href="ch06s02.html" title="6.2 Form Tags WAR"><link rel="next" href="ch06s04.html" title="6.4 Form Tags Shared Services WAR"><!--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">6.3 Form Tags Shared Libraries WAR</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch06s02.html">Prev</a> </td><th width="60%" align="center">6. Case Study: Migrating the Form Tags Sample Application</th><td width="20%" align="right"> <a accesskey="n" href="ch06s04.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="formtags-case-study-war-shared-libs"></a>6.3 Form Tags Shared Libraries WAR</h2></div></div></div><p> |
| As mentioned above, a standard WAR file typically packages of all its |
| required |
| dependencies in |
| <code class="literal">WEB-INF/lib</code> |
| . The servlet container will |
| then add all of the JARs in |
| <code class="literal">WEB-INF/lib</code> |
| to the application’s |
| classpath. |
| </p><p> |
| The first step of the migration towards benefiting from an OSGi |
| container is to retrieve the dependencies from the |
| VTS’s bundle |
| repository at runtime. This |
| can significantly reduce the time it takes to build |
| and deploy the |
| application. It also enables the enforcement of policies |
| regarding the |
| use of third-party libraries. |
| </p><p> |
| The way in which dependencies are declared in an OSGi environment is |
| via manifest headers in a bundle’s |
| <code class="literal">/META-INF/MANIFEST.MF</code> |
| . |
| As mentioned in |
| <a class="xref" href="ch04.html" title="4. Developing Applications">Chapter 4, <i>Developing Applications</i></a> |
| , there are |
| three ways of expressing dependencies: |
| <code class="literal">Import-Package</code> |
| , |
| <code class="literal">Import-Bundle</code> |
| and |
| <code class="literal">Import-Library</code> |
| . |
| </p><p> |
| The Form Tags application uses JSTL standard tag libraries. |
| Thus, you |
| need to choose a JSTL provider, for example the |
| Apache implementation |
| which comes with the VTS. To use the |
| Apache |
| implementation of JSTL, you need to express your dependency |
| as |
| outlined in the following manifest listing. |
| Because it is a single |
| bundle, |
| <code class="literal">Import-Bundle</code> |
| is |
| the simplest and therefore preferred manifest header to use. |
| </p><p> |
| The Form Tags application requires commons-logging and Spring. |
| It |
| would be very painful to have to list all the Spring packages one by |
| one. |
| Equally, considering the number of bundles that make up the |
| Spring framework, it would be verbose to list each bundle. Therefore |
| <code class="literal">Import-Library</code> |
| is the preferred approach |
| for expressing the dependency on the Spring |
| framework. |
| </p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.gif"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p> |
| How do you determine the name of a library definition provided |
| by the |
| Virgo Server for Apache Tomcat? |
| Use the |
| <a class="ulink" href="http://www.springsource.com/repository" target="_top">SpringSource Enterprise Bundle Repository</a> |
| . |
| </p></td></tr></table></div><p> |
| Examine the |
| <code class="literal">/META-INF/MANIFEST.MF</code> |
| in |
| <code class="literal">/dist/formtags-shared-libs-*.war</code> |
| : |
| </p><pre class="programlisting"> |
| Manifest-Version: 1.0 |
| Ant-Version: Apache Ant 1.7.0 |
| Created-By: 1.5.0_13-119 (Apple Inc.) |
| Bundle-ManifestVersion: 2 |
| Bundle-SymbolicName: org.springframework.showcase.formtags-shared-libs |
| <span class="bold"><strong>Import-Library</strong></span>: org.springframework.spring;version="[3.0.0,4.0.0)" |
| <span class="bold"><strong>Import-Bundle</strong></span>: com.springsource.org.apache.taglibs.standard;version="1 |
| .1.2" |
| </pre><p> |
| You can see the |
| <code class="literal">Import-Library</code> |
| and |
| <code class="literal">Import-Bundle</code> |
| directives that instruct the VTS to add the |
| appropriate package imports to the bundle |
| classpath used by this WAR file. |
| </p><p> |
| Deploying the shared libraries WAR onto the |
| VTS should result |
| in console output similar to |
| the following: |
| </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.gif"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>The console output has been reformatted to fit this document. |
| </p></td></tr></table></div><pre class="programlisting"> |
| [2009-07-01 15:00:14.953] fs-watcher |
| <SPDE0048I> Processing 'CREATED' event for file 'formtags-shared-libs-3.0.0.RELEASE.war'. |
| [2009-07-01 15:00:15.363] fs-watcher |
| <SPDE0010I> Deployment of 'org.springframework.showcase.formtags_shared_libs' version '2' completed. |
| [2009-07-01 15:00:15.364] Thread-20 |
| <SPWE0000I> Starting web bundle '/formtags-shared-libs-3.0.0.RELEASE'. |
| [2009-07-01 15:00:15.816] Thread-20 |
| <SPWE0001I> Started web bundle '/formtags-shared-libs-3.0.0.RELEASE'. |
| </pre><p> |
| Navigating to |
| <code class="literal">http://localhost:8080/formtags-shared-libs-BUILDTAG |
| </code> |
| should render the welcome page. Note that for the pre-packaged |
| distributable, |
| the |
| <code class="literal">BUILDTAG</code> |
| should be similar to |
| <code class="literal">3.0.0.RELEASE</code> |
| ; |
| whereas, for a local build the |
| <code class="literal">-BUILDTAG</code> |
| may be completely |
| omitted. Please consult the console output, |
| web-based admin console, or log |
| to determine the exact context path |
| under which the web application has been deployed. |
| </p></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="ch06s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch06.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch06s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6.2 Form Tags WAR </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 6.4 Form Tags Shared Services WAR</td></tr></table></div></body></html> |