geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Geronimo v2.2 > Creating deployment plans for Java EE application clients
Date Mon, 27 Jul 2009 01:49:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=GMOxDOC22&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Creating+deployment+plans+for+Java+EE+application+clients">Creating
deployment plans for Java EE application clients</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~sophia">Ying
Tang</a>
    </h4>
     JEE-&gt; Java EE
          <div id="versionComment" class="noteMacro" style="display:none; padding: 5px;">
     JEE-&gt; Java EE<br />
     </div>
          <br/>
     <div class="notificationGreySide">
         <h1><a name="CreatingdeploymentplansforJavaEEapplicationclients-JavaEEApplicationClientdeploymentplan"></a>Java
EE Application Client deployment plan</h1>


<p>Java EE application client modules run in client container and also have access to
server environment. Usually, Java EE client applications are created to administer the running
enterprise applications in the server. Client modules run in a separate JVM and connect to
enterprise application resources but have access to all the application resources in standard
Java EE way.</p>

<p>The Java EE client module requires <a href="http://java.sun.com/xml/ns/javaee/application-client_5.xsd"
rel="nofollow">application-client.xml</a> as deployment descriptor and <a href="http://geronimo.apache.org/schemas-2.1/docs/geronimo-application-client-2.0.xsd.html"
rel="nofollow">geronimo-application-client.xml</a> as deployment plan. In the <tt>application-client.xml</tt>,
the required ejb names, security role names, resources names etc., are declared while in <tt>geronimo-application-client.xml</tt>,
the declared names are mapped to actual resources in server.</p>

<p>The following is the deployment descriptor of the Java EE application client module
that looks up an ejb and calls a method on it. The ejb converts the Indian Rupess (Rs.) into
American Dollars ($). The client sends a double value which is Indian Rupees to ejb. The ejb
returns equivalent American Dollars as double value. </p>

<style type="text/css">
@import url(/confluence/download/resources/confluence.ext.code:code/shStyles.css);
</style>
<!--[if IE]>
<style type="text/css">
    .code textarea, .code input { padding: 0 !important; }
</style>
<![endif]-->
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly">&lt;?xml
version="1.0" encoding="UTF-8"?&gt;

&lt;application-client xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/application-client_5.xsd"
  version="5"&gt;
    
  &lt;ejb-ref&gt;
    &lt;ejb-ref-name&gt;ejb/Converter&lt;/ejb-ref-name&gt;
    &lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt;
    &lt;remote&gt;examples.appclient.Converter&lt;/remote&gt;
  &lt;/ejb-ref&gt;

&lt;/application-client&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>The default namespace of the above
XML document is <tt><a href="http://java.sun.com/xml/ns/javaee" rel="nofollow">http://java.sun.com/xml/ns/javaee</a></tt>.
The XML elements that do not have a namespace prefix belong to the default namespace. Hence,
in the above XML document, all the XML elements belong to the default namespace.</td></tr></table></div>
<p>The application client declares the ejb name <tt>ejb/Converter</tt> through
<tt>&lt;ejb-ref&gt;&gt;</tt> .. <tt>&lt;/ejb-ref&gt;</tt>
elements.</p>

<p>Following is the corresponding deployment plan of the Java EE client module.</p>

<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly">&lt;?xml
version="1.0" encoding="UTF-8"?&gt;

&lt;application-client xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"
  xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
  xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
  xmlns:security="http://geronimo.apache.org/xml/ns/security-2.0"
  xmlns:connector="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"&gt;
 
 &lt;sys:client-environment&gt;
  &lt;sys:moduleId&gt;
  &lt;sys:groupId&gt;Converter&lt;/sys:groupId&gt;
  &lt;sys:artifactId&gt;Converter-app-client&lt;/sys:artifactId&gt;
  &lt;sys:version&gt;3.0&lt;/sys:version&gt;
  &lt;sys:type&gt;jar&lt;/sys:type&gt;
  &lt;/sys:moduleId&gt;
&lt;/sys:client-environment&gt;
  
  &lt;sys:server-environment&gt; 
   &lt;sys:moduleId&gt;
   &lt;sys:groupId&gt;Converter&lt;/sys:groupId&gt;
   &lt;sys:artifactId&gt;Converter-app-client-server&lt;/sys:artifactId&gt;
   &lt;sys:version&gt;3.0&lt;/sys:version&gt;
   &lt;sys:type&gt;jar&lt;/sys:type&gt;
   &lt;/sys:moduleId&gt;    		
  &lt;/sys:server-environment&gt; 
    
     &lt;ejb-ref&gt;
     	&lt;ref-name&gt;ejb/Converter&lt;/ref-name&gt;
     	&lt;naming:pattern&gt;
         &lt;naming:groupId&gt;Converter&lt;/naming:groupId&gt;
         &lt;naming:artifactId&gt;ConverterEAR&lt;/naming:artifactId&gt;
         &lt;naming:version&gt;5.0&lt;/naming:version&gt;
         &lt;naming:module&gt;ConverterEJB.jar&lt;/naming:module&gt;
         &lt;naming:name&gt;ConverterBean&lt;/naming:name&gt;
       &lt;/naming:pattern&gt;
     &lt;/ejb-ref&gt;
     
