com.teraspaces.qwfix
Class FIXStandaloneApplication

java.lang.Object
  extended by com.teraspaces.qwfix.FIXApplication
      extended by com.teraspaces.qwfix.FIXStandaloneApplication

public final class FIXStandaloneApplication
extends FIXApplication

Provides methods and properties to manage a standlone application, such as methods to start and stop an application and properties to get information about a stand alone application. This class cannot be inherited.

The FIXStandaloneApplication is the most commonly used application framework. A stand alone application manages only one FIX engine. Its life cycle is controller by the scheduler of the FIX engine.


Constructor Summary
FIXStandaloneApplication(com.teraspaces.qwfix.repository.FIXRepository repository)
          Instantiates a new fIX standalone application.
FIXStandaloneApplication(com.teraspaces.qwframework.io.SecureUri repositoryUri)
          Instantiates a new fIX standalone application.
FIXStandaloneApplication(String repositoryUriString, String repositoryLoginName, String repositoryLoginPassword)
          Instantiates a new fIX standalone application.
 
Method Summary
 void addListener(FIXStandaloneApplicationListener listener)
          Adds an event listener.
 void exit()
          Turns off the scheduler and close the repository.
 FIXEngine getFIXEngine()
          Gets the FIX engine.
 boolean isEngineSettingsUpdated(String engineName, String fixLogDirectory)
          Determines whether FIX engine settings has been updated.
 boolean isRecoveryRequired(String engineName, String fixLogDirectory)
          Determines whether recovery is required for the FIX engine specified.
 void registerRemoteService(String serviceName, com.teraspaces.qwframework.communication.QWRemoteServiceActivator serviceActivator)
          Registers the remote service.
 void removeListener(FIXStandaloneApplicationListener listener)
          Removes an event listener.
 void run(String engineName, FIXEngineRole role, String fixLogDirectory, FIXStandaloneApplicationStartupMode startupMode, boolean syncIncomingMessages)
          Starts the application.
 
Methods inherited from class com.teraspaces.qwfix.FIXApplication
getEngineSettingsLoader, getRepositoryUri, getSchedulerLoader, getSchemaLoader, getSessionSettingsLoader, getVisualLambdaLoader
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FIXStandaloneApplication

public FIXStandaloneApplication(com.teraspaces.qwfix.repository.FIXRepository repository)
Instantiates a new fIX standalone application.

Parameters:
repository - the repository

FIXStandaloneApplication

public FIXStandaloneApplication(com.teraspaces.qwframework.io.SecureUri repositoryUri)
Instantiates a new fIX standalone application.

Parameters:
repositoryUri - the repository uri

FIXStandaloneApplication

public FIXStandaloneApplication(String repositoryUriString,
                                String repositoryLoginName,
                                String repositoryLoginPassword)
Instantiates a new fIX standalone application.

Parameters:
repositoryUriString - the repository uri string
repositoryLoginName - the repository login name
repositoryLoginPassword - the repository login password
Method Detail

isRecoveryRequired

public boolean isRecoveryRequired(String engineName,
                                  String fixLogDirectory)
Determines whether recovery is required for the FIX engine specified.

Recovery is required if the process is unexpectedly terminated and the FIX engine scheduler of the current engine has not expired as of the time this method is called.

This method should be called before run(String, FIXEngineRole, String, FIXStandaloneApplicationStartupMode, boolean) is called. The main purpose of this method is to give user an option to determine FIXStandaloneApplicationStartupMode parameter in run method; if recovery is required. For example, if engineSettingsUpdated is true, RECOVER will keep using the old FIX engine settings; while RECONFIG will take the latest settings and convert the message log to the latest settings before starting the FIX engine (Note: Some restriction may apply about how the settings can be modified in order to use RECONFIG).

Parameters:
engineName - the engine name
fixLogDirectory - the FIX log directory
Returns:
true if recovery is required; otherwise, false.

isEngineSettingsUpdated

public boolean isEngineSettingsUpdated(String engineName,
                                       String fixLogDirectory)
Determines whether FIX engine settings has been updated.

Parameters:
engineName - the engine name
fixLogDirectory - the FIX log directory
Returns:
true, if is engine setting is updated

run

public void run(String engineName,
                FIXEngineRole role,
                String fixLogDirectory,
                FIXStandaloneApplicationStartupMode startupMode,
                boolean syncIncomingMessages)
Starts the application.

The application will try to load the settings for the FIXEngine by specified engineName.

If the process is started before the start time of the engine scheduler, the process will wait until the scheduler is kicked start at the start time. The engine may stay uninitialized for a long time. Accessing properties such as Settings from the uninitialized FIXEngine is meaningless, and should be treated as a bug in your application.

If processed is restarted in recovery mode, the version of the FIX engine settings will stay the same, even if the latest settings has been changed in the repository. Use Reset or RECONFIG to catch up the latest version change. See FIXStandaloneApplicationStartupMode for more details.

Parameters:
engineName - the engine name
role - the role
fixLogDirectory - the FIX log directory
startupMode - the start up mode that affects the handling of version of settings
syncIncomingMessages - If set to true the incoming messages will be processed by one thread; otherwise, each session will create a separate thread to process incoming FIX messages.

exit

public void exit()
Turns off the scheduler and close the repository.

This method does not actually terminate the process!


getFIXEngine

public FIXEngine getFIXEngine()
Gets the FIX engine.

The FIX engine won't be available until FIXStandaloneApplicationListener.engineInitialized(FIXEngine) event is triggered.

Returns:
the FIX engine

addListener

public void addListener(FIXStandaloneApplicationListener listener)
Adds an event listener.

The method is thread safe.

Parameters:
listener - the listener

removeListener

public void removeListener(FIXStandaloneApplicationListener listener)
Removes an event listener.

The method is thread safe.

Parameters:
listener - the listener

registerRemoteService

public void registerRemoteService(String serviceName,
                                  com.teraspaces.qwframework.communication.QWRemoteServiceActivator serviceActivator)
Registers the remote service. Normal application doesn't need to call this method.

Parameters:
serviceName - the service name
serviceActivator - the service activator