use of quickfix.DefaultMessageFactory in project camel by apache.
the class QuickfixjComponentTest method setUpComponent.
private void setUpComponent(boolean injectQfjPlugins) throws IOException, MalformedURLException, NoSuchMethodException {
camelContext = new DefaultCamelContext();
component = new QuickfixjComponent();
component.setCamelContext(camelContext);
camelContext.addComponent("quickfix", component);
if (injectQfjPlugins) {
engineMessageFactory = new DefaultMessageFactory();
engineMessageStoreFactory = new MemoryStoreFactory();
engineLogFactory = new ScreenLogFactory();
component.setMessageFactory(engineMessageFactory);
component.setMessageStoreFactory(engineMessageStoreFactory);
component.setLogFactory(engineLogFactory);
}
assertThat(component.getEngines().size(), is(0));
Method converterMethod = QuickfixjConverters.class.getMethod("toSessionID", new Class<?>[] { String.class });
camelContext.getTypeConverterRegistry().addTypeConverter(SessionID.class, String.class, new StaticMethodTypeConverter(converterMethod, false));
}
use of quickfix.DefaultMessageFactory 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