List of usage examples for org.apache.commons.configuration XMLConfiguration getProperty
public Object getProperty(String key)
From source file:cn.quickj.Setting.java
@SuppressWarnings("unchecked") private static void loadPlugin(XMLConfiguration config) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Object property = config.getProperty("plugins.plugin.class"); if (property instanceof Collection) { Collection<String> pluginClazzs = (Collection<String>) property; int i = 0; for (String pluginClazz : pluginClazzs) { createPlugin(config, pluginClazz, i); i++;/*from w w w . j av a 2 s. com*/ } } else { if (property != null) createPlugin(config, (String) property, 0); } }
From source file:eu.betaas.taas.taasvmmanager.configuration.TaaSVMMAnagerConfiguration.java
private static void loadClouds() { int iter;/*from w w w.j a va2 s. c o m*/ String type; String url; String user; String pass; String[] cloudData; if (clouds == null) { clouds = new HashMap<String, String[]>(); try { XMLConfiguration config = new XMLConfiguration("vmmanager.conf"); iter = 0; while (config.getProperty("clouds.cloud(" + iter + ")") != null) { type = config.getString("clouds.cloud(" + iter + ")[@type]"); url = config.getString("clouds.cloud(" + iter + ").url"); user = config.getString("clouds.cloud(" + iter + ").user"); pass = config.getString("clouds.cloud(" + iter++ + ").password"); cloudData = new String[3]; cloudData[0] = type; cloudData[1] = user; cloudData[2] = pass; clouds.put(url, cloudData); } } catch (ConfigurationException e) { logger.error(e.getMessage()); } } }
From source file:com.termmed.statistics.runner.Runner.java
/** * Inits the file providers./*from w w w .jav a 2 s. c o m*/ * * @param file the file * @throws Exception the exception */ private static void initFileProviders(File file) throws Exception { logger.logInfo("Initializing file providers"); XMLConfiguration xmlConfig; try { xmlConfig = new XMLConfiguration(file); } catch (ConfigurationException e) { logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage()); throw e; } String releaseFolder = xmlConfig.getString("releaseFullFolder"); if (releaseFolder == null || releaseFolder.trim().equals("") || !new File(releaseFolder).exists()) { throw new Exception("Release folder doesn't exist."); } File sourceFolder = new File(releaseFolder); Object prop = xmlConfig.getProperty("releaseDependencies.releaseFullFolder"); HashSet<String> releaseDependencies = null; if (prop != null) { if (prop instanceof Collection) { releaseDependencies = new HashSet<String>(); for (String loopProp : (Collection<String>) prop) { releaseDependencies.add(loopProp); } } else if (prop instanceof String) { releaseDependencies = new HashSet<String>(); releaseDependencies.add((String) prop); System.out.println(prop); } } String releaseDate = xmlConfig.getString("releaseDate"); String previousReleaseDate = xmlConfig.getString("previousReleaseDate"); CurrentFile.init(sourceFolder, new File("release" + releaseDate), releaseDependencies, releaseDate); PreviousFile.init(sourceFolder, new File("release" + previousReleaseDate), releaseDependencies, previousReleaseDate); String dependentRelease = xmlConfig.getString("dependentReleaseFullFolder"); if (dependentRelease != null && !dependentRelease.trim().equals("")) { String dependentReleaseDate = xmlConfig.getString("dependentReleaseDate"); if (dependentReleaseDate == null || dependentReleaseDate.trim().equals("")) { dependentReleaseDate = releaseDate; } DependentFile.init(new File(dependentRelease), new File("dependentrelease" + dependentReleaseDate), dependentReleaseDate); } }
From source file:com.termmed.utils.FileHelper.java
/** * Gets the file type by header.//from w w w . j a va 2s. c o m * * @param inputFile the input file * @param isReduced the is reduced * @return the file type by header * @throws Exception the exception */ public static String getFileTypeByHeader(File inputFile, boolean isReduced) throws Exception { String namePattern = null; try { Thread currThread = Thread.currentThread(); if (currThread.isInterrupted()) { return null; } String patternFile; if (isReduced) { patternFile = "validation-rules_reduced.xml"; } else { patternFile = "validation-rules.xml"; } XMLConfiguration xmlConfig = new XMLConfiguration( FileHelper.class.getResource("/org/ihtsdo/utils/" + patternFile)); if (xmlConfig == null) { String error = "Pattern file '" + patternFile + "' doesn't exist."; log.error(error); throw new Exception(error); } List<String> namePatterns = new ArrayList<String>(); Object prop = xmlConfig.getProperty("files.file.fileType"); if (prop instanceof Collection) { namePatterns.addAll((Collection) prop); } // System.out.println(""); boolean toCheck = false; String headerRule = null; FileInputStream fis = new FileInputStream(inputFile); InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); BufferedReader br = new BufferedReader(isr); String header = br.readLine(); if (header != null) { for (int i = 0; i < namePatterns.size(); i++) { if (currThread.isInterrupted()) { return null; } headerRule = xmlConfig.getString("files.file(" + i + ").headerRule.regex"); namePattern = namePatterns.get(i); // log.info("==================================="); // log.info("For file : " + inputFile.getAbsolutePath()); // log.info("namePattern:" + namePattern); // log.info("headerRule:" + headerRule); if (header.matches(headerRule)) { // log.info("Match"); if ((inputFile.getName().toLowerCase().contains("textdefinition") && namePattern.equals("rf2-descriptions")) || (inputFile.getName().toLowerCase().contains("description") && namePattern.equals("rf2-textDefinition"))) { continue; } toCheck = true; break; } } } if (!toCheck) { log.info("Header for null pattern:" + header); namePattern = null; //System.out.println( "Cannot found header matcher for : " + inputFile.getName()); } br.close(); } catch (FileNotFoundException e) { System.out.println("FileAnalizer: " + e.getMessage()); } catch (UnsupportedEncodingException e) { System.out.println("FileAnalizer: " + e.getMessage()); } catch (IOException e) { System.out.println("FileAnalizer: " + e.getMessage()); } catch (ConfigurationException e) { System.out.println("FileAnalizer: " + e.getMessage()); } return namePattern; }
From source file:net.sf.tweety.cli.plugins.CliMain.java
/** * This method is meant to load the tweety plugin pathes on startup * /* w ww . ja v a2 s .co m*/ * @return an object with one or more pluginpathes * @throws ConfigurationException */ public static Map<String, String> configCLI() throws ConfigurationException, FileNotFoundException { System.out.println("Initialize CLI..."); // TODO : exception handling for empty/erroneous configuration Map<String, String> loadablePlugins = new HashMap<String, String>(); XMLConfiguration tweetyXmlConfig = new XMLConfiguration(); File in = new File(TWEETY_CLI_DEFAULT_CONFIG); try { System.out.print("Loading Configuration..."); String inPath = in.getAbsolutePath(); tweetyXmlConfig .setBasePath(inPath.substring(0, inPath.length() - TWEETY_CLI_DEFAULT_CONFIG.length() - 1)); tweetyXmlConfig.load(in); System.out.print("success.\n"); } catch (NullPointerException e) { e.printStackTrace(); } // map ueber "plugins.plugin" mit keys () // TODO: Verhalten bei leeren Feldern pruefen // TODO: Verhalten bei einem einzelnen Eintrag prfen Iterator<String> it = tweetyXmlConfig.getKeys("plugin"); // // TODO fix the casts! // if (it.hasNext()) { // // String pluginPath = (String) tweetyXmlConfig.getProperty(it.next() // .toString()); // // String pluginName = (String) tweetyXmlConfig.getProperty(it.next() // .toString()); // // // for (int i = 0; i < pluginPath.size(); i++) { // // System.out.println(pluginName.get(i) + pluginPath.get(i)); // loadablePlugins.put(pluginName, pluginPath); // } // } System.out.print("Getting Plugins..."); // TODO fix the casts! if (it.hasNext()) { @SuppressWarnings("unchecked") ArrayList<String> pluginPath = (ArrayList<String>) tweetyXmlConfig.getProperty(it.next()); @SuppressWarnings("unchecked") ArrayList<String> pluginName = (ArrayList<String>) tweetyXmlConfig.getProperty(it.next()); for (int i = 0; i < pluginPath.size(); i++) { // System.out.println(pluginName.get(i) + pluginPath.get(i)); loadablePlugins.put(pluginName.get(i), pluginPath.get(i)); } } System.out.print("done.\n"); System.out.println("CLI initialized"); return loadablePlugins; }
From source file:com.voidsearch.voidbase.config.VoidBaseConfig.java
protected XMLConfiguration mergeConfiguration(List<String> files) throws ConfigException { XMLConfiguration config = new XMLConfiguration(); for (String file : files) { Iterator<String> keys; XMLConfiguration fragment; try {//ww w. j ava 2 s . com logger.info("Loading configuration file: " + file); fragment = new XMLConfiguration(file); keys = fragment.getKeys(); } catch (ConfigurationException e) { GenericUtil.logException(e); throw new ConfigException("Failed to load configuration from: " + file); } while (keys.hasNext()) { String key = keys.next(); // sanity check if (config.containsKey(key)) { throw new ConfigException("Collision of keys for: " + key); } // merge configuration config.addProperty(key, fragment.getProperty(key)); } } return config; }
From source file:com.termmed.control.executor.PatternExecutor.java
/** * Execute.//from www. j a v a2 s . com * * @throws IOException Signals that an I/O exception has occurred. * @throws Exception the exception */ public void execute() throws IOException, Exception { logger.logInfo("Starting patterns execution"); XMLConfiguration xmlConfig; try { xmlConfig = new XMLConfiguration(configFile); } catch (ConfigurationException e) { logger.logInfo("ClassificationRunner - Error happened getting params configFile." + e.getMessage()); throw e; } String runControls = xmlConfig.getString("patternExecutions.runControlPatterns"); if (runControls == null || !runControls.toLowerCase().equals("true")) { return; } resultOutputFolder = I_Constants.PATTERN_OUTPUT_FOLDER; File resultTmpFolder = new File(resultOutputFolder); if (!resultTmpFolder.exists()) { resultTmpFolder.mkdirs(); } else { FileHelper.emptyFolder(resultTmpFolder); } this.releaseDate = xmlConfig.getString("releaseDate"); this.previousReleaseDate = xmlConfig.getString("previousReleaseDate"); getNewConcepts(); getChangedConcepts(); excludes = new HashSet<String>(); Object prop = xmlConfig.getProperty("patternExecutions.exclusions.patternId"); if (prop != null) { if (prop instanceof Collection) { for (String loopProp : (Collection<String>) prop) { excludes.add(loopProp); } } else if (prop instanceof String) { excludes.add((String) prop); } } String relativePath = "src/main/resources/"; String path = "org/ihtsdo/control/patterns"; if (new File(relativePath).isDirectory()) { path = relativePath + path; logger.logInfo("Getting patterns from file system: " + path); executeFromFileSystem(path); } else { logger.logInfo("Getting patterns from resources: " + path); executeFromResources(path); } }
From source file:io.datalayer.conf.XmlConfigurationTest.java
/** * Tests the copy constructor./*from www .j a v a 2s . co m*/ */ @Test public void testInitCopy() throws ConfigurationException { XMLConfiguration copy = new XMLConfiguration(conf); assertEquals("value", copy.getProperty("element")); assertNull("Document was copied, too", copy.getDocument()); ConfigurationNode root = copy.getRootNode(); for (ConfigurationNode node : root.getChildren()) { assertNull("Reference was not cleared", node.getReference()); } removeTestFile(); copy.setFile(testSaveConf); copy.save(); copy.clear(); checkSavedConfig(copy); }
From source file:it.jnrpe.server.XmlJNRPEConfiguration.java
@SuppressWarnings("rawtypes") @Override//w ww. j a v a 2 s . co m public void load(final File confFile) throws ConfigurationException { // Parse an ini file ServerSection serverConf = getServerSection(); CommandsSection commandSection = getCommandSection(); try { XMLConfiguration confParser = new XMLConfiguration(confFile); List<Object> vBindAddresses = confParser.getList("server.bind[@address]"); int iBindListSize = vBindAddresses.size(); for (int i = 0; i < iBindListSize; i++) { String sAddress = confParser.getString("server.bind(" + i + ")[@address]"); String useSSL = confParser.getString("server.bind(" + i + ")[@SSL]"); if (useSSL == null) { useSSL = "false"; } serverConf.addBindAddress(sAddress, "true".equalsIgnoreCase(useSSL)); } String sAcceptParams = confParser.getString("server[@accept-params]", "true"); serverConf.setAcceptParams( "true".equalsIgnoreCase(sAcceptParams) || "yes".equalsIgnoreCase(sAcceptParams)); serverConf.setPluginPath(confParser.getString("server.plugin[@path]", ".")); serverConf.setBackLogSize(confParser.getInt("server[@backlog-size]", ServerSection.DEFAULT_BACKLOG)); // TODO : move this to publicly accessible constants serverConf.setReadTimeout(confParser.getInteger("server[@read-timeout]", 10)); // TODO : move this to publicly accessible constants serverConf.setWriteTimeout(confParser.getInteger("server[@write-timeout]", 60)); List<Object> vAllowedAddresses = confParser.getList("server.allow[@ip]"); if (vAllowedAddresses != null) { for (Object address : vAllowedAddresses) { serverConf.addAllowedAddress((String) address); } } // Get the commands count ( searching for a better way...) // int iCommandsCount = Object obj = confParser.getProperty("commands.command[@name]"); int iCount = 0; if (obj != null) { if (obj instanceof List) { iCount = ((List) obj).size(); } else { iCount = 1; } } // Loop through configured commands for (int i = 0; i < iCount; i++) { String sCommandName = (String) confParser.getProperty("commands.command(" + i + ")[@name]"); String sPluginName = (String) confParser.getProperty("commands.command(" + i + ")[@plugin_name]"); String sWholeCommandLine = (String) confParser.getProperty("commands.command(" + i + ")[@params]"); if (sWholeCommandLine == null) { sWholeCommandLine = ""; } else { sWholeCommandLine += " "; } // Loop through command arguments... Object argsObj = confParser.getProperty("commands.command(" + i + ").arg[@name]"); int iArgsCount = 0; if (argsObj != null) { if (argsObj instanceof List) { iArgsCount = ((List) argsObj).size(); } else { iArgsCount = 1; } } StringBuilder commandLineBuffer = new StringBuilder(sWholeCommandLine); for (int j = 0; j < iArgsCount; j++) { String sArgName = (String) confParser .getProperty("commands.command(" + i + ").arg(" + j + ")[@name]"); Object value = confParser.getProperty("commands.command(" + i + ").arg(" + j + ")[@value]"); String sArgValue = null; if (value instanceof String) { sArgValue = (String) value; } else if (value instanceof Collection) { sArgValue = StringUtils.join((Collection) value, confParser.getListDelimiter()); } if (sArgName.length() > 1) { commandLineBuffer.append("--"); } else { commandLineBuffer.append('-'); } commandLineBuffer.append(sArgName).append(" "); if (sArgValue != null) { boolean bQuote = sArgValue.indexOf(' ') != -1; // FIXME : handle quote escaping... if (bQuote) { commandLineBuffer.append('\"'); } commandLineBuffer.append(sArgValue); if (bQuote) { commandLineBuffer.append("\""); } commandLineBuffer.append(" "); } } sWholeCommandLine = commandLineBuffer.toString(); commandSection.addCommand(sCommandName, sPluginName, sWholeCommandLine); } } catch (org.apache.commons.configuration.ConfigurationException e) { throw new ConfigurationException(e); } }
From source file:edu.hawaii.soest.kilonalu.adam.AdamSource.java
/** * A method that processes the data ByteBuffer passed in for the given IP * address of the ADAM sensor, parses the binary ADAM data, and flushes the * data to the DataTurbine given the sensor properties in the XMLConfiguration * passed in./*from www . ja va2s . c om*/ * * @param datagramAddress - the IP address of the datagram of this packet of data * @param xmlConfig - the XMLConfiguration object containing the list of * sensor properties * @param sampleBuffer - the binary data sample as a ByteBuffer */ protected boolean process(String datagramAddress, XMLConfiguration xmlConfig, ByteBuffer sampleBuffer) { logger.debug("AdamSource.process() called."); // do not execute the stream if there is no connection if (!isConnected()) return false; boolean failed = false; try { // add channels of data that will be pushed to the server. // Each sample will be sent to the Data Turbine as an rbnb frame. Information // on each channel is found in the XMLConfiguration file (sensors.properties.xml) // and the AdamParser object (to get the actual voltages for each ADAM channel) ChannelMap rbnbChannelMap = new ChannelMap(); // used to flush channels ChannelMap registerChannelMap = new ChannelMap(); // used to register channels int channelIndex = 0; this.adamParser = new AdamParser(sampleBuffer); logger.debug("\n" + "channelZero : " + this.adamParser.getChannelZero() + "\n" + "channelOne : " + this.adamParser.getChannelOne() + "\n" + "channelTwo : " + this.adamParser.getChannelTwo() + "\n" + "channelThree : " + this.adamParser.getChannelThree() + "\n" + "channelFour : " + this.adamParser.getChannelFour() + "\n" + "channelFive : " + this.adamParser.getChannelFive() + "\n" + "channelSix : " + this.adamParser.getChannelSix() + "\n" + "channelSeven : " + this.adamParser.getChannelSeven() + "\n" + "channelAverage : " + this.adamParser.getChannelAverage() + "\n" + "channelZeroMax : " + this.adamParser.getChannelZeroMax() + "\n" + "channelOneMax : " + this.adamParser.getChannelOneMax() + "\n" + "channelTwoMax : " + this.adamParser.getChannelTwoMax() + "\n" + "channelThreeMax : " + this.adamParser.getChannelThreeMax() + "\n" + "channelFourMax : " + this.adamParser.getChannelFourMax() + "\n" + "channelFiveMax : " + this.adamParser.getChannelFiveMax() + "\n" + "channelSixMax : " + this.adamParser.getChannelSixMax() + "\n" + "channelSevenMax : " + this.adamParser.getChannelSevenMax() + "\n" + "channelAverageMax : " + this.adamParser.getChannelAverageMax() + "\n" + "channelZeroMin : " + this.adamParser.getChannelZeroMin() + "\n" + "channelOneMin : " + this.adamParser.getChannelOneMin() + "\n" + "channelTwoMin : " + this.adamParser.getChannelTwoMin() + "\n" + "channelThreeMin : " + this.adamParser.getChannelThreeMin() + "\n" + "channelFourMin : " + this.adamParser.getChannelFourMin() + "\n" + "channelFiveMin : " + this.adamParser.getChannelFiveMin() + "\n" + "channelSixMin : " + this.adamParser.getChannelSixMin() + "\n" + "channelSevenMin : " + this.adamParser.getChannelSevenMin() + "\n" + "channelAverageMin : " + this.adamParser.getChannelAverageMin() + "\n" ); // create a TreeMap to hold the voltageChannel and its associated // RBNB ChannelMap channel string. When the RBNB ChannelMap is // populated, this TreeMap will be consulted TreeMap<Integer, String> voltageChannelTreeMap = new TreeMap<Integer, String>(); // create a character string to store characters from the voltage values StringBuilder decimalASCIISampleData = new StringBuilder(); // Create a list of sensors from the properties file, and iterate through // the list, matching the datagram IP address to the address in the // xml configuration file. If there is a match, find the correct voltage // channel to measurement mappings, create a corresponding RBNB channel // map, and flush the data to the DataTurbine. List sensorList = xmlConfig.getList("sensor.address"); // declare the properties that will be pulled from the // sensor.properties.xml file String address = ""; String sourceName = ""; String description = ""; String type = ""; String cacheSize = ""; String archiveSize = ""; String archiveChannel = ""; String portNumber = ""; String voltageChannel = ""; String measurement = ""; // evaluate each sensor listed in the sensor.properties.xml file for (Iterator sIterator = sensorList.iterator(); sIterator.hasNext();) { // get each property value of the sensor int index = sensorList.indexOf(sIterator.next()); address = (String) xmlConfig.getProperty("sensor(" + index + ").address"); sourceName = (String) xmlConfig.getProperty("sensor(" + index + ").name"); description = (String) xmlConfig.getProperty("sensor(" + index + ").description"); type = (String) xmlConfig.getProperty("sensor(" + index + ").type"); logger.debug("Sensor details:" + "\n\t\t\t\t\t\t\t\t\t\taddress : " + address + "\n\t\t\t\t\t\t\t\t\t\tname : " + sourceName + "\n\t\t\t\t\t\t\t\t\t\tdescription : " + description + "\n\t\t\t\t\t\t\t\t\t\ttype : " + type); // move to the next sensor if this doesn't match the RBNB source name if (!sourceName.equals(getRBNBClientName())) { continue; } List portList = xmlConfig.getList("sensor(" + index + ").ports.port[@number]"); // get each port of the sensor, along with the port properties for (Iterator pIterator = portList.iterator(); pIterator.hasNext();) { int pindex = portList.indexOf(pIterator.next()); // get the port number value portNumber = (String) xmlConfig .getProperty("sensor(" + index + ").ports.port(" + pindex + ")[@number]"); logger.debug("\tport " + portNumber + " details:"); List measurementList = xmlConfig .getList("sensor(" + index + ").ports.port(" + pindex + ").measurement[@label]"); // get each measurement and voltageChannel for the given port for (Iterator mIterator = measurementList.iterator(); mIterator.hasNext();) { int mindex = measurementList.indexOf(mIterator.next()); // build the property paths into the config file String voltagePath = "sensor(" + index + ").ports.port(" + pindex + ").measurement(" + mindex + ").voltageChannel"; String measurementPath = "sensor(" + index + ").ports.port(" + pindex + ").measurement(" + mindex + ")[@label]"; // get the voltageChannel and measurement label values voltageChannel = (String) xmlConfig.getProperty(voltagePath); measurement = (String) xmlConfig.getProperty(measurementPath); logger.debug("\t\t" + "voltageChannel: " + voltageChannel + "\n\t\t\t\t\t\t\t\t\t\t\t" + "measurement label: " + measurement); // Match the datagram address with the address in the xmlConfig file if (datagramAddress.equals(address)) { // and only add channel data for this class instance RBNB Source name if (sourceName.equals(getRBNBClientName())) { // create an Integer out of the voltageChannel Integer voltageChannelInt = new Integer(voltageChannel); // build the RBNB channel path string String channelPath = "port" + "/" + portNumber + "/" + measurement; voltageChannelTreeMap.put(voltageChannelInt, channelPath); } else { logger.debug("\t\tSource names don't match: " + sourceName + " != " + getRBNBClientName()); } // end sourceName if() statement } else { logger.debug("\t\tNo IP address match. " + datagramAddress + " != " + address); } //end IP address if() statement } // end for each channel } // end for each port // now that we've found the correct sensor, exit the sensor loop break; } // end for each sensor // Build the RBNB channel map from the entries in the tree map // by doing a lookup of the ADAM voltage channel values based // on the voltage channel number in the treemap. Also add the voltages // to the DecimalASCIISampleData string (and then channel) for (Iterator vcIterator = voltageChannelTreeMap.keySet().iterator(); vcIterator.hasNext();) { int voltageChannelFromMap = ((Integer) vcIterator.next()).intValue(); String channelPathFromMap = voltageChannelTreeMap.get(voltageChannelFromMap); float voltageValue = -9999.0f; // look up the voltage value from the AdamParser object based // on the voltage channel set in the xmlConfig file (via the treemap) switch (voltageChannelFromMap) { case 0: voltageValue = this.adamParser.getChannelZero(); break; case 1: voltageValue = this.adamParser.getChannelOne(); break; case 2: voltageValue = this.adamParser.getChannelTwo(); break; case 3: voltageValue = this.adamParser.getChannelThree(); break; case 4: voltageValue = this.adamParser.getChannelFour(); break; case 5: voltageValue = this.adamParser.getChannelFive(); break; case 6: voltageValue = this.adamParser.getChannelSix(); break; case 7: voltageValue = this.adamParser.getChannelSeven(); break; } // now add the channel and the voltage value to the RBNB channel maps channelIndex = registerChannelMap.Add(channelPathFromMap); registerChannelMap.PutUserInfo(channelIndex, "units=volts"); registerChannelMap.PutUserInfo(channelIndex, "description=" + description); logger.debug("Voltage Channel Tree Map: " + voltageChannelTreeMap.toString()); // then the channel and voltage channelIndex = rbnbChannelMap.Add(channelPathFromMap); rbnbChannelMap.PutMime(channelIndex, "application/octet-stream"); rbnbChannelMap.PutDataAsFloat32(channelIndex, new float[] { voltageValue }); decimalASCIISampleData.append(String.format("%05.3f", (Object) voltageValue) + ", "); } // and only flush data for this class instance RBNB Source name if (sourceName.equals(getRBNBClientName()) && datagramAddress.equals(address)) { // add the timestamp to the rbnb channel map registerChannelMap.PutTimeAuto("server"); rbnbChannelMap.PutTimeAuto("server"); // then add a timestamp to the end of the ASCII version of the sample DATE_FORMAT.setTimeZone(TZ); String sampleDateAsString = DATE_FORMAT.format(new Date()).toString(); decimalASCIISampleData.append(sampleDateAsString); decimalASCIISampleData.append("\n"); // add the DecimalASCIISampleData channel to the channelMap channelIndex = registerChannelMap.Add(getRBNBChannelName()); channelIndex = rbnbChannelMap.Add(getRBNBChannelName()); rbnbChannelMap.PutMime(channelIndex, "text/plain"); rbnbChannelMap.PutDataAsString(channelIndex, decimalASCIISampleData.toString()); // Now register the RBNB channels, and flush the rbnbChannelMap to the // DataTurbine getSource().Register(registerChannelMap); getSource().Flush(rbnbChannelMap); logger.info(getRBNBClientName() + " Sample sent to the DataTurbine: " + decimalASCIISampleData.toString()); registerChannelMap.Clear(); rbnbChannelMap.Clear(); sampleBuffer.clear(); } else { logger.debug("\t\tSource names don't match: " + sourceName + " != " + getRBNBClientName()); registerChannelMap.Clear(); rbnbChannelMap.Clear(); sampleBuffer.clear(); } } catch (SAPIException sapie) { // In the event of an RBNB communication exception, log the exception, // and allow execute() to return false, which will prompt a retry. failed = true; sapie.printStackTrace(); return !failed; } return !failed; }