|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sshtools.j2ssh.transport.Service
The service class provides a mechanisnm for the ssh services provided by the transport layer. It is itself a thread and contains a message loop in which all registered messages will be routed to onMessageReceived()
Constructor Summary | |
Service(java.lang.String serviceName)
Constructor for the SshService object |
Method Summary | |
protected byte[] |
getExchangeHash()
Gets the exchange hash produced from key exchange |
protected SshMessageStore |
getMessageStore()
Gets the service's message store. |
java.lang.String |
getServiceName()
Returns the name of the service. |
protected TransportProtocol |
getTransportLayer()
Gets the transport mechanism for this service |
protected abstract void |
onDisconnect(java.lang.String reason)
Abstract method called by the framework when the remote computer disconnects. |
protected abstract void |
onMessageReceived(SshMessage msg)
Abstract method called when a registered message ahs been received. |
protected abstract void |
onServiceAccept()
Abstract method called when the service has been accepted by the remote computer. |
protected abstract void |
onServiceInit()
Abstract method called when the service is initialized. |
protected abstract void |
onServiceRequest()
Abstract method called when the service has been requested. |
protected abstract void |
onThreadException(java.lang.Exception e)
Abstract method that is called by the framework whenever an exception occurs in a child thread. |
void |
run()
Provides the message loop. |
void |
start(TransportProtocol transport,
ServiceState state,
byte[] exchangeHash)
This method is called by the framework to initialize the service after it has been created. |
void |
stop()
Stops the message loop and causes the thread to exit |
protected SshMessage |
waitForSingleMessage(int[] messageIdFilter)
Gets or waits for a single message from the message store. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Service(java.lang.String serviceName)
serviceName
- The service nameMethod Detail |
public final void start(TransportProtocol transport, ServiceState state, byte[] exchangeHash) throws ServiceOperationException
This method is called by the framework to initialize the service after it has been created. Subclasses should implement the abstract method onServiceInit() which is called from this method. Depending upon the state of the service passed to the init method one of the abstract methods onServiceAccept() or onServiceRequest() is then called.
transport
- The transport layer object used for
communicationstate
- The state of the service
(Accepted/Requested)exchangeHash
- The exchange hash
ServiceOperationException
- Can be thrown from abstract method
implementationsprotected final byte[] getExchangeHash()
protected final TransportProtocol getTransportLayer()
protected abstract void onServiceInit() throws ServiceOperationException
Abstract method called when the service is initialized.
NOTE: The message loop is not started until this method has completed.
ServiceOperationException
- This exception can be thrown by
subclassesprotected abstract void onServiceAccept() throws ServiceOperationException
Abstract method called when the service has been accepted by the remote computer.
NOTE: the message loop does not start until this method has completed.
ServiceOperationException
- This exception can be thrown by
subclassesprotected abstract void onServiceRequest() throws ServiceOperationException
Abstract method called when the service has been requested.
ServiceOperationException
- This exception can be thrown by
subclassesprotected abstract void onThreadException(java.lang.Exception e)
Abstract method that is called by the framework whenever an exception occurs in a child thread. This is to avoid any exception being written to System.out.
e
- The exception thrownprotected abstract void onDisconnect(java.lang.String reason)
Abstract method called by the framework when the remote computer disconnects.
reason
- The reason for the disconnection.protected final SshMessageStore getMessageStore()
Gets the service's message store.
protected SshMessage waitForSingleMessage(int[] messageIdFilter) throws TransportProtocolException, ServiceOperationException
Gets or waits for a single message from the message store. If the message filter is null then the next available message is returned. To filter for specific messages then create an int array containing the message id's for the messages you are prepared to accept.
messageIdFilter
- Description of the Parameter
TransportProtocolException
- Description of the Exception
ServiceOperationException
- Description of the Exceptionpublic final void run()
Provides the message loop.
run
in interface java.lang.Runnable
public final void stop()
public final java.lang.String getServiceName()
Returns the name of the service.
protected abstract void onMessageReceived(SshMessage msg) throws ServiceOperationException, TransportProtocolException
Abstract method called when a registered message ahs been received.
msg
- The message received
ServiceOperationException
- Subclasses can throw this
exception
TransportProtocolException
- Subclasses can throw this
exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |