KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > stests > appli > A_thread


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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,v 1.4 2004/03/19 11:57:16 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.stests.appli;
27
28 import java.rmi.RemoteException JavaDoc;
29
30 import javax.ejb.RemoveException JavaDoc;
31
32
33 /**
34  * Appli Test
35  * @author Philippe Coq
36  */

37 public class A_thread extends Thread JavaDoc {
38     OrderEntryClerkHome home;
39     int num;
40     int orders;
41     int lines;
42     int numThread;
43
44     public A_thread(OrderEntryClerkHome home, int numThread, int orders, int lines) {
45         this.home = home;
46         this.numThread = numThread;
47         this.orders = orders;
48         this.lines = lines;
49     }
50
51
52     public void run() {
53
54         // Create a OrderEntryClerk bean
55
OrderEntryClerk oecbean = null;
56
57         try {
58             oecbean = home.create();
59         } catch (Exception JavaDoc e) {
60             System.out.println("Cannot Create OrderEntryClerk bean:" + e);
61             return;
62         }
63
64         try {
65             
66
67             // main loop
68
for (int i = 0; i < orders; i++) {
69                 oecbean.setCustomer(new Integer JavaDoc(numThread+1));
70                 for (int j = 0; j < lines; j++) {
71                     oecbean.addOrderLine(new Integer JavaDoc(j+1),j+2);
72                 }
73                 String JavaDoc numorder = oecbean.placeOrder();
74             }
75             // delete Session
76
oecbean.remove();
77         } catch (RemoteException JavaDoc e) {
78             System.out.println("Thread " + numThread + " : " + e);
79  
80         } catch (RemoveException JavaDoc e) {
81             System.out.println("Thread " + numThread + " Cannot remove session: " + e);
82  
83         }
84     }
85 }
86
Popular Tags