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