/* Global dictionary, read only once: * com.reuters.tibmsg.TibException: Specified data dictionary has already been loaded/unpacked */ static { Context.initialize(); dictionary = FieldDictionary.create(); FieldDictionary.readRDMFieldDictionary(dictionary, "RDMFieldDictionary"); FieldDictionary.readEnumTypeDef(dictionary, "enumtype.def"); biddef = dictionary.getFidDef("BID"); askdef = dictionary.getFidDef("ASK"); }
public void init() throws Exception { LOG.trace("Initializing RFA."); Context.initialize(null); /* Populate Config Database. */ LOG.trace("Populating RFA config database."); ConfigDb staging = new ConfigDb(); for (SessionConfig session_config : this.config.getSessions()) { final String session_name = session_config.getSessionName(), connection_name = session_config.getConnectionName(); String name, value; /* Session list */ name = "/Sessions/" + session_name + "/connectionList"; value = connection_name; staging.addVariable(fixRfaStringPath(name), value); /* Logging per connection */ name = "/Connections/" + connection_name + "/logFileName"; value = "none"; staging.addVariable(fixRfaStringPath(name), value); /* List of servers */ name = "/Connections/" + connection_name + "/serverList"; value = Joiner.on(",").join(session_config.getServers()); staging.addVariable(fixRfaStringPath(name), value); /* Default port */ if (session_config.hasDefaultPort()) { name = "/Connections/" + connection_name + "/portNumber"; value = session_config.getDefaultPort(); staging.addVariable(fixRfaStringPath(name), value); } /* Protocol ping interval */ if (session_config.hasPingInterval()) { name = "/Connections/" + connection_name + "/pingInterval"; value = session_config.getPingInterval(); staging.addVariable(fixRfaStringPath(name), value); } /* Communications protocol */ name = "/Connections/" + connection_name + "/connectionType"; if (session_config.getProtocol().equalsIgnoreCase(RSSL_PROTOCOL)) { value = "RSSL"; staging.addVariable(fixRfaStringPath(name), value); if (RSSL_TRACE) { name = "/Connections/" + connection_name + "/ipcTraceFlags"; value = "31"; staging.addVariable(fixRfaStringPath(name), value); } if (RSSL_MOUNT_TRACE) { name = "/Connections/" + connection_name + "/mountTrace"; value = "True"; staging.addVariable(fixRfaStringPath(name), value); } } else if (session_config.getProtocol().equalsIgnoreCase(SSLED_PROTOCOL)) { value = "SSL"; staging.addVariable(fixRfaStringPath(name), value); name = "/Connections/" + connection_name + "/userName"; StringBuilder username = new StringBuilder(); if (session_config.hasUserName()) { username.append(session_config.getUserName()); } else { username.append(System.getProperty("user.name")); } if (session_config.hasApplicationId()) { username.append('+'); username.append(session_config.getApplicationId()); if (session_config.hasPosition()) { if (!session_config.getPosition().isEmpty()) { username.append('+'); username.append(session_config.getPosition()); } } else { username.append('+'); username.append(InetAddress.getLocalHost().getHostAddress()); username.append('/'); username.append(InetAddress.getLocalHost().getHostName()); } } value = username.toString(); staging.addVariable(fixRfaStringPath(name), value); /* 9.10.2. Merged Thread Model */ name = "/Sessions/" + session_name + "/shareConnections"; value = "False"; staging.addVariable(fixRfaStringPath(name), value); /* Enable dictionary download */ name = "/Connections/" + connection_name + "/downloadDataDict"; value = !(session_config.hasFieldDictionary() && session_config.hasEnumDictionary()) ? "True" : "False"; staging.addVariable(fixRfaStringPath(name), value); /* appendix_a */ if (session_config.hasFieldDictionary()) { name = "/Connections/" + connection_name + "/masterFidFile"; value = session_config.getFieldDictionary(); staging.addVariable(fixRfaStringPath(name), value); } /* enumtype.def */ if (session_config.hasEnumDictionary()) { name = "/Connections/" + connection_name + "/enumTypeFile"; value = session_config.getEnumDictionary(); staging.addVariable(fixRfaStringPath(name), value); } /* Disable client side DACS usage */ name = "/Connections/" + connection_name + "/dacs_CbeEnabled"; value = "False"; staging.addVariable(fixRfaStringPath(name), value); name = "/Connections/" + connection_name + "/dacs_SbeSubEnabled"; staging.addVariable(fixRfaStringPath(name), value); if (SSL_TRACE) { name = "/Connections/" + connection_name + "/ipcTraceFlags"; value = "15"; staging.addVariable(fixRfaStringPath(name), value); } } else { throw new Exception( "Unsupported transport protocol \"" + session_config.getProtocol() + "\"."); } } LOG.trace("Merging RFA config database with staging database."); this.rfa_config = staging; Context.initialize(this.rfa_config); /* TODO: Java properties override */ /* Dump effective Java properties configuration */ LOG.debug("Dumping configuration database:{}{}", LINE_SEPARATOR, this.rfa_config); LOG.trace("RFA initialization complete."); }
public void clear() { LOG.trace("Uninitializing RFA."); Context.uninitialize(); }