本文整理匯總了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;
}
示例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;
}
}
示例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);
// }
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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));
}
示例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);
}
}
示例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));
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}