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: ClientLBHome.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 home, remote
40: */
41: public class ClientLBHome {
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: System.out.println("Trying to retieve Home");
60: MyEjb1Home home = ClientUtility.getMyEjb1Home();
61: System.out.println("Home retrieved -> " + home);
62:
63: for (int i = 1; i < ITERATION_NB + 1; i++) {
64: try {
65: MyEjb1 bean = ClientUtility.getMyEjb1Bean(home);
66: System.out.println("Bean created -> " + bean);
67:
68: //prop = bean.getInfoProps();
69: //System.out.println("Bean invoked");
70:
71: //jonasEJBServer = prop.getProperty("EJB server");
72: //ejbTotalCallsCount = prop.getProperty("EJB total calls");
73: //ejbEntityCreated = prop.getProperty("EJB server entity created");
74:
75: // Comments the remove() call to avoid confusing in the LB algo
76: // Indeed, the remove is equilibrated too
77: //bean.remove();
78:
79: } catch (Exception e) {
80: e.printStackTrace();
81: return -1;
82: }
83: System.out.println("\n");
84: System.out.println("Iteration=" + i
85: + " - EJB served by jonas=" + jonasEJBServer
86: + " - EJB total calls=" + ejbTotalCallsCount
87: + " - ejbEntityCreated=" + ejbEntityCreated);
88: }
89:
90: System.out.println("Client OK. Exiting.");
91: return 0;
92: }
93: }
|