|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
dist1.acb.common.transport.AbstractClientSocket
Abstract class for threaded model of client socket. The class manages outcoming requests.
| Nested Class Summary | |
static class |
AbstractClientSocket.SocketAndStreams
Container for three objects: Socket, ObjectOutputStream and ObjectInputStream |
| Field Summary | |
protected boolean |
isShutdowned
|
protected java.util.logging.Logger |
log
|
protected ObjectStreamFactory |
objectStreamFactory
|
protected java.net.Socket |
socket
|
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
AbstractClientSocket(java.lang.ThreadGroup group)
Creates a new instance of AbstractClientSocket |
|
AbstractClientSocket(java.lang.ThreadGroup group,
boolean doNotConnectInParentThread)
Creates a new AbstractClientSocket object. |
|
| Method Summary | |
void |
connect()
Connect to the next server |
static AbstractClientSocket.SocketAndStreams |
connect(java.net.InetSocketAddress serverAddr,
java.lang.String className,
java.util.logging.Logger log)
Create connected socket and related streams |
static AbstractClientSocket.SocketAndStreams |
connect(java.net.InetSocketAddress serverAddr,
java.lang.String className,
java.util.logging.Logger log,
ObjectStreamFactory osf)
Create connected socket and related streams |
Response |
getResponse(Request request)
Get respons to the request. |
java.net.InetSocketAddress |
getServerAddr()
Getter for property serverAddr. |
java.util.LinkedList |
getServersAddresses()
Getter for property serversAddresses. |
protected abstract void |
handleConnectionEstablished()
|
protected abstract boolean |
handleConnectionLost()
|
protected void |
handleResponseToNoRequest(Response response)
|
protected abstract void |
handleUnrecoverableError(java.lang.Throwable e)
|
boolean |
isConnected()
Returns the connection state of the socket. |
protected Response |
receiveResponse()
Private static function for receiving a response. |
Response |
request(Request request)
Send the request and receive a response from the server in same thread. |
static Response |
request(Request request,
java.io.ObjectInputStream in,
java.io.ObjectOutputStream out,
java.util.logging.Logger log)
Used by a modles which use direct exchange of messages |
void |
run()
Main processing method for the ConnectionServer object |
void |
scheduleRequest(Request request)
Schedules equest to the server. |
void |
setServersAddresses(java.util.LinkedList serversAddresses)
Setter for property serversAddresses. |
void |
start()
Initiate connection to the server and if succeed, causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.logging.Logger log
protected ObjectStreamFactory objectStreamFactory
protected java.net.Socket socket
protected boolean isShutdowned
| Constructor Detail |
public AbstractClientSocket(java.lang.ThreadGroup group)
group - Thread group to which current thread will be related
public AbstractClientSocket(java.lang.ThreadGroup group,
boolean doNotConnectInParentThread)
group - DOCUMENT ME!doNotConnectInParentThread - DOCUMENT ME!| Method Detail |
public boolean isConnected()
public Response getResponse(Request request)
request - A request to search for response
public java.net.InetSocketAddress getServerAddr()
public void setServersAddresses(java.util.LinkedList serversAddresses)
throws java.lang.RuntimeException
serversAddresses - New value of property serversAddresses.
java.lang.RuntimeException - if contains less then 1 elementpublic java.util.LinkedList getServersAddresses()
public static AbstractClientSocket.SocketAndStreams connect(java.net.InetSocketAddress serverAddr,
java.lang.String className,
java.util.logging.Logger log)
throws java.lang.ClassNotFoundException,
java.io.IOException
serverAddr - DestinationclassName - Requester of the connectionlog - A logger
java.lang.ClassNotFoundException - if class with name className was not
found
java.io.IOException - if some input-output exception occured
public static AbstractClientSocket.SocketAndStreams connect(java.net.InetSocketAddress serverAddr,
java.lang.String className,
java.util.logging.Logger log,
ObjectStreamFactory osf)
throws java.lang.ClassNotFoundException,
java.io.IOException
serverAddr - DestinationclassName - Requester of the connectionlog - A loggerosf - ObjectStreamFactory for constructing streams
java.lang.ClassNotFoundException - if class with name className was not
found
java.io.IOException - if some input-output exception occuredpublic void connect()
public Response request(Request request)
throws java.lang.InterruptedException,
java.lang.ClassNotFoundException,
java.io.IOException
request - Request to send
java.lang.InterruptedException - The thread was interrupted.
java.lang.ClassNotFoundException - if received from the server class was not
found
java.io.IOException - if handleConnectionLost() returns false
public static Response request(Request request,
java.io.ObjectInputStream in,
java.io.ObjectOutputStream out,
java.util.logging.Logger log)
throws java.lang.InterruptedException,
java.lang.ClassNotFoundException,
java.io.IOException,
java.lang.ClassCastException
request - Requestin - Input stream from where to receive a Responseout - Output stream where to send a Requestlog - A logger
java.lang.InterruptedException - Current thread was interrupted
java.lang.ClassNotFoundException - If we received a class that we haven't
localy
java.io.IOException - An input exception
java.lang.ClassCastException - if received object can not be casted to
Responsepublic void run()
java.lang.InterruptedException - DOCUMENT ME!public void scheduleRequest(Request request)
request - Request to sendpublic void start()
protected abstract void handleConnectionEstablished()
protected abstract boolean handleConnectionLost()
protected void handleResponseToNoRequest(Response response)
protected abstract void handleUnrecoverableError(java.lang.Throwable e)
protected Response receiveResponse()
throws java.lang.InterruptedException,
java.io.IOException,
java.lang.ClassNotFoundException
java.lang.InterruptedException - Current thread was interrupted
java.io.IOException - An input exception
java.lang.ClassNotFoundException - If we received a class that we haven't
localy
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||