|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.rdg.resc.jstyx.client.StyxConnection
public class StyxConnection
Object representing a client connection to a Styx server.
| Constructor Summary | |
|---|---|
StyxConnection(java.lang.String host,
int port)
Creates a new instance of StyxConnection, connecting as an anonymous user |
|
StyxConnection(java.lang.String host,
int port,
int maxMessageSizeRequest)
Creates a new instance of StyxConnection, connecting as an anonymous user |
|
StyxConnection(java.lang.String host,
int port,
java.lang.String username,
java.lang.String password)
Uses DEFAULT_MAX_MESSAGE_SIZE_REQUEST |
|
StyxConnection(java.lang.String host,
int port,
java.lang.String username,
java.lang.String password,
int maxMessageSizeRequest)
Creates a new instance of StyxConnection. |
|
| Method Summary | |
|---|---|
void |
addListener(StyxConnectionListener listener)
Adds a StyxConnectionListener to this connection. |
void |
close()
Overrides the close() method in Session. |
void |
connect()
Connects to the remote server and handshakes. |
void |
connectAsync()
Connects to the remote server and handshakes. |
void |
exceptionCaught(org.apache.mina.protocol.ProtocolSession session,
java.lang.Throwable cause)
Called when an exception is caught by MINA; fires the connectError() event on all registered listeners and closes the connection. |
java.lang.String |
getContents(java.lang.String path)
Gets the entire contents of a file as a single string. |
CStyxFile |
getFile(java.lang.String path)
Gets a CStyxFile with the given path. |
long |
getFreeFid()
|
int |
getMaxMessageSize()
|
java.lang.String |
getRemoteHost()
|
int |
getRemotePort()
|
CStyxFile |
getRootDirectory()
Gets the CStyxFile representing the root directory of the remote Styx server |
long |
getRootFid()
|
void |
messageReceived(org.apache.mina.protocol.ProtocolSession session,
java.lang.Object message)
Called when a reply has arrived from a Styx server |
void |
messageSent(org.apache.mina.protocol.ProtocolSession session,
java.lang.Object message)
Called by MINA when a message has been sent |
CStyxFile |
openFile(java.lang.String path,
int mode)
Opens a file on the server, throwing a StyxException if the file can't be found or opened in the given mode. |
void |
removeListener(StyxConnectionListener listener)
Removes the given listener; does nothing if the listener has not been registered with this.addListener(). |
void |
returnFid(long fid)
Returns the given fid back to the pool |
StyxMessage |
send(StyxMessage message)
Sends a message and blocks until the corresponding reply arrives |
int |
sendAsync(StyxMessage tMessage,
MessageCallback callback)
Sends a message and returns its tag. |
int |
sendAsync(StyxMessage tMessage,
MessageCallback callback,
boolean isHandshake)
Sends a message and returns its tag. |
void |
sessionClosed(org.apache.mina.protocol.ProtocolSession session)
Called when the connection is closed |
void |
sessionCreated(org.apache.mina.protocol.ProtocolSession session)
Invoked when the session is created. |
void |
sessionIdle(org.apache.mina.protocol.ProtocolSession session,
org.apache.mina.common.IdleStatus status)
Required by the ProtocolHandler interface. |
void |
sessionOpened(org.apache.mina.protocol.ProtocolSession session)
Called when the socket connection to the remote server has been established |
void |
setMaxMessageSize(int maxMessageSize)
Sets the maximum size of message that can be sent on this connection |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StyxConnection(java.lang.String host,
int port,
java.lang.String username,
java.lang.String password,
int maxMessageSizeRequest)
public StyxConnection(java.lang.String host,
int port,
java.lang.String username,
java.lang.String password)
public StyxConnection(java.lang.String host,
int port,
int maxMessageSizeRequest)
public StyxConnection(java.lang.String host,
int port)
| Method Detail |
|---|
public java.lang.String getRemoteHost()
public int getRemotePort()
public void connectAsync()
throws StyxException
StyxException - if the IOProcessor could not be started
public void connect()
throws StyxException
StyxException - if the IOProcessor could not be started or if
an error occurred during connection or handshakingpublic void close()
public CStyxFile getRootDirectory()
public int sendAsync(StyxMessage tMessage,
MessageCallback callback)
tMessage - the message to be sentcallback - the MessageCallback to be called when the reply arrives
public int sendAsync(StyxMessage tMessage,
MessageCallback callback,
boolean isHandshake)
tMessage - the message to be sentcallback - the MessageCallback to be called when the reply arrivesisHandshake - if true, this message is part of the connection process
itself (e.g. authentication)
public StyxMessage send(StyxMessage message)
throws StyxException
StyxException - if the message type is not as expected, or if the
connection has not been made.
public void messageReceived(org.apache.mina.protocol.ProtocolSession session,
java.lang.Object message)
messageReceived in interface org.apache.mina.protocol.ProtocolHandlerpublic long getFreeFid()
public void returnFid(long fid)
public long getRootFid()
public int getMaxMessageSize()
public void setMaxMessageSize(int maxMessageSize)
public void sessionCreated(org.apache.mina.protocol.ProtocolSession session)
throws java.lang.Exception
sessionCreated in interface org.apache.mina.protocol.ProtocolHandlerjava.lang.Exceptionpublic void sessionOpened(org.apache.mina.protocol.ProtocolSession session)
sessionOpened in interface org.apache.mina.protocol.ProtocolHandlerpublic void sessionClosed(org.apache.mina.protocol.ProtocolSession session)
sessionClosed in interface org.apache.mina.protocol.ProtocolHandler
public void exceptionCaught(org.apache.mina.protocol.ProtocolSession session,
java.lang.Throwable cause)
exceptionCaught in interface org.apache.mina.protocol.ProtocolHandlerpublic CStyxFile getFile(java.lang.String path)
InvalidPathException - if the given path is not valid and absolute
(only catch this runtime exception if it is likely that the path could be
invalid, e.g. when the path is being input by a user)
public CStyxFile openFile(java.lang.String path,
int mode)
throws StyxException
path - The path of the file relative to the server root.mode - Integer representing the mode - see the constants in StyxUtils.
For example, to open a file for reading, use StyxUtils.OREAD. To open a
file for writing with truncation use StyxUtils.OWRITE | StyxUtils.OTRUNC.
StyxException
public java.lang.String getContents(java.lang.String path)
throws StyxException
path - The path of the file relative to the server root.
StyxExceptionpublic void addListener(StyxConnectionListener listener)
public void removeListener(StyxConnectionListener listener)
public void messageSent(org.apache.mina.protocol.ProtocolSession session,
java.lang.Object message)
messageSent in interface org.apache.mina.protocol.ProtocolHandler
public void sessionIdle(org.apache.mina.protocol.ProtocolSession session,
org.apache.mina.common.IdleStatus status)
sessionIdle in interface org.apache.mina.protocol.ProtocolHandler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||