KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > packaging > client > Client


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

8
9 package org.jboss.tutorial.packaging.client;
10
11 import javax.naming.InitialContext JavaDoc;
12 import org.jboss.tutorial.packaging.bean.Session2;
13 import org.jboss.tutorial.packaging.bean.Session1;
14 import org.jboss.tutorial.packaging.bean.Entity1;
15 import org.jboss.tutorial.packaging.bean.Entity2;
16
17 /**
18  * Sample client for the jboss container.
19  *
20  * @author <a HREF="mailto:bill@burkecentral.com">Bill Burke</a>
21  * @version $Id: Client.java,v 1.1.2.2 2005/06/24 05:26:33 bill Exp $
22  */

23
24 public class Client
25 {
26
27    public static void main(String JavaDoc[] args) throws Exception JavaDoc
28    {
29       Session1 session1 = (Session1) getInitialContext().lookup(Session1.class.getName());
30       Session2 session2 = (Session2) getInitialContext().lookup(Session2.class.getName());
31
32       int oneF = session1.create1FromFactory();
33       int oneM = session1.create1FromManager();
34       int twoF = session1.create2FromFactory();
35       int twoM = session1.create2FromManager();
36
37       Entity1 one = session2.find1FromFactory(oneF);
38       System.out.println("factory: " + one.getString());
39
40       one = session2.find1FromManager(oneM);
41       System.out.println("manager: " + one.getString());
42
43
44       Entity2 two = session2.find2FromFactory(twoF);
45       System.out.println("factory: " + two.getString());
46
47       two = session2.find2FromManager(twoM);
48       System.out.println("manager: " + two.getString());
49    }
50
51    public static InitialContext JavaDoc getInitialContext() throws Exception JavaDoc
52    {
53       return new InitialContext JavaDoc();
54    }
55
56
57
58 }
59
Popular Tags