1 7 package org.jboss.tutorial.mcdeploy; 8 9 import java.util.Hashtable ; 10 import javax.naming.InitialContext ; 11 import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap; 12 13 19 public class Main 20 { 21 public static void main(String [] args) throws Exception 22 { 23 EJB3StandaloneBootstrap.boot(null); 24 EJB3StandaloneBootstrap.deployXmlResource("ejb3-deployment.xml"); 25 26 InitialContext ctx = getInitialContext(); 27 CustomerDAOLocal local = (CustomerDAOLocal)ctx.lookup(CustomerDAOLocal.class.getName()); 28 CustomerDAORemote remote = (CustomerDAORemote)ctx.lookup(CustomerDAORemote.class.getName()); 29 30 System.out.println("----------------------------------------------------------"); 31 32 int id = local.createCustomer("Gavin"); 33 Customer cust = local.findCustomer(id); 34 System.out.println("Successfully created and found Gavin from @Local interface"); 35 36 id = remote.createCustomer("Emmanuel"); 37 cust = remote.findCustomer(id); 38 System.out.println("Successfully created and found Emmanuel from @Remote interface"); 39 System.out.println("----------------------------------------------------------"); 40 41 } 42 43 public static InitialContext getInitialContext() throws Exception 44 { 45 Hashtable props = getInitialContextProperties(); 46 return new InitialContext (props); 47 } 48 49 private static Hashtable getInitialContextProperties() 50 { 51 Hashtable props = new Hashtable (); 52 props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory"); 53 props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); 54 return props; 55 } 56 } 57 | Popular Tags |