&lt;/application-client&gt;</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>The default namespace of the above
XML document is <tt><a href="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"
rel="nofollow">http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0</a></tt>.
The XML elements that do not have a namespace prefix belong to the default namespace. Hence,
in the above XML document, <tt>&lt;application-client&gt;</tt>, <tt>&lt;ejb-ref&gt;</tt>
and <tt>&lt;ref-name&gt;</tt> elements belong to the default namespace.</td></tr></table></div>

<p>Observe the various xml elements and schemas to which they belong. The plan defines
the client environment and the server environment configurations. The server environment configuration
runs in the server where as the client environment configuration runs in the client JVM. In
the above plan, the ejb name <tt>ejb/Converter</tt> is mapped to <tt>ConverterBean</tt>
ejb in the <tt>ConverterEAR</tt>.</p>

<p>The below is the client code that looks up the ejb and calls the method on it.</p>

<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">package
examples.appclient.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import examples.appclient.Converter;

public class ConverterClient {

 //The remote interface of the ConverterBean packaged with the
 //Java EE client jar
   private static Converter converter;

   private static double amount = 50;
   public static void main(String[] args) {
    amount = Double.parseDouble(args[0]);
    doConversion();
   }

    public static void doConversion() {
     try {
            
        Context context = new InitialContext();
        converter = (Converter) 
                 context.lookup("java:comp/env/ejb/Converter");
        double dollars = converter.getDollars(amount);
        System.out.println("Rs " + amount + " is " + dollars + " Dollars.");
        System.exit(0);
            
        } catch (Exception ex) {
            System.err.println("Caught an unexpected exception!");
            ex.printStackTrace();
        }
    }
}</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<p>The <tt>META-INF/MANIFEST.MF</tt> file should contain the following entry
for the client to run.</p>
<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly">Manifest-Version:
1.0
Main-Class: examples.appclient.client.ConverterClient</textarea>
<script class="javascript">
    if(!window.newcodemacro_initialised)
    {
        window.newcodemacro_initialised = true;
        window.oldonloadmethod = window.onload;
        window.onload = function(){
            dp.SyntaxHighlighter.HighlightAll('newcodemacro');
            if(window.oldonloadmethod)
            {
                window.oldonloadmethod();
            }
        }
    }

</script>
</div>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td>Do not forget to insert
a new line after the Main-Class: entry in the MANIFEST.MF  file.</td></tr></table></div>

<p>The Java EE client is created by packaging <tt>META-INF/application-client.xml</tt>,
<tt>META-INF/geronimo-application-client.xml</tt>, <tt>ConverterClient.class</tt>,
<tt>Converter.class</tt> and <tt>META-INF/MANIFEST.MF</tt> files into
a jar file.</p>

<p>The following command illustrates the packaging.<br/>
<font color="white">
<div class="preformatted panel" style="background-color: #000000;border-style: solid;border-width:
1px;"><div class="preformattedContent panelContent" style="background-color: #000000;">
<pre>C:\temp\ConverterEJBClient&gt;jar -cvf ConverterEJBClient.jar *
added manifest
adding: examples/(in = 0) (out= 0)(stored 0%)
adding: examples/appclient/(in = 0) (out= 0)(stored 0%)
adding: examples/appclient/client/(in = 0) (out= 0)(stored 0%)
adding: examples/appclient/client/ConverterClient.class(in = 1716) (out= 936)(deflated 45%)
adding: examples/appclient/Converter.class(in = 146) (out= 131)(deflated 10%)
adding: META-INF/application-client.xml(in = 510) (out= 252)(deflated 50%)
adding: META-INF/geronimo-application-client.xml(in = 2049) (out= 474)(deflated 76%)
ignoring entry META-INF/MANIFEST.MF
</pre>
</div></div></font></p>

<p>The following commands illustrates the deployment and running of the client module.<br/>
<font color="white">
<div class="preformatted panel" style="background-color: #000000;border-style: solid;border-width:
1px;"><div class="preformattedContent panelContent" style="background-color: #000000;">
<pre>C:\\Geronimo-2.1\bin&gt;deploy.bat --user system --password manager deploy
C:\temp\ConverterEJBClient.jar
Using GERONIMO_BASE:   C:\Geronimo-2.1
Using GERONIMO_HOME:   C:\Geronimo-2.1
Using GERONIMO_TMPDIR: var\temp
Using JRE_HOME:        C:\JDK\jre
    Deployed Converter/Converter-app-client-server/3.0/jar

C:\Geronimo-2.1\bin&gt;java -Djava.endorsed.dirs="C:\Geronimo-2.1\lib\endorsed" -jar
              C:\Geronimo-2.1\bin\client.jar Converter/Converter-app-client/3.0/jar 4000

Rs 4000.0 is 100.0 Dollars.
</pre>
</div></div></font></p>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Creating+deployment+plans+for+Java+EE+application+clients">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=102904&revisedVersion=4&originalVersion=3">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/GMOxDOC22/Creating+deployment+plans+for+Java+EE+application+clients?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message