Package com.swiftmq.net.client
Class BlockingConnection
- java.lang.Object
-
- java.lang.Thread
-
- com.swiftmq.net.client.BlockingConnection
-
- All Implemented Interfaces:
Connection
,ChunkListener
,OutputListener
,java.lang.Runnable
public class BlockingConnection extends java.lang.Thread implements Connection, ChunkListener, OutputListener
-
-
Constructor Summary
Constructors Constructor Description BlockingConnection(java.net.Socket socket, int inputBufferSize, int inputExtendSize, int outputBufferSize, int outputExtendSize)
BlockingConnection(java.net.Socket socket, InboundHandler inboundHandler, ExceptionHandler exceptionHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
chunkCompleted(byte[] b, int offset, int len)
Called from a ProtocolInputHandler when a protocol-chunk has been completed.void
close()
protected ProtocolInputHandler
createInputHandler()
protected ProtocolOutputHandler
createOutputHandler(int outputBufferSize, int outputExtendSize)
java.lang.String
getHostname()
java.lang.String
getLocalHostname()
java.io.OutputStream
getOutputStream()
int
getPort()
int
performWrite(byte[] b, int offset, int len)
Performs the write to the network.void
run()
void
setExceptionHandler(ExceptionHandler exceptionHandler)
void
setInboundHandler(InboundHandler inboundHandler)
void
setInputActiveIndicator(java.util.concurrent.atomic.AtomicBoolean inputActiveIndicator)
java.lang.String
toString()
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.swiftmq.net.client.Connection
start
-
-
-
-
Constructor Detail
-
BlockingConnection
public BlockingConnection(java.net.Socket socket, InboundHandler inboundHandler, ExceptionHandler exceptionHandler) throws java.io.IOException
- Throws:
java.io.IOException
-
BlockingConnection
public BlockingConnection(java.net.Socket socket, int inputBufferSize, int inputExtendSize, int outputBufferSize, int outputExtendSize) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
createOutputHandler
protected ProtocolOutputHandler createOutputHandler(int outputBufferSize, int outputExtendSize)
-
createInputHandler
protected ProtocolInputHandler createInputHandler()
-
setInputActiveIndicator
public void setInputActiveIndicator(java.util.concurrent.atomic.AtomicBoolean inputActiveIndicator)
- Specified by:
setInputActiveIndicator
in interfaceConnection
-
chunkCompleted
public void chunkCompleted(byte[] b, int offset, int len)
Description copied from interface:ChunkListener
Called from a ProtocolInputHandler when a protocol-chunk has been completed.- Specified by:
chunkCompleted
in interfaceChunkListener
- Parameters:
b
- byte array.offset
- offsetlen
- length
-
performWrite
public int performWrite(byte[] b, int offset, int len) throws java.io.IOException
Description copied from interface:OutputListener
Performs the write to the network.- Specified by:
performWrite
in interfaceOutputListener
- Parameters:
b
- byte array.offset
- offset.len
- length.- Returns:
- number of bytes written.
- Throws:
java.io.IOException
- on error.
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
setInboundHandler
public void setInboundHandler(InboundHandler inboundHandler)
- Specified by:
setInboundHandler
in interfaceConnection
-
setExceptionHandler
public void setExceptionHandler(ExceptionHandler exceptionHandler)
- Specified by:
setExceptionHandler
in interfaceConnection
-
getLocalHostname
public java.lang.String getLocalHostname()
- Specified by:
getLocalHostname
in interfaceConnection
-
getHostname
public java.lang.String getHostname()
- Specified by:
getHostname
in interfaceConnection
-
getPort
public int getPort()
- Specified by:
getPort
in interfaceConnection
-
getOutputStream
public java.io.OutputStream getOutputStream()
- Specified by:
getOutputStream
in interfaceConnection
-
close
public void close()
- Specified by:
close
in interfaceConnection
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Thread
-
-