Package com.epam.fixengine
Class FIXServer
java.lang.Object
com.epam.fixengine.FIXServer
- All Implemented Interfaces:
com.epam.fixengine.manager.ConfiguredSessionListener
- Direct Known Subclasses:
ScheduledFIXServer
,SSLFIXServer
public class FIXServer
extends Object
implements com.epam.fixengine.manager.ConfiguredSessionListener
Generic FIXServer implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.epam.fixengine.session.util.ConfigurationAdaptor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Server
addServer
(com.epam.fixengine.session.util.ConfigurationAdaptor config, Integer port, Server server, com.epam.fixengine.acceptor.ConnectionHandler handler) void
addServerStatusListener
(FIXServerStatusListener statusListener) protected void
boolean
closePort
(int portNum) Closes port for listening of incoming FIX sessions on the given port.protected Server
createServer
(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose) protected Server
deleteServer
(Integer port) protected SessionAcceptorStrategyHandler
getAcceptorStrategy
(com.epam.fixengine.session.util.ConfigurationAdaptor configuration, com.epam.fixengine.manager.ConfiguredSessionRegister configuredSessionRegister) Path to config fileprotected ServerSocketFactory
getConfiguredServerSocketFactory
(@NotNull com.epam.fixengine.configuration.Configuration configuration) getNic()
Provides with port numbers which added and actually started in this FIX Server.int[]
getPorts()
Listening portsprotected Server
getServer
(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose) protected SessionTransportFactory
getTransportFactory
(com.epam.fixengine.configuration.Configuration configuration) protected boolean
handleAutoClose
(Integer portNum, Server server) boolean
void
onAddSession
(SessionParameters params) void
onRemoveSession
(SessionParameters params) boolean
openPort
(int portNum) Opens port for listening of incoming FIX sessions on the given port (immediately if FIXServer is already started, or after its start).boolean
openPort
(int portNum, boolean autoClose) Opens port for listening of incoming FIX sessions on the given port (immediately if FIXServer is already started, or after its start).boolean
openPort
(com.epam.fixengine.configuration.Configuration config, int portNum) boolean
openPort
(com.epam.fixengine.configuration.Configuration config, int portNum, boolean autoClose) void
registerAcceptorSession
(SessionParameters sessionParameters) Register the session parameters of acceptor.protected void
void
removeServerStatusListener
(FIXServerStatusListener statusListener) void
setConfigPath
(String configPath) Set path to config filevoid
setConnectionValidator
(ConnectionValidator connectionValidator) void
setIncomingConnectionExecutor
(ExecutorService executorService) Set custom executor service.void
setListener
(FIXServerListener listener) Sets listener.void
setLoginWaitTimeout
(int loginWaitTimeout) Sets login timeout.void
void
setPort
(int port) Sets port to listen on.void
setPorts
(int... ports) Sets ports to listen on.void
setPorts
(com.epam.fixengine.session.util.ConfigurationAdaptor config, int... ports) void
Replaces default TCPServer implementation with custom Server implementation.boolean
start()
Actually starts the servers.void
stop()
Stops the server.protected boolean
stopAndDeleteServer
(int portNum) void
unregisterAcceptorSession
(SessionParameters sessionParameters) Remove registered acceptor session.protected void
validateBeforeRegistration
(SessionParameters sessionParameters)
-
Field Details
-
servers
-
configuration
protected final com.epam.fixengine.session.util.ConfigurationAdaptor configuration
-
-
Constructor Details
-
FIXServer
public FIXServer() -
FIXServer
public FIXServer(int... ports) -
FIXServer
public FIXServer(com.epam.fixengine.configuration.Configuration conf) Creates the fix server. -
FIXServer
public FIXServer(com.epam.fixengine.configuration.Configuration conf, int... ports)
-
-
Method Details
-
getTransportFactory
protected SessionTransportFactory getTransportFactory(com.epam.fixengine.configuration.Configuration configuration) -
getAcceptorStrategy
protected SessionAcceptorStrategyHandler getAcceptorStrategy(com.epam.fixengine.session.util.ConfigurationAdaptor configuration, com.epam.fixengine.manager.ConfiguredSessionRegister configuredSessionRegister) -
setServer
Replaces default TCPServer implementation with custom Server implementation.- Parameters:
server
- implementation specified by user- See Also:
-
setListener
Sets listener.- Parameters:
listener
- - user specified listener
-
setConnectionValidator
-
setLoginWaitTimeout
public void setLoginWaitTimeout(int loginWaitTimeout) Sets login timeout.- Parameters:
loginWaitTimeout
- the login timeout in mils
-
setPorts
public void setPorts(int... ports) Sets ports to listen on.- Parameters:
ports
- ports to listen on
-
setPorts
public void setPorts(com.epam.fixengine.session.util.ConfigurationAdaptor config, int... ports) -
addServer
-
deleteServer
-
clearServers
protected void clearServers() -
createServer
protected Server createServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose) -
getServer
protected Server getServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose) -
getPorts
public int[] getPorts()Listening ports- Returns:
- listening ports
-
setPort
public void setPort(int port) Sets port to listen on.- Parameters:
port
- port to listen on
-
setNic
-
getNic
-
start
Actually starts the servers.- Returns:
- true if all servers started succesfully false - otherwise (server will add WARN messages with description of each problem to LOG)
- Throws:
IOException
- if unable to start the server at least on one port. In this case the first received exception will be thrown.
-
registerConfiguredSessions
protected void registerConfiguredSessions() -
stop
Stops the server.- Throws:
IOException
- if stop was unsuccessful
-
getOpenPorts
Provides with port numbers which added and actually started in this FIX Server.- Returns:
- set of port numbers
-
openPort
Opens port for listening of incoming FIX sessions on the given port (immediately if FIXServer is already started, or after its start).- Parameters:
portNum
- the socket port number- Returns:
- true if opened, false - otherwise (was already open etc)
- Throws:
IOException
- if was failed to open
-
openPort
public boolean openPort(com.epam.fixengine.configuration.Configuration config, int portNum) throws IOException - Throws:
IOException
-
openPort
Opens port for listening of incoming FIX sessions on the given port (immediately if FIXServer is already started, or after its start).- Parameters:
portNum
- the socket port numberautoClose
- flag to switch on/off auto close of port listening on removing from registry of last session with the given port- Returns:
- true if opened, false - otherwise (was already open etc)
- Throws:
IOException
- if was failed to open
-
openPort
public boolean openPort(com.epam.fixengine.configuration.Configuration config, int portNum, boolean autoClose) throws IOException - Throws:
IOException
-
closePort
public boolean closePort(int portNum) Closes port for listening of incoming FIX sessions on the given port.- Parameters:
portNum
- the socket port number- Returns:
- true if port was open and closed, false - otherwise (was not open etc)
-
stopAndDeleteServer
protected boolean stopAndDeleteServer(int portNum) -
handleAutoClose
-
registerAcceptorSession
Register the session parameters of acceptor.- Parameters:
sessionParameters
- the sessionParameters
-
unregisterAcceptorSession
Remove registered acceptor session. Note: To remove registered acceptor session it's enough to pass SessionParameters with right SenderComId and TargetCompId for a moment.- Parameters:
sessionParameters
-
-
getRegisterAcceptorSession
-
getConfigPath
Path to config file- Returns:
- path to config file
-
setConfigPath
Set path to config file- Parameters:
configPath
- path to config file
-
setIncomingConnectionExecutor
Set custom executor service.- Parameters:
executorService
- the executor will be used for working with incoming connections.
-
getConfiguredServerSocketFactory
protected ServerSocketFactory getConfiguredServerSocketFactory(@NotNull @NotNull com.epam.fixengine.configuration.Configuration configuration) -
isStarted
public boolean isStarted() -
addServerStatusListener
-
removeServerStatusListener
-
onAddSession
- Specified by:
onAddSession
in interfacecom.epam.fixengine.manager.ConfiguredSessionListener
-
onRemoveSession
- Specified by:
onRemoveSession
in interfacecom.epam.fixengine.manager.ConfiguredSessionListener
-
validateBeforeRegistration
-