geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Geronimo v3.0 > Using shared libraries in your applications
Date Fri, 23 Dec 2011 03:27:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/4/_/styles/combined.css?spaceKey=GMOxDOC30&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Using+shared+libraries+in+your+applications">Using
shared libraries in your applications</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~chirunhua@gmail.com">Runhua
Chi</a>
    </h4>
        <br/>
                         <h4>Changes (0)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>The server provides a common directory where you can install class files
and JAR files that can be shared by multiple Java EE assets.  Although the shared library
may not be suitable for production environments, it may be a convenient place to keep classes
or libraries while you are developing your Java EE asset.</p>
<ul>
	<li>Within the shared library, JAR file names must be unique. To prevent collisions
with other products that may use the same JAR name, avoid the shared library and place the
JAR file in the server repository instead.</li>
	<li>The shared library can only hold one version of a class file. If your server holds
several applications that depend on different versions of a particular class file, avoid the
shared library and bundle the class files into a JAR file in the server repository instead.</li>
	<li>Likewise, the shared library can only hold one version of a JAR file. If several
applications depend on different versions of a JAR file, avoid the shared library and place
the JAR file in the server repository instead.</li>
</ul>


<h1><a name="Usingsharedlibrariesinyourapplications-Configuringsharedlibraries"></a>Configuring
shared libraries</h1>

<p>You can use a reference class to the gbean <tt>org.apache.geronimo.system.sharedlib.SharedLib</tt>
so that you can use shared libraries in your applications. By default, you may put all your
libraries and classes files under &lt;Geronimo_HOME&gt;/var/shared directory, then
add a dependency to deployment plan of your application as followed.</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-xml">
...
<span class="code-tag">&lt;environment&gt;</span>
    <span class="code-tag">&lt;dependencies&gt;</span>
        <span class="code-tag">&lt;dependency&gt;</span>
            <span class="code-tag">&lt;groupId&gt;</span>org.apache.geronimo.configs<span
class="code-tag">&lt;/groupId&gt;</span>
            <span class="code-tag">&lt;artifactId&gt;</span>sharedlib<span
class="code-tag">&lt;/artifactId&gt;</span>
        <span class="code-tag">&lt;/dependency&gt;</span>
    <span class="code-tag">&lt;/dependencies&gt;</span>
 ...
<span class="code-tag">&lt;/environment&gt;</span>
...
</pre>
</div></div>

<p>You can also specify another directory rather than the default &lt;Geronimo_HOME&gt;/var/shared
directory for libraries sharing. Use the following code snippet in your deployment plan when
referring to a relative path: </p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>using
relative paths</b></div><div class="codeContent panelContent">
<pre class="code-xml">
...
 <span class="code-tag">&lt;gbean name=<span class="code-quote">"SharedLib1"</span>
class=<span class="code-quote">"org.apache.geronimo.system.sharedlib.SharedLib"</span>&gt;</span>
   <span class="code-tag">&lt;attribute name=<span class="code-quote">"baseDir"</span>&gt;</span>var/shared<span
class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"classesDirs"</span>&gt;</span>classes<span
class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"libDirs"</span>&gt;</span>lib<span
class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"ServerInfo"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>ServerInfo<span
class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
   <span class="code-tag">&lt;/gbean&gt;</span>
  ...
</pre>
</div></div>

<p>or the following code snippet when referring to an absolute path:</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>using
absolute paths</b></div><div class="codeContent panelContent">
<pre class="code-xml">
...
 <span class="code-tag">&lt;gbean name=<span class="code-quote">"SharedLib1"</span>
class=<span class="code-quote">"org.apache.geronimo.system.sharedlib.SharedLib"</span>&gt;</span>
   <span class="code-tag">&lt;attribute name=<span class="code-quote">"baseDir"</span>&gt;</span>c:/mySharedLib<span
class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"classesDirs"</span>&gt;</span>classes<span
class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;attribute name=<span class="code-quote">"libDirs"</span>&gt;</span>lib<span
class="code-tag">&lt;/attribute&gt;</span>
        <span class="code-tag">&lt;reference name=<span class="code-quote">"ServerInfo"</span>&gt;</span>
            <span class="code-tag">&lt;name&gt;</span>ServerInfo<span
class="code-tag">&lt;/name&gt;</span>
        <span class="code-tag">&lt;/reference&gt;</span>
   <span class="code-tag">&lt;/gbean&gt;</span>
  ...
</pre>
</div></div>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Using+shared+libraries+in+your+applications">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27834235&revisedVersion=3&originalVersion=2">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Using+shared+libraries+in+your+applications?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message