ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/agents/Handler.java
Revision: 1.1
Committed: Fri May 4 02:04:35 2001 UTC (23 years, 7 months ago) by ajm
Branch: MAIN
CVS Tags: HEAD
Log Message:
Loads of new framework but far from complete.

The BasicAgent class is as it says, a basic agent, with ability to be run from the command line to fire it into an agentstation.

AgentStations now have support for adding and removing agents and support for multiple listeners.  Also initial support for peer agent stations.  Attempted support at peer -> peer agent transfer, but run into problems.

Still no bytecode transfer, but location and method has been figured out.

The AgentSystem class is now the bootstrap class for an agent station.  It brings up the AgentStation (which is now singleton) and the Logger (also singleton - using standard i-scream logging techniques).  It is possible to specify a peer station that the booting agent station should connect to.

Initial TODO:

	agent class loader
	agent bytecode transfer
	solve peer -> peer problems - possibly by creating extra socket to send agent, but shouldn't really be needed

File Contents

# Content
1 //---PACKAGE DECLARATION---
2
3 //---IMPORTS---
4 import java.io.IOException;
5 import java.net.Socket;
6
7 /**
8 * An abstract class providing basic socket handling functionality
9 *
10 * @author $Author: tdb1 $
11 * @version $Id: TemplateClass.java,v 1.11 2001/03/22 21:50:41 tdb1 Exp $
12 */
13 abstract class Handler extends Thread {
14
15 //---FINAL / FINAL STATIC ATTRIBUTES---
16
17 /**
18 * The current CVS revision of this class
19 */
20 public static final String REVISION = "$Revision: 1.11 $";
21
22 //---STATIC METHODS---
23
24 //---CONSTRUCTORS---
25
26 public Handler(Socket socket) throws IOException {
27 _socket = socket;
28 }
29
30 //---PUBLIC METHODS---
31
32 /**
33 * Overrides the {@link java.lang.Object#toString() Object.toString()}
34 * method to provide clean logging (every class should have this).
35 *
36 * This uses the uk.ac.ukc.iscream.util.FormatName class
37 * to format the toString()
38 *
39 * @return the name of this class and its CVS revision
40 */
41 public String toString() {
42 return FormatName.getName(
43 _name,
44 getClass().getName(),
45 REVISION);
46 }
47
48 //---PRIVATE/PROTECTED METHODS---
49
50 protected void shutdownSocket() {
51 // Disconnect streams & socket
52 try {
53 _socket.close();
54 } catch (IOException e) {
55 _logger.write(toString(), Logger.ERROR, "exception on socket close");
56 }
57 }
58
59 //---ACCESSOR/MUTATOR METHODS---
60
61 //---ATTRIBUTES---
62
63 /**
64 * This is the friendly identifier of the
65 * component this class is running in.
66 * eg, a Filter may be called "filter1",
67 * If this class does not have an owning
68 * component, a name from the configuration
69 * can be placed here. This name could also
70 * be changed to null for utility classes.
71 */
72 private String _name = null;
73
74 /**
75 * This holds a reference to the
76 * system logger that is being used.
77 */
78 private Logger _logger = Logger.getInstance();
79
80 /**
81 * The socket this class uses
82 */
83 protected Socket _socket;
84
85 //---STATIC ATTRIBUTES---
86
87 }