1 22 package org.jboss.tutorial.ejb21_client_adaptors.client; 23 24 import org.jboss.tutorial.ejb21_client_adaptors.bean.Session1RemoteHome; 25 import org.jboss.tutorial.ejb21_client_adaptors.bean.Session1Remote; 26 27 import javax.naming.InitialContext ; 28 29 public class Client 30 { 31 public static void main(String [] args) throws Exception 32 { 33 accessHomes(); 34 35 accessDeploymentDescriptorHomes(); 36 } 37 38 public static void accessHomes() throws Exception 39 { 40 InitialContext jndiContext = new InitialContext (); 41 Session1RemoteHome home = (Session1RemoteHome)jndiContext.lookup("Session1RemoteHome"); 42 Session1Remote session1 = home.create(); 43 String initValue1 = session1.getInitValue(); 44 System.out.println("Session1 init value is " + initValue1); 45 46 String initValue2 = session1.getLocalSession2InitValue(); 47 System.out.println("Session2 init value is " + initValue2); 48 } 49 50 public static void accessDeploymentDescriptorHomes() throws Exception 51 { 52 InitialContext jndiContext = new InitialContext (); 53 Session1RemoteHome home = (Session1RemoteHome)jndiContext.lookup("DeploymentDescriptorSession1RemoteHome"); 54 Session1Remote session1 = home.create(); 55 String initValue1 = session1.getInitValue(); 56 System.out.println("DeploymentDescriptor Session1 init value is " + initValue1); 57 58 String initValue2 = session1.getLocalSession2InitValue(); 59 System.out.println("DeploymentDescriptor Session2 init value is " + initValue2); 60 } 61 } 62 | Popular Tags |