01: /*
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
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: * --------------------------------------------------------------------------
22: * $Id: A_thread.java 4406 2004-03-19 11:57:20Z benoitf $
23: * --------------------------------------------------------------------------
24: */
25:
26: package org.objectweb.jonas.stests.appli;
27:
28: import java.rmi.RemoteException;
29:
30: import javax.ejb.RemoveException;
31:
32: /**
33: * Appli Test
34: * @author Philippe Coq
35: */
36: public class A_thread extends Thread {
37: OrderEntryClerkHome home;
38: int num;
39: int orders;
40: int lines;
41: int numThread;
42:
43: public A_thread(OrderEntryClerkHome home, int numThread,
44: int orders, int lines) {
45: this .home = home;
46: this .numThread = numThread;
47: this .orders = orders;
48: this .lines = lines;
49: }
50:
51: public void run() {
52:
53: // Create a OrderEntryClerk bean
54: OrderEntryClerk oecbean = null;
55:
56: try {
57: oecbean = home.create();
58: } catch (Exception e) {
59: System.out.println("Cannot Create OrderEntryClerk bean:"
60: + e);
61: return;
62: }
63:
64: try {
65:
66: // main loop
67: for (int i = 0; i < orders; i++) {
68: oecbean.setCustomer(new Integer(numThread + 1));
69: for (int j = 0; j < lines; j++) {
70: oecbean.addOrderLine(new Integer(j + 1), j + 2);
71: }
72: String numorder = oecbean.placeOrder();
73: }
74: // delete Session
75: oecbean.remove();
76: } catch (RemoteException e) {
77: System.out.println("Thread " + numThread + " : " + e);
78:
79: } catch (RemoveException e) {
80: System.out.println("Thread " + numThread
81: + " Cannot remove session: " + e);
82:
83: }
84: }
85: }
|