com.dxfeed.api
Class DXEndpoint

java.lang.Object
  extended by com.dxfeed.api.DXEndpoint

public abstract class DXEndpoint
extends java.lang.Object

DXEndpoint manages network connections to data feed or to publisher. There are factory methods create() and create(Role), and a number of configuration methods.

Sample usage

The following code creates feed that is connected to DXFeed demo server.

 DXFeed feed = DXEndpoint.create().connect("demo.dxfeed.com:7300").getFeed();
See DXFeed class to learn how to subscribe to symbols and to receive events.

Endpoint role

Each endpoint has a role that is specified on its creation and cannot be changed afterwards. The default factory method create() creates an endpoint with a FEED role. Endpoints with other roles are created with create(Role) factory method. Endpoint role is represented by DXEndpoint.Role enumeration.

Endpoint role defines the behavior of its connect method:

Threads and locks

This class is thread-safe and can be used concurrently from multiple threads without external synchronization.


Nested Class Summary
static class DXEndpoint.Role
          Role represents the role of this endpoint that was specified during its creation.
static class DXEndpoint.State
          State represents the stat of this endpoint.
 
Constructor Summary
DXEndpoint()
           
 
Method Summary
abstract  void close()
           
abstract  DXEndpoint connect(java.lang.String address)
          Connects to the specified remove address.
static DXEndpoint create()
          Creates an endpoint with FEED role.
static DXEndpoint create(DXEndpoint.Role role)
          Creates an endpoint with a specified role.
abstract  void disconnect()
          Closes all remote network connections.
abstract  DXEndpoint executor(java.util.concurrent.Executor executor)
          Changes executor that is used for notifications.
abstract  DXFeed getFeed()
           
abstract  DXPublisher getPublisher()
           
abstract  DXEndpoint.Role getRole()
          Returns the role of this endpoint.
abstract  DXEndpoint.State getState()
          Returns the state of this endpoint.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DXEndpoint

public DXEndpoint()
Method Detail

create

public static DXEndpoint create()
Creates an endpoint with FEED role. The result of this method is the same as create(DXEndpoint.Role.FEED).

Returns:
the created endpoint.

create

public static DXEndpoint create(DXEndpoint.Role role)
Creates an endpoint with a specified role.

Parameters:
role - the role.
Returns:
the created endpoint.

getRole

public abstract DXEndpoint.Role getRole()
Returns the role of this endpoint.

Returns:
the role.
See Also:
DXEndpoint

getState

public abstract DXEndpoint.State getState()
Returns the state of this endpoint.

Returns:
the state.
See Also:
DXEndpoint

executor

public abstract DXEndpoint executor(java.util.concurrent.Executor executor)
Changes executor that is used for notifications.

Parameters:
executor - the executor.
Returns:
this DXEndpoint
Throws:
java.lang.NullPointerException - if executor is null.

connect

public abstract DXEndpoint connect(java.lang.String address)
Connects to the specified remove address. Previously established connections are closed if the new address is different from the old one. Does nothing if address does not change. The address string is provided with the market data vendor agreement. Use "demo.dxfeed.com:7300" for a demo quote feed.

Parameters:
address - data source address.
Returns:
this DXEndpoint
Throws:
java.lang.NullPointerException - if address is null.

disconnect

public abstract void disconnect()
Closes all remote network connections.


close

public abstract void close()

getFeed

public abstract DXFeed getFeed()

getPublisher

public abstract DXPublisher getPublisher()