|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.echomine.net.Connection
com.echomine.net.TimeableConnection
com.echomine.net.SocketConnector
public class SocketConnector
Makes a connection to a remote client using TCP protocol. The connector is synchronous and asynchronous; Asynchronous connections have methods that begin with an "a" (ie. aconnect). This class is simply a helper class so you don't have to deal with the connection details. Most of the details should still be implemented by the writer in the SocketHandler instances.
There are four ways to call connect. Aside from the synchronous and asynchronous, the choice is yours to use an internal socket handler or pass in your own external socket handler. The connector is basically amphibious, acting both as an instance-based single-threaded object (ie. one connector per connection) and a non-instance-based multi-threaded object (ie. one connector for multiple handlers/connections). The recommended usage is: if you require listening to connection events for each connection made, then instantiate a connector for each handler (a 1-to-1 connector-handler pairing); if you don't care about connection events (or if your handler fires its own events that you need), then you can instantiate one connector for multiple handlers (ie. a 1-to-many connector-handler pairing).
This class also fully support SSL connections. Certain properties can be set to change the location on where to look for the keystore, passphrase, etc.
The SSL-related key property names are: com.echomine.net.keyStorePath, com.echomine.netkeyStorePassphrase, com.echomine.net.trustManager. By default, the keystore is ~/.keystore, the passphrase is empty, and trust manager uses com.echomine.util.SimpleTrustManager.
Field Summary |
---|
Fields inherited from class com.echomine.net.Connection |
---|
listenerList |
Constructor Summary | |
---|---|
SocketConnector()
Do-nothing constructor. |
|
SocketConnector(SocketHandler socketHandler)
|
Method Summary | |
---|---|
void |
aconnect(ConnectionModel connectionModel)
makes a connection asynchronously using internal socket handler. |
void |
aconnect(SocketHandler socketHandler,
ConnectionModel connectionModel)
makes a connection asynchronously. |
void |
connect(ConnectionModel connectionModel)
Synchronous connect method using internal socket handler. |
void |
connect(SocketHandler socketHandler,
ConnectionModel connectionModel)
Synchronous connect method. |
SocketHandler |
getSocketHandler()
|
void |
setSocketHandler(SocketHandler socketHandler)
|
Methods inherited from class com.echomine.net.TimeableConnection |
---|
fireConnectionClosed, fireConnectionEstablished |
Methods inherited from class com.echomine.net.Connection |
---|
addConnectionListener, fireConnectionStarting, fireConnectionStartingWithoutVeto, removeConnectionListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SocketConnector(SocketHandler socketHandler)
public SocketConnector()
Method Detail |
---|
public void connect(ConnectionModel connectionModel) throws ConnectionFailedException
ConnectionFailedException
public void connect(SocketHandler socketHandler, ConnectionModel connectionModel) throws ConnectionFailedException
ConnectionFailedException
public void aconnect(ConnectionModel connectionModel)
public void aconnect(SocketHandler socketHandler, ConnectionModel connectionModel)
public SocketHandler getSocketHandler()
public void setSocketHandler(SocketHandler socketHandler)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |