xmlBlaster 2.2.0 API

org.xmlBlaster.protocol.socket
Class HandleClient

java.lang.Object
  extended by org.xmlBlaster.util.protocol.RequestReplyExecutor
      extended by org.xmlBlaster.util.protocol.socket.SocketExecutor
          extended by org.xmlBlaster.protocol.socket.HandleClient
All Implemented Interfaces:
java.lang.Runnable, I_AdminPlugin, I_AdminUsage, RequestReplyExecutorMBean, SocketExecutorMBean

public class HandleClient
extends SocketExecutor
implements java.lang.Runnable

Holds one socket connection to a client and handles all requests from one client with plain socket messaging.

  1. We block on the socket input stream to read incoming messages in a separate thread (see run() method)
  2. We send update() and ping() back to the client

Author:
Marcel Ruff.

Field Summary
private  I_Authenticate authenticate
          The singleton handle for this authentication server
private  CallbackSocketDriver callback
           
private  boolean callCoreInSeparateThread
           
protected  boolean disconnectIsCalled
           
private  SocketDriver driver
           
protected static java.util.concurrent.ExecutorService executorService
           
private  boolean isShutdownCompletly
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
protected  java.lang.String remoteSocketStr
          Holds remote "host:port" for logging
private  java.lang.String secretSessionId
          The unique client sessionId
protected  java.net.Socket sock
          The socket connection to/from one client
private  java.lang.Thread socketHandlerThread
           
protected  java.net.DatagramSocket sockUDP
          The socket connection to/from one client
 
Fields inherited from class org.xmlBlaster.util.protocol.socket.SocketExecutor
iStream, loginName, maxChunkSize, msgInfoParserClassName, oStream, running, soLingerTimeout, soTimeout
 
Fields inherited from class org.xmlBlaster.util.protocol.RequestReplyExecutor
addressConfig, addressServer, cbClient, compressZlib, compressZlibStream, contextNode, glob, mbeanHandle, minSizeForCompression, ONEWAY, pingResponseTimeout, prefix, progressListener, responseListenerMap, responseTimeout, updateResponseTimeout, useEmailExpiryTimestamp, WAIT_ON_RESPONSE
 
Constructor Summary
HandleClient(Global glob, SocketDriver driver, java.net.Socket sock, java.net.DatagramSocket sockUDP)
          Creates an instance which serves exactly one client.
 
Method Summary
private  void closeSocket()
           
 java.lang.String getCbMsgInfoParserClassName()
           
 java.lang.String getSecretSessionId()
           
 java.net.Socket getSocket()
           
 java.lang.String getType()
          The protocol type, used for logging
 void handleMessage(MsgInfo receiver, boolean udp)
           
protected  boolean hasConnection()
           
 boolean isShutdown()
          Check status
 boolean isShutdownCompletly()
           
 void run()
          Serve a client, we block until a message arrives ...
protected  void sendMessage(byte[] msg, boolean udp)
          Flush the data to the socket.
 void shutdown()
          Close connection for one specific client
 void startThread()
           
 java.lang.String toString()
           
 boolean useUdpForOneway()
           
 
Methods inherited from class org.xmlBlaster.util.protocol.socket.SocketExecutor
getGlobalKey, getInputStream, getMsgInfoParserClassName, getOutputStream, getSoLingerTimeout, getSoTimeout, getUsageUrl, getVersion, initialize, ping, sendMessage, sendUpdate, setLoginName, setRunning, setSoLingerTimeout, setSoTimeout, setUsageUrl, usage
 
