use of quickfix.ConfigError in project camel by apache.
the class QuickfixjEngine method isConnectorRole.
private boolean isConnectorRole(SessionSettings settings, String connectorRole) throws ConfigError {
boolean hasRole = false;
Iterator<SessionID> sessionIdItr = settings.sectionIterator();
while (sessionIdItr.hasNext()) {
try {
if (connectorRole.equals(settings.getString(sessionIdItr.next(), SessionFactory.SETTING_CONNECTION_TYPE))) {
hasRole = true;
break;
}
} catch (FieldConvertError e) {
throw new ConfigError(e);
}
}
return hasRole;
}
use of quickfix.ConfigError in project camel by apache.
the class QuickfixjEngine method inferLogFactory.
private LogFactory inferLogFactory(SessionSettings settings) throws ConfigError {
Set<LogFactory> impliedLogFactories = new HashSet<LogFactory>();
isFileLog(settings, impliedLogFactories);
isScreenLog(settings, impliedLogFactories);
isSL4JLog(settings, impliedLogFactories);
isJdbcLog(settings, impliedLogFactories);
if (impliedLogFactories.size() > 1) {
throw new ConfigError("Ambiguous log factory implied in configuration");
}
LogFactory sessionLogFactory;
if (impliedLogFactories.size() == 1) {
sessionLogFactory = impliedLogFactories.iterator().next();
} else {
// Default
sessionLogFactory = new ScreenLogFactory(settings);
}
LOG.info("Inferring log factory: {}", sessionLogFactory.getClass().getName());
return sessionLogFactory;
}
use of quickfix.ConfigError in project camel by apache.
the class QuickfixjEngine method inferMessageStoreFactory.
private MessageStoreFactory inferMessageStoreFactory(SessionSettings settings) throws ConfigError {
Set<MessageStoreFactory> impliedMessageStoreFactories = new HashSet<MessageStoreFactory>();
isJdbcStore(settings, impliedMessageStoreFactories);
isFileStore(settings, impliedMessageStoreFactories);
isSleepycatStore(settings, impliedMessageStoreFactories);
if (impliedMessageStoreFactories.size() > 1) {
throw new ConfigError("Ambiguous message store implied in configuration.");
}
MessageStoreFactory messageStoreFactory;
if (impliedMessageStoreFactories.size() == 1) {
messageStoreFactory = impliedMessageStoreFactories.iterator().next();
} else {
messageStoreFactory = new MemoryStoreFactory();
}
LOG.info("Inferring message store factory: {}", messageStoreFactory.getClass().getName());
return messageStoreFactory;
}
use of quickfix.ConfigError in project camel by apache.
the class QuickfixjEngine method initializeEngine.
/**
* Initializes the engine on demand. May be called immediately in constructor or when needed.
* If initializing later, it should be started afterwards.
*/
void initializeEngine() throws ConfigError, FieldConvertError, JMException {
if (messageFactory == null) {
messageFactory = new DefaultMessageFactory();
}
if (sessionLogFactory == null) {
sessionLogFactory = inferLogFactory(settings);
}
if (messageStoreFactory == null) {
messageStoreFactory = inferMessageStoreFactory(settings);
}
// Set default session schedule if not specified in configuration
if (!settings.isSetting(Session.SETTING_START_TIME)) {
settings.setString(Session.SETTING_START_TIME, DEFAULT_START_TIME);
}
if (!settings.isSetting(Session.SETTING_END_TIME)) {
settings.setString(Session.SETTING_END_TIME, DEFAULT_END_TIME);
}
// Default heartbeat interval
if (!settings.isSetting(Session.SETTING_HEARTBTINT)) {
settings.setLong(Session.SETTING_HEARTBTINT, DEFAULT_HEARTBTINT);
}
// Allow specification of the QFJ threading model
ThreadModel threadModel = ThreadModel.ThreadPerConnector;
if (settings.isSetting(SETTING_THREAD_MODEL)) {
threadModel = ThreadModel.valueOf(settings.getString(SETTING_THREAD_MODEL));
}
if (settings.isSetting(SETTING_USE_JMX) && settings.getBool(SETTING_USE_JMX)) {
LOG.info("Enabling JMX for QuickFIX/J");
jmxExporter = new JmxExporter();
} else {
jmxExporter = null;
}
// From original component implementation...
// To avoid this exception in OSGi platform
// java.lang.NoClassDefFoundError: quickfix/fix41/MessageFactory
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
if (isConnectorRole(settings, SessionFactory.ACCEPTOR_CONNECTION_TYPE)) {
acceptor = createAcceptor(new Dispatcher(), settings, messageStoreFactory, sessionLogFactory, messageFactory, threadModel);
} else {
acceptor = null;
}
if (isConnectorRole(settings, SessionFactory.INITIATOR_CONNECTION_TYPE)) {
initiator = createInitiator(new Dispatcher(), settings, messageStoreFactory, sessionLogFactory, messageFactory, threadModel);
} else {
initiator = null;
}
if (acceptor == null && initiator == null) {
throw new ConfigError("No connector role");
}
} finally {
Thread.currentThread().setContextClassLoader(ccl);
}
initialized.set(true);
}
Aggregations