当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationException类代码示例

本文整理汇总了Java中org.apache.commons.configuration.ConfigurationException的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationException类的具体用法?Java ConfigurationException怎么用?Java ConfigurationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConfigurationException类属于org.apache.commons.configuration包,在下文中一共展示了ConfigurationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEntryForGraphNodeType

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
@Override
public KernelRepositoryEntry getEntryForGraphNodeType(GraphNodeType type)
		throws ConfigurationException {
	config.load(resource);
	
	List<ConfigurationNode> entryNodes = config.getRootNode().getChildren(ENTRY_NODE);
	for(ConfigurationNode node : entryNodes){
		List<ConfigurationNode> typeAttrList = node.getAttributes(ENTRY_NODE_TYPE_ATTRIBUTE);
		
		if(typeAttrList.size()>0){
			String val = (String) typeAttrList.get(0).getValue();
			
			if(type.equals(GraphNodeType.getType(val))){
				return getEntryFromConfigurationNode(node);
			}
		} else{
			throw new ConfigurationException("KH: no required '"+ENTRY_NODE_TYPE_ATTRIBUTE+"' attribute in "+ENTRY_NODE+" node");
		}
	}
	
	return null;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:23,代码来源:KernelRepository.java

示例2: getInstance

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
/**
 * gets instance
 * 
 * @return {@link AppConfiguration} instance
 */
public static RemoteRepositoryConfiguration getInstance() {
	if (_commonConfig == null) {
		try {
			_commonConfig = new RemoteRepositoryConfiguration();
			_commonConfig.reloadConfiguration();
			return _commonConfig;
		} catch (final ConfigurationException e) {
			LOG.severe("KH: " + e.getMessage());
			e.printStackTrace();
			return null;
		}
	} else {
		return _commonConfig;
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:21,代码来源:RemoteRepositoryConfiguration.java

示例3: loadProperties

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
private PropertiesConfiguration loadProperties() throws ConfigurationException {
    String deploymentProperties = "src/test/resources/deployment-fakeAdapterTest.properties";
    PropertiesConfiguration props = new PropertiesConfiguration(deploymentProperties);
    return props;
    // try {
    // Properties prop = null;
    // Resource res = appContext.getResource(deploymentProperties);
    // InputStream in = res.getInputStream();
    // if (in == null) {
    // LOG.warn("Failed to locate properties file on classpath: " + deploymentProperties);
    // } else {
    // LOG.info("Found '" + deploymentProperties + "' on the classpath");
    // prop = new Properties();
    // prop.load(in);
    // }
    // return prop;
    // } catch (IOException e) {
    // LOG.error("Failed to load properties file '" + deploymentProperties + "'", e);
    // throw new RuntimeException("Failed to initialise from properties file " +
    // deploymentProperties);
    // }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:23,代码来源:FakeAdapterTest.java

示例4: reloadConfigurationInner

import org.apache.commons.configuration.ConfigurationException; //导入依赖的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

示例5: loadExtraConfigration

import org.apache.commons.configuration.ConfigurationException; //导入依赖的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

示例6: createGraphNodeForEngine

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
private Node createGraphNodeForEngine(final EngineGraphNodeDecorator node)
		throws ConfigurationException {
	try {
		final Node configNode = createNodeForEngine(node);
		final Node sendToNode = createSendToSubNode(node.getGraphNode());
		final Node childrenNode = createChildrenSubNode(node.getGraphNode());
		final Node propertiesNode = createPropertiesSubNode(node
				.getGraphNode());
		final Node sourcesNode = createKernelsSubNode(node);
		configNode.addChild(childrenNode);
		configNode.addChild(sendToNode);
		configNode.addChild(propertiesNode);
		configNode.addChild(sourcesNode);
		return configNode;
	} catch (final NullPointerException e) {
		throw new ConfigurationException(e);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:19,代码来源:EngineGraphConfiguration.java

示例7: loadKernel

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
private IKernelString loadKernel(final ConfigurationNode node)
		throws ConfigurationException {
	String src;
	String srcId;

	final List<ConfigurationNode> idSourceAttrs = node
			.getAttributes(KERNEL_ID_ATTRIBUTE);
	if (idSourceAttrs.size() > 0) {
		srcId = (String) idSourceAttrs.get(0).getValue();
	} else {
		throw new ConfigurationException("KH: no required attribute '"
				+ KERNEL_ID_ATTRIBUTE + "' found in " + KERNEL + " node");
	}

	final List<ConfigurationNode> srcAttrs = node
			.getAttributes(KERNEL_SRC_ATTRIBUTE);
	if (srcAttrs.size() > 0) {
		src = (String) srcAttrs.get(0).getValue();
	} else {
		throw new ConfigurationException(
				"KH: no required attribute 'src' in " + KERNEL + " node");
	}

	final Map<String, Object> properties = loadKernelProperties(node);
	return new KernelString(srcId, src, properties);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:27,代码来源:EngineGraphConfiguration.java

示例8: loadExtraConfigration

import org.apache.commons.configuration.ConfigurationException; //导入依赖的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

示例9: testGetXmlConfigurationFromMap

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
/**
 * Tests getting a single object configuration via passing the path and the map of the desired values.
 *
 * @throws ConfigurationException if the testing xml file is not there.
 */
@Test
public void testGetXmlConfigurationFromMap() throws ConfigurationException {
    Map<String, String> pathAndValues = new HashMap<>();
    pathAndValues.put("capable-switch.id", "openvswitch");
    pathAndValues.put("switch.id", "ofc-bridge");
    pathAndValues.put("controller.id", "tcp:1.1.1.1:1");
    pathAndValues.put("controller.ip-address", "1.1.1.1");
    XMLConfiguration cfg = utils.getXmlConfiguration(OF_CONFIG_XML_PATH, pathAndValues);
    testCreateConfig.load(getClass().getResourceAsStream("/testCreateSingleYangConfig.xml"));
    assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig);

    assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                 IteratorUtils.toList(cfg.getKeys()));

    assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
                 utils.getString(cfg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:YangXmlUtilsTest.java

示例10: createGraphNodeForGUI

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
private Node createGraphNodeForGUI(GUIGraphNodeDecorator node, File file)
		throws ConfigurationException {
	try {
		Node configNode = createNodeForGUI(node);
		Node sendToNode = createSendToSubNode(node.getGraphNode());
		Node childrenNode = createChildrenSubNode(node.getGraphNode());
		Node propertiesNode = createPropertiesSubNode(node.getGraphNode());
		Node sourcesNode = createSourceFilesSubNode(node, file);
		configNode.addChild(childrenNode);
		configNode.addChild(sendToNode);
		configNode.addChild(propertiesNode);
		configNode.addChild(sourcesNode);
		return configNode;
	} catch (NullPointerException e) {
		throw new ConfigurationException(e);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:18,代码来源:GUIGraphConfiguration.java

示例11: getXmlConfigurationFromYangElements

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
/**
 * Tests getting a multiple object nested configuration via passing the path
 * and a list of YangElements containing with the element and desired value.
 *
 * @throws ConfigurationException
 */
@Test
public void getXmlConfigurationFromYangElements() throws ConfigurationException {

    assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig);
    testCreateConfig.load(getClass().getResourceAsStream("/testYangConfig.xml"));
    List<YangElement> elements = new ArrayList<>();
    elements.add(new YangElement("capable-switch", ImmutableMap.of("id", "openvswitch")));
    elements.add(new YangElement("switch", ImmutableMap.of("id", "ofc-bridge")));
    List<ControllerInfo> controllers =
            ImmutableList.of(new ControllerInfo(IpAddress.valueOf("1.1.1.1"), 1, "tcp"),
                             new ControllerInfo(IpAddress.valueOf("2.2.2.2"), 2, "tcp"));
    controllers.stream().forEach(cInfo -> {
        elements.add(new YangElement("controller", ImmutableMap.of("id", cInfo.target(),
                                                                   "ip-address", cInfo.ip().toString())));
    });
    XMLConfiguration cfg =
            new XMLConfiguration(YangXmlUtils.getInstance()
                                         .getXmlConfiguration(OF_CONFIG_XML_PATH, elements));
    assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                 IteratorUtils.toList(cfg.getKeys()));
    assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
                 utils.getString(cfg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:YangXmlUtilsTest.java

示例12: loadGraphNodeForGUI

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
private GUIGraphNodeDecorator loadGraphNodeForGUI(ConfigurationNode node)
		throws ConfigurationException {

	IGraphNode graphNode = loadGraphNode(node);
	int x = -1, y = -1;

	List<ConfigurationNode> xAttrList = node
			.getAttributes(NODE_X_ATTRIBUTE);
	List<ConfigurationNode> yAttrList = node
			.getAttributes(NODE_Y_ATTRIBUTE);
	if (xAttrList.size() > 0) {
		x = Integer.parseInt((String) xAttrList.get(0).getValue());
	}
	if (yAttrList.size() > 0) {
		y = Integer.parseInt((String) yAttrList.get(0).getValue());
	}

	GUIGraphNodeDecorator guiNode = new GUIGraphNodeDecorator(graphNode);
	guiNode.setX(x);
	guiNode.setY(y);

	return guiNode;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:24,代码来源:GUIGraphConfiguration.java

示例13: saveGraphForGUI

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
@Override
public void saveGraphForGUI(List<GUIGraphNodeDecorator> guiGraphNodes,
		File file) throws ConfigurationException {
	XMLConfiguration tempConfig = (XMLConfiguration) config.clone();
	try {
		config.clear();
		config.setRootNode(tempConfig.getRootNode());
		config.getRootNode().removeChildren();
		for (GUIGraphNodeDecorator guiNode : guiGraphNodes) {
			config.getRoot().addChild(createGraphNodeForGUI(guiNode, file));
		}
		config.save(file);
	} catch (ConfigurationException e) {
		config = tempConfig;
		config.save(file);
		throw e;
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:19,代码来源:GUIGraphConfiguration.java

示例14: createNode

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
protected Node createNode(final IGraphNode node)
		throws ConfigurationException {
	final Node configNode = new Node(NODE);
	final Node idAttr = new Node(NODE_ID_ATTRIBUTE, node.getNodeId());
	idAttr.setAttribute(true);
	final Node hashAttr = new Node(NODE_HASH_ATTRIBUTE, node.hashCode());
	hashAttr.setAttribute(true);
	final Node parentAttr = new Node(NODE_PARENT_ID_ATTRIBUTE,
			node.getParentNode() != null ? node.getParentNode().getNodeId()
					: "");
	parentAttr.setAttribute(true);
	final Node nameAttr = new Node(NODE_NAME_ATTRIBUTE, node.getName());
	nameAttr.setAttribute(true);
	final Node typeAttr = new Node(NODE_TYPE_ATTRIBUTE, node.getType()
			.toString());
	typeAttr.setAttribute(true);
	configNode.addAttribute(idAttr);
	configNode.addAttribute(parentAttr);
	configNode.addAttribute(hashAttr);
	configNode.addAttribute(nameAttr);
	configNode.addAttribute(typeAttr);
	return configNode;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:24,代码来源:AbstractGraphConfiguration.java

示例15: createPropertiesSubNode

import org.apache.commons.configuration.ConfigurationException; //导入依赖的package包/类
protected Node createPropertiesSubNode(final IGraphNode node)
		throws ConfigurationException {
	final Node propertiesNode = new Node(PROPERTIES_NODE);
	final Set<String> keySet = node.getProperties().keySet();
	for (final String key : keySet) {
		final Node propertyNode = new Node(PROPERTY_NODE);
		final Node keyAttr = new Node(PROPERTY_NODE_KEY_ATTRIBUTE, key);
		keyAttr.setAttribute(true);
		final Node valueAttr = new Node(PROPERTY_NODE_VALUE_ATTRIBUTE, node
				.getProperties().get(key));
		valueAttr.setAttribute(true);
		propertyNode.addAttribute(keyAttr);
		propertyNode.addAttribute(valueAttr);
		propertiesNode.addChild(propertyNode);
	}
	return propertiesNode;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:18,代码来源:AbstractGraphConfiguration.java


注:本文中的org.apache.commons.configuration.ConfigurationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。