Methods inherited from class org.xmlBlaster.util.protocol.RequestReplyExecutor
addResponseListener, clearResponseListenerMap, executeException, executeResponse, freePendingThreads, getAddressServer, getCbClient, getDefaultPingResponseTimeout, getDefaultResponseTimeout, getDefaultUpdateResponseTimeout, getExpiryTimestamp, getMinSizeForCompression, getPendingRequestList, getPingResponseTimeout, getProgressListener, getResponseListener, getResponseTimeout, getResponseTimeout, getResponseTimeout, getResponseTimeoutPropertyName, getUpdateResponseTimeout, getXmlBlasterCore, initialize, initializeCb, interruptInvocation, isCompressZlib, isCompressZlibStream, isUseEmailExpiryTimestamp, receiveReply, registerProgressListener, removeResponseListener, requestAndBlockForReply, setCbClient, setCompressZlib, setCompressZlibStream, setMinSizeForCompression, setPingResponseTimeout, setResponseTimeout, setUpdateResponseTimeout, setUseEmailExpiryTimestamp, setXmlBlasterCore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xmlBlaster.util.protocol.RequestReplyExecutorMBean
getMinSizeForCompression, getPingResponseTimeout, getResponseTimeout, getResponseTimeout, getUpdateResponseTimeout, interruptInvocation, isCompressZlib, isCompressZlibStream, isUseEmailExpiryTimestamp, setCompressZlib, setCompressZlibStream, setMinSizeForCompression, setPingResponseTimeout, setResponseTimeout, setUpdateResponseTimeout, setUseEmailExpiryTimestamp
 

Field Detail

ME

private java.lang.String ME

log

private static java.util.logging.Logger log

driver

private SocketDriver driver

authenticate

private I_Authenticate authenticate
The singleton handle for this authentication server


callback

private CallbackSocketDriver callback

sockUDP

protected java.net.DatagramSocket sockUDP
The socket connection to/from one client


remoteSocketStr

protected java.lang.String remoteSocketStr
Holds remote "host:port" for logging


sock

protected java.net.Socket sock
The socket connection to/from one client


secretSessionId

private java.lang.String secretSessionId
The unique client sessionId


callCoreInSeparateThread

private boolean callCoreInSeparateThread

executorService

protected static volatile java.util.concurrent.ExecutorService executorService

disconnectIsCalled

protected boolean disconnectIsCalled

isShutdownCompletly

private boolean isShutdownCompletly

socketHandlerThread

private java.lang.Thread socketHandlerThread
Constructor Detail

HandleClient

public HandleClient(Global glob,
                    SocketDriver driver,
                    java.net.Socket sock,
                    java.net.DatagramSocket sockUDP)
             throws java.io.IOException
Creates an instance which serves exactly one client.

Throws:
java.io.IOException
Method Detail

startThread

public void startThread()

useUdpForOneway

public boolean useUdpForOneway()
Overrides:
useUdpForOneway in class SocketExecutor

getType

public java.lang.String getType()
Description copied from class: RequestReplyExecutor
The protocol type, used for logging

Specified by:
getType in interface I_AdminPlugin
Specified by:
getType in class RequestReplyExecutor
Returns:
"SOCKET" or "EMAIL", never null

isShutdownCompletly

public boolean isShutdownCompletly()
Overrides:
isShutdownCompletly in class RequestReplyExecutor

isShutdown

public boolean isShutdown()
Description copied from interface: I_AdminPlugin
Check status

Specified by:
isShutdown in interface I_AdminPlugin
Overrides:
isShutdown in class RequestReplyExecutor
Returns:
true if down

hasConnection

protected boolean hasConnection()
Overrides:
hasConnection in class RequestReplyExecutor

shutdown

public void shutdown()
Close connection for one specific client

Specified by:
shutdown in interface I_AdminPlugin
Overrides:
shutdown in class SocketExecutor

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

closeSocket

private void closeSocket()

handleMessage

public void handleMessage(MsgInfo receiver,
                          boolean udp)

sendMessage

protected void sendMessage(byte[] msg,
                           boolean udp)
                    throws java.io.IOException
Flush the data to the socket. Overwrites SocketExecutor.sendMessage()

Throws:
java.io.IOException

getCbMsgInfoParserClassName

public java.lang.String getCbMsgInfoParserClassName()
Overrides:
getCbMsgInfoParserClassName in class SocketExecutor

run

public void run()
Serve a client, we block until a message arrives ...

Specified by:
run in interface java.lang.Runnable

getSecretSessionId

public java.lang.String getSecretSessionId()
Returns:
Returns the secretSessionId.

getSocket

public java.net.Socket getSocket()

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.