org.caleigo.toolkit.tunnel
Class SocketTunnel

java.lang.Object
  extended byorg.caleigo.toolkit.tunnel.AbstractTunnel
      extended byorg.caleigo.toolkit.tunnel.SocketTunnel
All Implemented Interfaces:
ITunnel

public class SocketTunnel
extends AbstractTunnel

Version:
1.00
Author:
Mattias Hagstrand

Nested Class Summary
 
Nested classes inherited from class org.caleigo.toolkit.tunnel.AbstractTunnel
AbstractTunnel.DefaultConnectionMessage, AbstractTunnel.DefaultPackage, AbstractTunnel.DefaultStatusMessage, AbstractTunnel.ErrorMessage, AbstractTunnel.IConnectionMessage, AbstractTunnel.IFinalizeMessage, AbstractTunnel.InputThread, AbstractTunnel.IPackage, AbstractTunnel.IStatusMessage, AbstractTunnel.OutputThread, AbstractTunnel.WorkerThread
 
Field Summary
protected  java.net.InetAddress mAddress
           
protected  int mPort
           
protected  java.net.Socket mSocket
           
 
Fields inherited from class org.caleigo.toolkit.tunnel.AbstractTunnel
DEBUG, DEFAULT_NBR_OF_WORKER_THREADS, ERROR, INFO, mCodec, mCurrentPackageID, mInputThread, mInQueue, mLogLevel, mMessageConsumers, mOutputThread, mOutQueue, mPackers, mReplyMessages, mStatusCallbacks, mTunnelListeners, mWorkerThreads, sNbrOfWorkerThreads, WARNING
 
Constructor Summary
  SocketTunnel(java.net.InetAddress address, int port)
           
  SocketTunnel(java.net.InetAddress address, int port, ITunnelCodec codec)
           
protected SocketTunnel(java.net.Socket socket)
           
 
Method Summary
 void finalize()
          Performs cleanup for this ITunnel.
 java.lang.String getDescription()
          Returns a humanly readably text that describes the ITunnel.
protected  java.io.InputStream getInputStream()
          Returns an InputStream that should be used to receive messages.
protected  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 setUpConnection()
           
 
Methods inherited from class org.caleigo.toolkit.tunnel.AbstractTunnel
addMessageConsumer, addPacker, addStatusCallback, addToInQueue, addToOutQueue, addTunnelListener, ask, createConnectionMessage, createPackage, doOnConnectionLost, doOnTunnelClose, finalizeTunnel, fireConnectionLostEvent, fireTunnelClosedEvent, getLogLevel, getNextFromInQueue, getNextFromOutQueue, getNextPackageID, log, log, ping, remomveMessageConsumer, remomvePacker, removeStatusCallback, removeTunnelListener, send, setCodec, setLogLevel, setNbrOfWorkerThreads, waitForReply
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mAddress

protected java.net.InetAddress mAddress

mPort

protected int mPort

mSocket

protected java.net.Socket mSocket
Constructor Detail

SocketTunnel

protected SocketTunnel(java.net.Socket socket)

SocketTunnel

public SocketTunnel(java.net.InetAddress address,
                    int port)

SocketTunnel

public SocketTunnel(java.net.InetAddress address,
                    int port,
                    ITunnelCodec codec)
Method Detail

initialize

public void initialize()
                throws java.lang.IllegalStateException,
                       TunnelException
Description copied from class: AbstractTunnel
Initializes the ITunnel. This method must be called before any messages can be sent. After this method has been called it is not possible to set the ITunnelCodec or to add or remove ITunnelPackers. Subclasses of AbstractTunnel must call super.initialize(). Successful initialization recuires that the methods getInStream and getOutStream does not return null.

Specified by:
initialize in interface ITunnel
Overrides:
initialize in class AbstractTunnel
Throws:
java.lang.IllegalStateException
TunnelException

finalize

public void finalize()
              throws java.lang.IllegalStateException,
                     TunnelException
Description copied from class: AbstractTunnel
Performs cleanup for this ITunnel. No messages can be sent after this method has been called. This method will send all messages in the message queue before closing down. Subclasses of AbstractTunnel must call super.finalize() before they do any finalization of their own.

Specified by:
finalize in interface ITunnel
Overrides:
finalize in class AbstractTunnel
Throws:
java.lang.IllegalStateException
TunnelException

isActive

public boolean isActive()
Returns 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.

Specified by:
isActive in interface ITunnel
Overrides:
isActive in class AbstractTunnel

getOutputStream

protected java.io.OutputStream getOutputStream()
Returns an OutputStream that should be used to send messages.

Specified by:
getOutputStream in class AbstractTunnel

getInputStream

protected java.io.InputStream getInputStream()
Returns an InputStream that should be used to receive messages.

Specified by:
getInputStream in class AbstractTunnel

getDescription

public java.lang.String getDescription()
Returns a humanly readably text that describes the ITunnel.

Specified by:
getDescription in interface ITunnel
Overrides:
getDescription in class AbstractTunnel

setUpConnection

protected void setUpConnection()
                        throws TunnelException
Throws:
TunnelException


Copyright © 2005 Caleigo. All Rights Reserved.