Package com.sshtools.j2ssh.transport
Class AsyncService
- java.lang.Object
-
- com.sshtools.j2ssh.transport.Service
-
- com.sshtools.j2ssh.transport.AsyncService
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
AuthenticationProtocolServer,ConnectionProtocol
public abstract class AsyncService extends Service implements java.lang.Runnable
Extends the simple
Serviceclass to provide an asyncronous messaging service for the transport protocol.- Since:
- 0.2.0
- Version:
- $Revision: 1.28 $
- Author:
- Lee David Painter
-
-
Field Summary
Fields Modifier and Type Field Description protected SshThreadthread-
Fields inherited from class com.sshtools.j2ssh.transport.Service
ACCEPTING_SERVICE, messageStore, REQUESTING_SERVICE, startMode, state, transport
-
-
Constructor Summary
Constructors Constructor Description AsyncService(java.lang.String serviceName)Constructs an asyncronous service.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract int[]getAsyncMessageFilter()Implement this method by returning the message ids of the asyncrounous messages your implementation wants to receive.protected abstract voidonMessageReceived(SshMessage msg)Called by the service thread when an asyncronous message is received.protected voidonStart()Implements the abstractServicemethod and starts the service thread.protected abstract voidonStop()The service thread calls this method when the thread is exiting.voidrun()Implements the asyncronous services message loop.-
Methods inherited from class com.sshtools.j2ssh.transport.Service
getServiceName, getState, init, onServiceAccept, onServiceInit, onServiceRequest, sendServiceAccept, start, stop
-
-
-
-
Field Detail
-
thread
protected SshThread thread
-
-
Method Detail
-
onStart
protected void onStart() throws java.io.IOExceptionImplements the abstract
Servicemethod and starts the service thread.
-
run
public final void run()
Implements the asyncronous services message loop.
- Specified by:
runin interfacejava.lang.Runnable- Since:
- 0.2.0
-
onStop
protected abstract void onStop()
The service thread calls this method when the thread is exiting.
- Since:
- 0.2.0
-
getAsyncMessageFilter
protected abstract int[] getAsyncMessageFilter()
Implement this method by returning the message ids of the asyncrounous messages your implementation wants to receive.
- Returns:
- an int array of message ids
- Since:
- 0.2.0
-
onMessageReceived
protected abstract void onMessageReceived(SshMessage msg) throws java.io.IOException
Called by the service thread when an asyncronous message is received.
- Parameters:
msg- the message received- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.2.0
-
-