Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: JEE-> Java EE

...

Java EE Application Client deployment plan

Excerpt
hiddentrue

A JEE Java EE client module requires application-client.xml as deployment descriptor and geronimo-application-client.xml as deployment plan.

JEE Java EE application client modules run in client container and also have access to server environment. Usually, JEE 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 JEE Java EE way.

The JEE Java EE client module requires application-client.xml as deployment descriptor and geronimo-application-client.xml as deployment plan. In the application-client.xml, the required ejb names, security role names, resources names etc., are declared while in geronimo-application-client.xml, the declared names are mapped to actual resources in server.

The following is the deployment descriptor of the JEE 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.

...

Following is the corresponding deployment plan of the JEE Java EE client module.

Code Block
XML
XML
borderStylesolid
titlegeronimo-application-client.xml
<?xml version="1.0" encoding="UTF-8"?>

<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">
 
 <sys:client-environment>
  <sys:moduleId>
  <sys:groupId>Converter</sys:groupId>
  <sys:artifactId>Converter-app-client</sys:artifactId>
  <sys:version>3.0</sys:version>
  <sys:type>jar</sys:type>
  </sys:moduleId>
</sys:client-environment>
  
  <sys:server-environment> 
   <sys:moduleId>
   <sys:groupId>Converter</sys:groupId>
   <sys:artifactId>Converter-app-client-server</sys:artifactId>
   <sys:version>3.0</sys:version>
   <sys:type>jar</sys:type>
   </sys:moduleId>    		
  </sys:server-environment> 
    
     <ejb-ref>
     	<ref-name>ejb/Converter</ref-name>
     	<naming:pattern>
         <naming:groupId>Converter</naming:groupId>
         <naming:artifactId>ConverterEAR</naming:artifactId>
         <naming:version>5.0</naming:version>
         <naming:module>ConverterEJB.jar</naming:module>
         <naming:name>ConverterBean</naming:name>
       </naming:pattern>
     </ejb-ref>
     
</application-client>

...

Code Block
JAVA
JAVA
borderStylesolid
titleConverterClient.java
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
 //JEEJava 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();
        }
    }
}

...

Warning

Do not forget to insert a new line after the Main-Class: entry in the MANIFEST.MF file.

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

...