KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > mcdeploy > Main


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.mcdeploy;
8
9 import java.util.Hashtable JavaDoc;
10 import javax.naming.InitialContext JavaDoc;
11 import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
12
13 /**
14  * Comment
15  *
16  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
17  * @version $Revision: 1.1 $
18  */

19 public class Main
20 {
21    public static void main(String JavaDoc[] args) throws Exception JavaDoc
22    {
23       EJB3StandaloneBootstrap.boot(null);
24       EJB3StandaloneBootstrap.deployXmlResource("ejb3-deployment.xml");
25
26       InitialContext JavaDoc 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 JavaDoc getInitialContext() throws Exception JavaDoc
44    {
45       Hashtable JavaDoc props = getInitialContextProperties();
46       return new InitialContext JavaDoc(props);
47    }
48
49    private static Hashtable JavaDoc getInitialContextProperties()
50    {
51       Hashtable JavaDoc props = new Hashtable JavaDoc();
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