01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2005-2006 Bull S.A.S
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * Initial developer(s):
22: * --------------------------------------------------------------------------
23: * $Id: ClientLBLookup.java 8414 2006-06-01 13:57:58Z duvauchn $
24: * --------------------------------------------------------------------------
25: */package org.objectweb.sampleCluster2.client;
26:
27: import java.util.Properties;
28:
29: import javax.naming.Context;
30: import javax.naming.InitialContext;
31: import javax.naming.NamingException;
32: import javax.rmi.PortableRemoteObject;
33: import org.objectweb.sampleCluster2.ejb.MyEjb1Home;
34: import org.objectweb.sampleCluster2.ejb.MyEjb1;
35:
36: /**
37: * Fat client :
38: * - access to a SSB
39: * - LB at the lookup, home, remote
40: */
41: public class ClientLBLookup {
42:
43: /**
44: * Iteration number
45: */
46: private static final int ITERATION_NB = 20;
47:
48: /**
49: * Main method
50: * @param args arguments of the client
51: */
52: public static int main(String[] args) {
53:
54: String jonasEJBServer = null;
55: String ejbTotalCallsCount = null;
56: String ejbEntityCreated = null;
57: Properties prop = null;
58:
59: for (int i = 1; i < ITERATION_NB + 1; i++) {
60: try {
61:
62: MyEjb1Home home = ClientUtility.getMyEjb1Home();
63: System.out.println("Home retrieved -> " + home);
64: //MyEjb1 bean = ClientUtility.getMyEjb1Bean(home);
65: //System.out.println("Bean created -> " + bean);
66:
67: //prop = bean.getInfoProps();
68: //System.out.println("Bean invoked");
69:
70: //jonasEJBServer = prop.getProperty("EJB server");
71: //ejbTotalCallsCount = prop.getProperty("EJB total calls");
72: //ejbEntityCreated = prop.getProperty("EJB server entity created");
73:
74: // Comments the remove() call to avoid confusing in the LB algo
75: // Indeed, the remove is equilibrated too
76: //bean.remove();
77:
78: } catch (Exception e) {
79: e.printStackTrace();
80: return -1;
81: }
82: System.out.println("\n");
83: System.out.println("Iteration=" + i
84: + " - EJB served by jonas=" + jonasEJBServer
85: + " - EJB total calls=" + ejbTotalCallsCount
86: + " - ejbEntityCreated=" + ejbEntityCreated);
87: }
88:
89: System.out.println("Client OK. Exiting.");
90: return 0;
91: }
92: }
|