01: /*
02: * CoadunationLib: The coaduntion implementation library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * CoadunationThread.java
20: *
21: * The coadunation thread class.
22: */
23:
24: // package path
25: package com.rift.coad.lib.thread;
26:
27: import com.rift.coad.lib.security.UserSession;
28:
29: /**
30: * The coadunation thread class.
31: *
32: * @author Brett Chaldecott
33: */
34: public class CoadunationThread extends BasicThread {
35:
36: /**
37: *
38: * Creates a new instance of CoadunationThread
39: */
40: public CoadunationThread() throws Exception {
41: }
42:
43: /**
44: *
45: * Creates a new instance of CoadunationThread setting the runnable reference.
46: *
47: *
48: * @param runnable The reference to the runnable object.
49: */
50: public CoadunationThread(BasicRunnable runnable) throws Exception {
51: super (runnable);
52: }
53:
54: /**
55: * This method cannot be used on a coadunation thread.
56: */
57: public void start() throws IllegalThreadStateException {
58: throw new IllegalThreadStateException(
59: "Cannot user this method use"
60: + " start(Username) instead");
61: }
62:
63: /**
64: * This method overrides the start method to bind this thread to the
65: * thread group.
66: *
67: * @exception IllegalThreadStateException
68: */
69: public void start(String username)
70: throws IllegalThreadStateException {
71: try {
72: ThreadGroupManager.getInstance().addThreadToGroup(this ,
73: username);
74: super .start();
75: } catch (Exception ex) {
76: throw new IllegalThreadStateException(
77: "Failed to start the thread : " + ex.getMessage());
78: }
79: }
80: }
|