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 ServeraddServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, Integer port, Server server, com.epam.fixengine.acceptor.ConnectionHandler handler) voidaddServerStatusListener(FIXServerStatusListener statusListener) protected voidbooleanclosePort(int portNum) Closes port for listening of incoming FIX sessions on the given port.protected ServercreateServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose) protected ServerdeleteServer(Integer port) protected SessionAcceptorStrategyHandlergetAcceptorStrategy(com.epam.fixengine.session.util.ConfigurationAdaptor configuration, com.epam.fixengine.manager.ConfiguredSessionRegister configuredSessionRegister) Path to config fileprotected ServerSocketFactorygetConfiguredServerSocketFactory(@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 ServergetServer(com.epam.fixengine.session.util.ConfigurationAdaptor config, int port, boolean autoClose) protected SessionTransportFactorygetTransportFactory(com.epam.fixengine.configuration.Configuration configuration) protected booleanhandleAutoClose(Integer portNum, Server server) booleanvoidonAddSession(SessionParameters params) voidonRemoveSession(SessionParameters params) booleanopenPort(int portNum) Opens port for listening of incoming FIX sessions on the given port (immediately if FIXServer is already started, or after its start).booleanopenPort(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).booleanopenPort(com.epam.fixengine.configuration.Configuration config, int portNum) booleanopenPort(com.epam.fixengine.configuration.Configuration config, int portNum, boolean autoClose) voidregisterAcceptorSession(SessionParameters sessionParameters) Register the session parameters of acceptor.protected voidvoidremoveServerStatusListener(FIXServerStatusListener statusListener) voidsetConfigPath(String configPath) Set path to config filevoidsetConnectionValidator(ConnectionValidator connectionValidator) voidsetIncomingConnectionExecutor(ExecutorService executorService) Set custom executor service.voidsetListener(FIXServerListener listener) Sets listener.voidsetLoginWaitTimeout(int loginWaitTimeout) Sets login timeout.voidvoidsetPort(int port) Sets port to listen on.voidsetPorts(int... ports) Sets ports to listen on.voidsetPorts(com.epam.fixengine.session.util.ConfigurationAdaptor config, int... ports) voidReplaces default TCPServer implementation with custom Server implementation.booleanstart()Actually starts the servers.voidstop()Stops the server.protected booleanstopAndDeleteServer(int portNum) voidunregisterAcceptorSession(SessionParameters sessionParameters) Remove registered acceptor session.protected voidvalidateBeforeRegistration(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:
onAddSessionin interfacecom.epam.fixengine.manager.ConfiguredSessionListener
-
onRemoveSession
- Specified by:
onRemoveSessionin interfacecom.epam.fixengine.manager.ConfiguredSessionListener
-
validateBeforeRegistration
-