com.devexperts.qd.qtp.http
Class HttpConnector

java.lang.Object
  extended by com.devexperts.qd.qtp.AbstractMessageConnector
      extended by com.devexperts.qd.qtp.http.HttpConnector
All Implemented Interfaces:
HttpConnectorMBean, MessageConnector

@MessageConnectorSummary(info="Connects to some url by http or https protocol.",
                         addressFormat="",
                         properties={"user -- username to use","password -- password to use","updateDelay -- frequency (in ms) of checking if new data is avaliable","fetchDelay -- similar to updateDelay, but used when data was sent recently","fetchCount -- number of times to use fetchDelay after sending piece of data"})
public class HttpConnector
extends AbstractMessageConnector
implements HttpConnectorMBean


Field Summary
protected  java.lang.String address
           
static java.lang.String CONNECTION_ID_PARAMETER
          Connection id paramteres might be specified in URL to distinguish multiple connections that work in a single HTTP session (for example use address like "http://localhost:9090/sample/QDServlet?
static java.lang.String DEFAULT_CONNECTION_ID
          Default connection ID that is used when CONNECTION_ID_PARAMETER request property is not specified.
static int DEFAULT_FETCH_COUNT
           
static long DEFAULT_FETCH_DELAY
           
static long DEFAULT_UPDATE_DELAY
           
protected  int fetchCount
           
protected  long fetchDelay
           
protected  com.devexperts.qd.qtp.http.HttpConnectorHandler handler
           
protected  java.lang.String password
           
protected  java.lang.String proxyHost
           
protected  int proxyPort
           
protected  long updateDelay
           
protected  java.lang.String user
           
 
Fields inherited from class com.devexperts.qd.qtp.AbstractMessageConnector
DEFAULT_READ_AGGREGATION_SIZE, DEFAULT_RECONNECT_DELAY, log
 
Constructor Summary
HttpConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory, java.lang.String address)
          Creates new HTTP socket connector.
HttpConnector(MessageAdapter.Factory factory, java.lang.String address)
          Deprecated. use HttpConnector(com.devexperts.connector.proto.ApplicationConnectionFactory , String)
 
Method Summary
 java.lang.String getAddress()
          Returns address string of this connector.
 int getConnectionCount()
          Returns number of established connections.
 com.devexperts.transport.stats.EndpointStats getEndpointStats()
          Returns statistics for this message connector.
 int getFetchCount()
           
 long getFetchDelay()
          Returns "fetch" delay that is used between subsequent POST requests if any data was sent upstream.
 java.lang.String getPassword()
           
 java.lang.String getProxyHost()
           
 int getProxyPort()
           
 MessageConnectorState getState()
          Returns description of connectior's state as a string.
 long getUpdateDelay()
          Returns "update" delay that is used between subsequent POST requests by default.
 java.lang.String getUser()
           
protected  void handlerClosed(com.devexperts.qd.qtp.http.HttpConnectorHandler handler)
           
 boolean isActive()
          Returns true if connector is started (not stopped).
 void setAddress(java.lang.String address)
           
 void setFetchCount(int fetchCount)
           
 void setFetchDelay(long fetchDelay)
          Sets "fetch" delay.
 void setPassword(java.lang.String password)
           
 void setProxyHost(java.lang.String proxyHost)
           
 void setProxyPort(int proxyPort)
           
 void setStats(QDStats stats)
          Sets stats for this connector.
 void setUpdateDelay(long updateDelay)
          Sets "update" delay.
 void setUser(java.lang.String user)
           
 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.MessageConnector
addMessageConnectorListener, getName, getReconnectDelay, getStats, getThreadPriority, removeMessageConnectorListener, restart, setName, setReconnectDelay, setThreadPriority
 

Field Detail

CONNECTION_ID_PARAMETER

public static final java.lang.String CONNECTION_ID_PARAMETER
Connection id paramteres might be specified in URL to distinguish multiple connections that work in a single HTTP session (for example use address like "http://localhost:9090/sample/QDServlet?connection-id=qdc0"). Each connection should be assigned a unique id, otherwise disaster happens.

See Also:
Constant Field Values

DEFAULT_CONNECTION_ID

public static final java.lang.String DEFAULT_CONNECTION_ID
Default connection ID that is used when CONNECTION_ID_PARAMETER request property is not specified.

See Also:
Constant Field Values

DEFAULT_FETCH_COUNT

public static final int DEFAULT_FETCH_COUNT
See Also:
Constant Field Values

DEFAULT_FETCH_DELAY

public static final long DEFAULT_FETCH_DELAY
See Also:
Constant Field Values

DEFAULT_UPDATE_DELAY

public static final long DEFAULT_UPDATE_DELAY
See Also:
Constant Field Values

address

protected java.lang.String address

user

protected java.lang.String user

password

protected java.lang.String password

fetchCount

protected int fetchCount

fetchDelay

protected long fetchDelay

updateDelay

protected long updateDelay

proxyHost

protected java.lang.String proxyHost

proxyPort

protected int proxyPort

handler

protected volatile com.devexperts.qd.qtp.http.HttpConnectorHandler handler
Constructor Detail

HttpConnector

@Deprecated
public HttpConnector(MessageAdapter.Factory factory,
                                java.lang.String address)
Deprecated. use HttpConnector(com.devexperts.connector.proto.ApplicationConnectionFactory , String)

Creates new HTTP socket connector.

Parameters:
factory - message adapter factory to use
address - address HTTP address to connect to
Throws:
java.lang.NullPointerException - if factory or address is null

HttpConnector

public HttpConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory,
                     java.lang.String address)
Creates new HTTP socket connector.

Parameters:
factory - application connection factory to use
address - address HTTP address to connect to
Throws:
java.lang.NullPointerException - if factory or address is null
Method Detail

getAddress

public java.lang.String getAddress()
Description copied from interface: MessageConnector
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 MessageConnector
Returns:
address string of this connector

setAddress

public void setAddress(java.lang.String address)
Specified by:
setAddress in interface HttpConnectorMBean

getUser

public java.lang.String getUser()
Specified by:
getUser in interface HttpConnectorMBean

setUser

public void setUser(java.lang.String user)
Specified by:
setUser in interface HttpConnectorMBean

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface HttpConnectorMBean

setPassword

public void setPassword(java.lang.String password)
Specified by:
setPassword in interface HttpConnectorMBean

getFetchCount

public int getFetchCount()
Specified by:
getFetchCount in interface HttpConnectorMBean

setFetchCount

public void setFetchCount(int fetchCount)
Specified by:
setFetchCount in interface HttpConnectorMBean

getFetchDelay

public long getFetchDelay()
Description copied from interface: HttpConnectorMBean
Returns "fetch" delay that is used between subsequent POST requests if any data was sent upstream.

Specified by:
getFetchDelay in interface HttpConnectorMBean
Returns:
"fetch" delay that is used between subsequent POST requests if any data was sent upstream

setFetchDelay

public void setFetchDelay(long fetchDelay)
Description copied from interface: HttpConnectorMBean
Sets "fetch" delay. See HttpConnectorMBean.getFetchDelay().

Specified by:
setFetchDelay in interface HttpConnectorMBean
Parameters:
fetchDelay - see HttpConnectorMBean.getFetchDelay()

getUpdateDelay

public long getUpdateDelay()
Description copied from interface: HttpConnectorMBean
Returns "update" delay that is used between subsequent POST requests by default.

Specified by:
getUpdateDelay in interface HttpConnectorMBean
Returns:
"update" delay that is used between subsequent POST requests by default

setUpdateDelay

public void setUpdateDelay(long updateDelay)
Description copied from interface: HttpConnectorMBean
Sets "update" delay. See HttpConnectorMBean.getUpdateDelay().

Specified by:
setUpdateDelay in interface HttpConnectorMBean
Parameters:
updateDelay - see HttpConnectorMBean.getUpdateDelay()

getProxyHost

public java.lang.String getProxyHost()

setProxyHost

public void setProxyHost(java.lang.String proxyHost)

getProxyPort

public int getProxyPort()

setProxyPort

public void setProxyPort(int proxyPort)

start

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

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

stop

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

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

handlerClosed

protected void handlerClosed(com.devexperts.qd.qtp.http.HttpConnectorHandler handler)

setStats

public void setStats(QDStats stats)
Sets stats for this connector. Stats should be of type QDStats.SType#HTTP_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: MessageConnector
Returns true if connector is started (not stopped).

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

getState

public MessageConnectorState getState()
Description copied from interface: MessageConnector
Returns description of connectior's state as a string.

Specified by:
getState in interface MessageConnector
Returns:
description of connectior's state as a string

getConnectionCount

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

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

getEndpointStats

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

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