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, MessageConnectorMBean

@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 available","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
static java.lang.String CONNECTION_ID_PARAMETER
          Connection id parameters 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  AbstractConnectionHandler<?> handler
           
 
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 message connector state.
 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).
 boolean isFile()
           
 void setAddress(java.lang.String address)
           
 void setFetchCount(int fetchCount)
           
 void setFetchDelay(long fetchDelay)
          Sets "fetch" delay.
 void setFile(boolean file)
           
 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.MessageConnectorMBean
getName, getReconnectDelay, getThreadPriority, restart, setName, setReconnectDelay, setThreadPriority
 

Field Detail

CONNECTION_ID_PARAMETER

public static final java.lang.String CONNECTION_ID_PARAMETER
Connection id parameters 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

handler

protected volatile AbstractConnectionHandler<?> 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: 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

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()
Specified by:
getProxyHost in interface HttpConnectorMBean

setProxyHost

public void setProxyHost(java.lang.String proxyHost)
Specified by:
setProxyHost in interface HttpConnectorMBean

getProxyPort

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

setProxyPort

public void setProxyPort(int proxyPort)
Specified by:
setProxyPort in interface HttpConnectorMBean

isFile

public boolean isFile()
Specified by:
isFile in interface HttpConnectorMBean

setFile

public void setFile(boolean file)
Specified by:
setFile in interface HttpConnectorMBean

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

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

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: 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