|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.caleigo.toolkit.tunnel.AbstractTunnel
Abstract class that implements most of the functinallity needed by an ITunnel. Only to methods need to be implemented by subclsses: getOutStream and getInStream. Optionally the method createPackage can be overridden to provide custom implementations of the IPackage interface.
Nested Class Summary | |
static class |
AbstractTunnel.DefaultConnectionMessage
|
static class |
AbstractTunnel.DefaultPackage
|
static class |
AbstractTunnel.DefaultStatusMessage
|
static class |
AbstractTunnel.ErrorMessage
|
static interface |
AbstractTunnel.IConnectionMessage
|
static interface |
AbstractTunnel.IFinalizeMessage
|
protected class |
AbstractTunnel.InputThread
|
static interface |
AbstractTunnel.IPackage
An IPackage represents a package that is sent by an ITunnel. |
static interface |
AbstractTunnel.IStatusMessage
|
protected class |
AbstractTunnel.OutputThread
|
protected class |
AbstractTunnel.WorkerThread
|
Field Summary | |
static int |
DEBUG
|
static int |
DEFAULT_NBR_OF_WORKER_THREADS
|
static int |
ERROR
|
static int |
INFO
|
protected ITunnelCodec |
mCodec
|
protected int |
mCurrentPackageID
|
protected AbstractTunnel.InputThread |
mInputThread
|
protected java.util.List |
mInQueue
|
protected int |
mLogLevel
|
protected java.util.List |
mMessageConsumers
|
protected AbstractTunnel.OutputThread |
mOutputThread
|
protected java.util.List |
mOutQueue
|
protected java.util.List |
mPackers
|
protected java.util.Map |
mReplyMessages
|
protected java.util.List |
mStatusCallbacks
|
protected java.util.List |
mTunnelListeners
|
protected AbstractTunnel.WorkerThread[] |
mWorkerThreads
|
protected static int |
sNbrOfWorkerThreads
|
static int |
WARNING
|
Constructor Summary | |
AbstractTunnel()
Default constructor. |
|
AbstractTunnel(ITunnelCodec codec)
|
Method Summary | |
void |
addMessageConsumer(IMessageConsumer consumer)
Adds the consumer to the end of this ITunnels message consumer list. |
void |
addPacker(ITunnelPacker packer)
Adds the packer to the end of this ITunnels packer list. |
void |
addStatusCallback(IStatusCallback callback)
Adds the callback to the list of IStatusCallbacks that receives status messages from this ITunnel. |
protected void |
addToInQueue(AbstractTunnel.IPackage inPackage)
|
protected void |
addToOutQueue(AbstractTunnel.IPackage outPackage)
|
void |
addTunnelListener(ITunnelListener listener)
|
java.lang.Object |
ask(java.lang.Object message)
Sends a request/reply message over this ITunnel. |
protected AbstractTunnel.IConnectionMessage |
createConnectionMessage()
|
AbstractTunnel.IPackage |
createPackage(java.lang.Object message,
int sessionID)
Creates an IPackage that contains the provided message. |
protected void |
doOnConnectionLost()
|
protected void |
doOnTunnelClose()
|
void |
finalize()
Performs cleanup for this ITunnel. |
protected void |
finalizeTunnel()
|
protected void |
fireConnectionLostEvent()
|
protected void |
fireTunnelClosedEvent()
|
java.lang.String |
getDescription()
Returns a humanly readably text that describes the ITunnel. |
protected abstract java.io.InputStream |
getInputStream()
Returns an InputStream that should be used to receive messages. |
int |
getLogLevel()
Gets the log level for this ITunnel. |
protected AbstractTunnel.IPackage |
getNextFromInQueue()
|
protected AbstractTunnel.IPackage |
getNextFromOutQueue()
|
protected int |
getNextPackageID()
|
protected abstract java.io.OutputStream |
getOutputStream()
Returns an OutputStream that should be used to send messages. |
void |
initialize()
Initializes the ITunnel. |
boolean |
isActive()
Returns true if this tunnel is active, that is, if it is
correctly initialized. |
protected void |
log(java.lang.Object source,
int logLevel,
java.lang.String message)
|
protected void |
log(java.lang.Object source,
int logLevel,
java.lang.String message,
java.lang.Throwable e)
|
int |
ping()
Sends a ping message over this ITunnel. |
void |
remomveMessageConsumer(IMessageConsumer consumer)
Removes the consumer from this ITunnels message consumer list. |
void |
remomvePacker(ITunnelPacker packer)
Removes the packer from this ITunnels packer list. |
void |
removeStatusCallback(IStatusCallback callback)
Removes the callback from the list of IStatusCallbacks. |
void |
removeTunnelListener(ITunnelListener listener)
|
void |
send(java.lang.Object message)
Sends a message over this ITunnel. |
void |
setCodec(ITunnelCodec codec)
Sets the ITunnelCodec that should be used by this ITunnel. |
void |
setLogLevel(int level)
Sets the log level for this ITunnel. |
static void |
setNbrOfWorkerThreads(int nbrOfWorkerThreads)
Sets the number of worker threads for all tunnels that are initilized after this methods has been called. |
protected java.lang.Object |
waitForReply(AbstractTunnel.IPackage requestPackage)
|
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEBUG
public static final int INFO
public static final int WARNING
public static final int ERROR
public static final int DEFAULT_NBR_OF_WORKER_THREADS
protected static int sNbrOfWorkerThreads
protected java.util.List mMessageConsumers
protected ITunnelCodec mCodec
protected java.util.List mPackers
protected java.util.List mStatusCallbacks
protected int mLogLevel
protected java.util.List mOutQueue
protected java.util.List mInQueue
protected java.util.List mTunnelListeners
protected int mCurrentPackageID
protected AbstractTunnel.WorkerThread[] mWorkerThreads
protected AbstractTunnel.OutputThread mOutputThread
protected AbstractTunnel.InputThread mInputThread
protected java.util.Map mReplyMessages
Constructor Detail |
public AbstractTunnel()
public AbstractTunnel(ITunnelCodec codec)
Method Detail |
public static void setNbrOfWorkerThreads(int nbrOfWorkerThreads)
public void initialize() throws java.lang.IllegalStateException, TunnelException
null
.
initialize
in interface ITunnel
java.lang.IllegalStateException
TunnelException
public void finalize() throws java.lang.IllegalStateException, TunnelException
finalize
in interface ITunnel
java.lang.IllegalStateException
TunnelException
public boolean isActive()
true
if this tunnel is active, that is, if it is
correctly initialized. If this method returns true
then
a call to finalize must not throw an IllegalStateException.
isActive
in interface ITunnel
public int ping() throws TunnelException
ping
in interface ITunnel
TunnelException
public void send(java.lang.Object message) throws TunnelException
send
in interface ITunnel
TunnelException
public java.lang.Object ask(java.lang.Object message) throws TunnelException
ask
in interface ITunnel
TunnelException
public void addMessageConsumer(IMessageConsumer consumer)
addMessageConsumer
in interface ITunnel
public void remomveMessageConsumer(IMessageConsumer consumer)
remomveMessageConsumer
in interface ITunnel
public void setCodec(ITunnelCodec codec) throws java.lang.IllegalStateException
setCodec
in interface ITunnel
java.lang.IllegalStateException
public void addPacker(ITunnelPacker packer) throws java.lang.IllegalStateException
addPacker
in interface ITunnel
java.lang.IllegalStateException
public void remomvePacker(ITunnelPacker packer) throws java.lang.IllegalStateException
remomvePacker
in interface ITunnel
java.lang.IllegalStateException
public void addStatusCallback(IStatusCallback callback)
addStatusCallback
in interface ITunnel
public void removeStatusCallback(IStatusCallback callback)
removeStatusCallback
in interface ITunnel
public void setLogLevel(int level)
setLogLevel
in interface ITunnel
public int getLogLevel()
getLogLevel
in interface ITunnel
public void addTunnelListener(ITunnelListener listener)
addTunnelListener
in interface ITunnel
public void removeTunnelListener(ITunnelListener listener)
removeTunnelListener
in interface ITunnel
public java.lang.String getDescription()
getDescription
in interface ITunnel
public AbstractTunnel.IPackage createPackage(java.lang.Object message, int sessionID)
protected abstract java.io.OutputStream getOutputStream()
protected abstract java.io.InputStream getInputStream()
protected AbstractTunnel.IConnectionMessage createConnectionMessage()
protected void log(java.lang.Object source, int logLevel, java.lang.String message)
protected void log(java.lang.Object source, int logLevel, java.lang.String message, java.lang.Throwable e)
protected void fireTunnelClosedEvent()
protected void fireConnectionLostEvent()
protected int getNextPackageID()
protected void addToOutQueue(AbstractTunnel.IPackage outPackage)
protected AbstractTunnel.IPackage getNextFromOutQueue()
protected void addToInQueue(AbstractTunnel.IPackage inPackage)
protected AbstractTunnel.IPackage getNextFromInQueue()
protected java.lang.Object waitForReply(AbstractTunnel.IPackage requestPackage)
protected void doOnTunnelClose()
protected void doOnConnectionLost()
protected void finalizeTunnel()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |