當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLConfiguration.load方法代碼示例

本文整理匯總了Java中org.apache.commons.configuration.XMLConfiguration.load方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLConfiguration.load方法的具體用法?Java XMLConfiguration.load怎麽用?Java XMLConfiguration.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.configuration.XMLConfiguration的用法示例。


在下文中一共展示了XMLConfiguration.load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadExtraConfigration

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
@Override
protected boolean loadExtraConfigration() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;
            if (node.getName().equals(KEY_RELATED_LSP_FIELD_NAME)) {
                setRelatedRsvplspFieldName((String) node.getValue());
                return true;
            }
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }
    return false;
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:21,代碼來源:NmsCorePseudoWireConfiguration.java

示例2: loadExtraConfigration

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
@Override
protected boolean loadExtraConfigration() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;
            if (node.getName().equals(KEY_HOP_IP_PATH_FIELD_NAME)) {
                List<String> values = new ArrayList<String>();

                for (Object value : node.getChildren()) {
                    values.add((String) ((Node) value).getValue());
                }
                setHopIpPathFieldsName(values);
                return true;
            }
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }
    return false;
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:26,代碼來源:NmsCoreRsvpLspConfiguration.java

示例3: reloadConfigurationInner

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
@Override
protected synchronized void reloadConfigurationInner() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        String __isSystemUserUpdateEnabled = config.getString(KEY_ENABLE_SYSTEM_USER_UPDATE);
        boolean _isSystemUserUpdateEnabled = (__isSystemUserUpdateEnabled == null ? false :
                Boolean.parseBoolean(__isSystemUserUpdateEnabled));

        this.isSystemUserUpdateEnabled = _isSystemUserUpdateEnabled;

        log().info("isSystemUserUpdateEnabled=" + this.isSystemUserUpdateEnabled);
        log().info("reload finished.");
    } catch (ConfigurationException e) {
        log().error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + FILE_NAME);
    }
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:21,代碼來源:BuilderConfiguration.java

示例4: load

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
/**
 * Loads and parse CME MDP Configuration.
 *
 * @param uri URI to CME MDP Configuration (config.xml, usually available on CME FTP)
 * @throws ConfigurationException if failed to parse configuration file
 * @throws MalformedURLException  if URI to Configuration is malformed
 */
private void load(final URI uri) throws ConfigurationException, MalformedURLException {
    // todo: if to implement the same via standard JAXB then dep to apache commons configuration will be not required
    final XMLConfiguration configuration = new XMLConfiguration();
    configuration.setDelimiterParsingDisabled(true);
    configuration.load(uri.toURL());
    for (final HierarchicalConfiguration channelCfg : configuration.configurationsAt("channel")) {
        final ChannelCfg channel = new ChannelCfg(channelCfg.getString("[@id]"), channelCfg.getString("[@label]"));

        for (final HierarchicalConfiguration connCfg : channelCfg.configurationsAt("connections.connection")) {
            final String id = connCfg.getString("[@id]");
            final FeedType type = FeedType.valueOf(connCfg.getString("type[@feed-type]"));
            final TransportProtocol protocol = TransportProtocol.valueOf(connCfg.getString("protocol").substring(0, 3));
            final Feed feed = Feed.valueOf(connCfg.getString("feed"));
            final String ip = connCfg.getString("ip");
            final int port = connCfg.getInt("port");
            final List<String> hostIPs = Arrays.asList(connCfg.getStringArray("host-ip"));

            final ConnectionCfg connection = new ConnectionCfg(feed, id, type, protocol, ip, hostIPs, port);
            channel.addConnection(connection);
            connCfgs.put(connection.getId(), connection);
        }
        channelCfgs.put(channel.getId(), channel);
    }
}
 
開發者ID:epam,項目名稱:java-cme-mdp3-handler,代碼行數:32,代碼來源:Configuration.java

示例5: testBalancerStorageSequentialSingle

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
@Test
public void testBalancerStorageSequentialSingle() throws Exception {

    SequentialHostBalancer balancer = new SequentialHostBalancer();

    String balancerConfig = "<essvcenter><balancer hosts=\"elm1\" /></essvcenter>";
    XMLConfiguration xmlConfiguration = new XMLHostConfiguration();
    xmlConfiguration.load(new StringReader(balancerConfig));
    balancer.setConfiguration(xmlConfiguration.configurationAt("balancer"));

    VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();

    VMwareHost elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
            .createHostSystemProperties("elm1", "128", "1")));
    elm.setEnabled(true);

    balancer.setInventory(inventory);

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm1", elm.getName());

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm1", elm.getName());
}
 
開發者ID:servicecatalog,項目名稱:development,代碼行數:27,代碼來源:SequentialHostBalancerTest.java

示例6: loadRegexAlerts

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
public static Map<String, JSONObject> loadRegexAlerts(String config_path)
		throws ConfigurationException, ParseException {
	XMLConfiguration alert_rules = new XMLConfiguration();
	alert_rules.setDelimiterParsingDisabled(true);
	alert_rules.load(config_path);

	//int number_of_rules = alert_rules.getList("rule.pattern").size();

	String[] patterns = alert_rules.getStringArray("rule.pattern");
	String[] alerts = alert_rules.getStringArray("rule.alert");

	JSONParser pr = new JSONParser();
	Map<String, JSONObject> rules = new HashMap<String, JSONObject>();

	for (int i = 0; i < patterns.length; i++)
		rules.put(patterns[i], (JSONObject) pr.parse(alerts[i]));

	return rules;
}
 
開發者ID:apache,項目名稱:metron,代碼行數:20,代碼來源:SettingsLoader.java

示例7: initialize

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
private static boolean initialize(String configFile) {
   // read parameters from configuration file
   try {
      config = new XMLConfiguration();
      type2key = new HashMap<String, String>();
      Exception ex = new Exception();
      StackTraceElement[] sTrace = ex.getStackTrace();
      String className = sTrace[0].getClassName();
      Class c = Class.forName(className);
      URL fileurl = ResourceLocator.getURL(configFile, defaultConfigFile, c);
      config.load(fileurl);
      // create index to map idType to key
      int types = config.getMaxIndex("type") + 1;
      String typekey, idType;
      for (int i = 0; i < types; i++) {
         typekey = "type(" + i + ").";
         idType = config.getString(typekey + "idType");
         type2key.put(idType.toLowerCase(), typekey);
      }
   } catch (ConfigurationException ce) {
      return false;
   } catch (ClassNotFoundException cnfe) {
      return false;
   }
   return true;
}
 
開發者ID:Fosstrak,項目名稱:fosstrak-hal,代碼行數:27,代碼來源:IDType.java

示例8: loadXml

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
/**
 * Method to read an input stream into a XMLConfiguration.
 * @param xmlStream inputstream containing XML description
 * @return the XMLConfiguration object
 */
public XMLConfiguration loadXml(InputStream xmlStream) {
    XMLConfiguration cfg = new XMLConfiguration();
    try {
        cfg.load(xmlStream);
        return cfg;
    } catch (ConfigurationException e) {
        throw new IllegalArgumentException("Cannot load xml from Stream", e);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:YangXmlUtils.java

示例9: loadXml

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
public static HierarchicalConfiguration loadXml(InputStream xmlStream) {
    XMLConfiguration cfg = new XMLConfiguration();
    try {
        cfg.load(xmlStream);
        return cfg;
    } catch (ConfigurationException e) {
        throw new IllegalArgumentException("Cannot load xml from Stream", e);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:XmlConfigParser.java

示例10: loadDrivers

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
/**
 * Loads the specified drivers resource as an XML stream and parses it to
 * produce a ready-to-register driver provider.
 *
 * @param driversStream stream containing the drivers definitions
 * @param resolver      driver resolver
 * @return driver provider
 * @throws java.io.IOException if issues are encountered reading the stream
 *                             or parsing the driver definitions within
 */
public DefaultDriverProvider loadDrivers(InputStream driversStream,
                                         DriverResolver resolver) throws IOException {
    try {
        XMLConfiguration cfg = new XMLConfiguration();
        cfg.setRootElementName(DRIVERS);
        cfg.setAttributeSplittingDisabled(true);

        cfg.load(driversStream);
        return loadDrivers(cfg, resolver);
    } catch (ConfigurationException e) {
        throw new IOException("Unable to load drivers", e);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:XmlDriverLoader.java

示例11: getApplicationDescription

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
/**
 * Loads the application descriptor from the specified application archive
 * stream and saves the stream in the appropriate application archive
 * directory.
 *
 * @param appName application name
 * @return application descriptor
 * @throws org.onosproject.app.ApplicationException if unable to read application description
 */
public ApplicationDescription getApplicationDescription(String appName) {
    try {
        XMLConfiguration cfg = new XMLConfiguration();
        cfg.setAttributeSplittingDisabled(true);
        cfg.setDelimiterParsingDisabled(true);
        cfg.load(appFile(appName, APP_XML));
        return loadAppDescription(cfg);
    } catch (Exception e) {
        throw new ApplicationException("Unable to get app description", e);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:21,代碼來源:ApplicationArchive.java

示例12: parsePlainAppDescription

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
private ApplicationDescription parsePlainAppDescription(InputStream stream)
        throws IOException {
    XMLConfiguration cfg = new XMLConfiguration();
    cfg.setAttributeSplittingDisabled(true);
    cfg.setDelimiterParsingDisabled(true);
    try {
        cfg.load(stream);
        return loadAppDescription(cfg);
    } catch (ConfigurationException e) {
        throw new IOException("Unable to parse " + APP_XML, e);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:13,代碼來源:ApplicationArchive.java

示例13: reloadConfigurationInner

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
@Override
protected void reloadConfigurationInner() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        log.debug("loading config:" + getConfigName());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;

            if (node.getName().equals(KEY_DISPATCHER_IP_ADDRESS)) {
                List<String> values = new ArrayList<String>();

                for (Object value : node.getChildren()) {
                    values.add((String) ((Node) value).getValue());
                }
                setDispatcherIpAddress(values);
            } else {
                log.info("unknown node:" + node.getName());
            }

        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }

}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:31,代碼來源:NmsCoreCommonConfiguration.java

示例14: reloadConfigurationInner

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
@Override
protected synchronized void reloadConfigurationInner() throws IOException {
    try {
        config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());
        this.inventoryRmiServicePort = config.getInt(INVENTORY_RMI_SERVICE_PORT);
        log().info("reload finished.");
    } catch (ConfigurationException e) {
        log().error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + FILE_NAME);
    }
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:14,代碼來源:MplsNmsConfiguration.java

示例15: JBrickConfigManager

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
private JBrickConfigManager(String pStrConfigurationFilePath) {
       mXMLConfiguration = new XMLConfiguration();
       mXMLConfiguration.setFileName(pStrConfigurationFilePath);
       mXMLConfiguration.setExpressionEngine(new XPathExpressionEngine());
	try {
		mXMLConfiguration.load();
	} catch (ConfigurationException e) {
		mLog.error(e,"Error while reading configuration from file ",this.getStrConfigFileName());
		throw new JBrickException(e, "jBrickException.configManager.errorWhileReadingConfiguration", e.getMessage());
	}
	mLog.debug("ConfigManager initialized using file ", pStrConfigurationFilePath);
}
 
開發者ID:MakeITBologna,項目名稱:zefiro,代碼行數:13,代碼來源:JBrickConfigManager.java


注:本文中的org.apache.commons.configuration.XMLConfiguration.load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。