com.devexperts.qd.qtp.socket
Class ServerSocketConnector

java.lang.Object
  extended by com.devexperts.qd.qtp.AbstractMessageConnector
      extended by com.devexperts.qd.qtp.socket.ServerSocketConnector
All Implemented Interfaces:
MessageConnector, MessageConnectorMBean, ServerSocketConnectorMBean

@MessageConnectorSummary(info="Creates server TCP/IP socket connection",
                         addressFormat=":",
                         properties={})
public class ServerSocketConnector
extends AbstractMessageConnector
implements ServerSocketConnectorMBean

The ServerSocketConnector handles standard server socket using blocking API.


Field Summary
protected  com.devexperts.qd.qtp.socket.SocketAcceptor acceptor
           
protected  java.net.InetAddress bindAddr
           
protected  java.lang.String bindAddrString
           
protected  SocketHandler.CloseListener closeListener
           
protected  java.util.Set<com.devexperts.qd.qtp.socket.SocketHandler> handlers
           
protected  int port
           
protected  boolean useTls
           
 
Fields inherited from class com.devexperts.qd.qtp.AbstractMessageConnector
DEFAULT_READ_AGGREGATION_SIZE, DEFAULT_RECONNECT_DELAY, log
 
Constructor Summary
ServerSocketConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory, int port)
          Creates new server socket connector.
ServerSocketConnector(MessageAdapter.Factory factory, int port)
          Deprecated. use ServerSocketConnector(com.devexperts.connector.proto.ApplicationConnectionFactory, int)
 
Method Summary
protected  void addHandler(com.devexperts.qd.qtp.socket.SocketHandler handler)
           
 void close()
          Deprecated. Use stop()
 java.lang.String getAddress()
          Returns address string of this connector.
 java.lang.String getBindAddr()
           
 int getConnectionCount()
          Returns number of established connections.
 com.devexperts.transport.stats.EndpointStats getEndpointStats()
          Returns statistics for this message connector.
 int getLocalPort()
           
 MessageConnectorState getState()
          Returns message connector state.
 boolean getTls()
           
protected  void handlerClosed(com.devexperts.qd.qtp.socket.SocketHandler handler)
           
 boolean isActive()
          Returns true if connector is started (not stopped).
 void setBindAddr(java.lang.String bindAddrString)
           
 void setLocalPort(int port)
          Changes local port and restarts connector if new port is different from the old one and the connector was running.
 void setStats(QDStats stats)
          Sets stats for this connector.
 void setTls(boolean useTls)
           
 void start()
          Starts connector (connection is immediately established).
 void stop()
          Stops connector (connection is immediately dropped).
 
Methods inherited from class com.devexperts.qd.qtp.AbstractMessageConnector
addClosedConnectionStats, addMessageConnectorListener, getFactory, getLogging, getName, getReconnectDelay, getStats, getThreadPriority, notifyMessageConnectorListeners, reconfigure, removeMessageConnectorListener, restart, setName, setReconnectDelay, setThreadPriority, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.devexperts.qd.qtp.MessageConnectorMBean
getName, getReconnectDelay, getThreadPriority, restart, setName, setReconnectDelay, setThreadPriority
 

Field Detail

port

protected int port

bindAddrString

protected java.lang.String bindAddrString

bindAddr

protected java.net.InetAddress bindAddr

useTls

protected boolean useTls

handlers

protected final java.util.Set<com.devexperts.qd.qtp.socket.SocketHandler> handlers

closeListener

protected final SocketHandler.CloseListener closeListener

acceptor

protected volatile com.devexperts.qd.qtp.socket.SocketAcceptor acceptor
Constructor Detail

ServerSocketConnector

@Deprecated
public ServerSocketConnector(MessageAdapter.Factory factory,
                                        int port)
Deprecated. use ServerSocketConnector(com.devexperts.connector.proto.ApplicationConnectionFactory, int)

Creates new server socket connector.

Parameters:
factory - message adapter factory to use
port - TCP port to use
Throws:
java.lang.NullPointerException - if factory is null

ServerSocketConnector

public ServerSocketConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory,
                             int port)
Creates new server socket connector.

Parameters:
factory - application connection factory to use
port - TCP port to use
Throws:
java.lang.NullPointerException - if factory is null
Method Detail

getAddress

public java.lang.String getAddress()
Description copied from interface: MessageConnectorMBean
Returns address string of this connector. It is "[host1[:port1],host2[:port2],...]:port" for client socket connector and ":port" for server socket connector.

Specified by:
getAddress in interface MessageConnectorMBean
Returns:
address string of this connector

setLocalPort

public void setLocalPort(int port)
Changes local port and restarts connector if new port is different from the old one and the connector was running.

Specified by:
setLocalPort in interface ServerSocketConnectorMBean

getLocalPort

public int getLocalPort()
Specified by:
getLocalPort in interface ServerSocketConnectorMBean

getBindAddr

public java.lang.String getBindAddr()
Specified by:
getBindAddr in interface ServerSocketConnectorMBean

setBindAddr

public void setBindAddr(java.lang.String bindAddrString)
                 throws java.net.UnknownHostException
Specified by:
setBindAddr in interface ServerSocketConnectorMBean
Throws:
java.net.UnknownHostException

getTls

public boolean getTls()

setTls

public void setTls(boolean useTls)

setStats

public void setStats(QDStats stats)
Sets stats for this connector. Stats should be of type QDStats.SType#SERVER_SOCKET_CONNECTOR or a suitable substitute. This method may be invoked only once.

Specified by:
setStats in interface MessageConnector
Overrides:
setStats in class AbstractMessageConnector
Throws:
java.lang.IllegalStateException - if already set.

isActive

public boolean isActive()
Description copied from interface: MessageConnectorMBean
Returns true if connector is started (not stopped).

Specified by:
isActive in interface MessageConnectorMBean
Returns:
true if connector is started (not stopped)

getState

public MessageConnectorState getState()
Description copied from interface: MessageConnectorMBean
Returns message connector state.

Specified by:
getState in interface MessageConnectorMBean
Returns:
message connector state.

getConnectionCount

public int getConnectionCount()
Description copied from interface: MessageConnectorMBean
Returns number of established connections.

Specified by:
getConnectionCount in interface MessageConnectorMBean
Returns:
number of established connections

getEndpointStats

public com.devexperts.transport.stats.EndpointStats getEndpointStats()
Description copied from interface: MessageConnectorMBean
Returns statistics for this message connector.

Specified by:
getEndpointStats in interface MessageConnectorMBean
Overrides:
getEndpointStats in class AbstractMessageConnector
Returns:
statistics for this message connector

start

public void start()
Description copied from interface: MessageConnectorMBean
Starts connector (connection is immediately established). Does nothing if connector is already started.

Specified by:
start in interface MessageConnectorMBean
Specified by:
start in class AbstractMessageConnector

close

public void close()
Deprecated. Use stop()


stop

public void stop()
Description copied from interface: MessageConnectorMBean
Stops connector (connection is immediately dropped). Does nothing if connector is stopped.

Specified by:
stop in interface MessageConnectorMBean
Specified by:
stop in class AbstractMessageConnector

addHandler

protected void addHandler(com.devexperts.qd.qtp.socket.SocketHandler handler)

handlerClosed

protected void handlerClosed(com.devexperts.qd.qtp.socket.SocketHandler handler)