本文整理匯總了Java中org.apache.commons.configuration.HierarchicalConfiguration.configurationsAt方法的典型用法代碼示例。如果您正苦於以下問題:Java HierarchicalConfiguration.configurationsAt方法的具體用法?Java HierarchicalConfiguration.configurationsAt怎麽用?Java HierarchicalConfiguration.configurationsAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.configuration.HierarchicalConfiguration
的用法示例。
在下文中一共展示了HierarchicalConfiguration.configurationsAt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseFujitsuT100Ports
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Parses a configuration and returns a set of ports for the fujitsu T100.
* @param cfg a hierarchical configuration
* @return a list of port descriptions
*/
private static List<PortDescription> parseFujitsuT100Ports(HierarchicalConfiguration cfg) {
AtomicInteger counter = new AtomicInteger(1);
List<PortDescription> portDescriptions = Lists.newArrayList();
List<HierarchicalConfiguration> subtrees =
cfg.configurationsAt("data.interfaces.interface");
for (HierarchicalConfiguration portConfig : subtrees) {
if (!portConfig.getString("name").contains("LCN") &&
!portConfig.getString("name").contains("LMP") &&
portConfig.getString("type").equals("ianaift:ethernetCsmacd")) {
portDescriptions.add(parseT100OduPort(portConfig, counter.getAndIncrement()));
} else if (portConfig.getString("type").equals("ianaift:otnOtu")) {
portDescriptions.add(parseT100OchPort(portConfig, counter.getAndIncrement()));
}
}
return portDescriptions;
}
示例2: getInterfacesFromConfig
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Parses device configuration and returns the descriptions of the device
* interfaces.
*
* @param cfg an hierarchical configuration
* @return list of interface descriptions for the device
*/
public static List<DeviceInterfaceDescription> getInterfacesFromConfig(
HierarchicalConfiguration cfg) {
List<DeviceInterfaceDescription> intfs = Lists.newArrayList();
List<HierarchicalConfiguration> subtrees =
cfg.configurationsAt("data.xml-config-data.Device-Configuration.interface");
for (HierarchicalConfiguration intfConfig :subtrees) {
String intfName = getInterfaceName(intfConfig);
DeviceInterfaceDescription.Mode intfMode = getInterfaceMode(intfConfig);
List<VlanId> intfVlans = getInterfaceVlans(intfConfig, intfMode);
short intfLimit = getInterfaceLimit(intfConfig);
boolean intfLimited = (intfLimit == NO_LIMIT ? false : true);
DeviceInterfaceDescription intf =
new DefaultDeviceInterfaceDescription(intfName,
intfMode,
intfVlans,
intfLimited,
intfLimit);
intfs.add(intf);
}
return intfs;
}
示例3: load
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的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);
}
}
示例4: parseStreamControllers
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
public static List<ControllerInfo> parseStreamControllers(HierarchicalConfiguration cfg) {
List<ControllerInfo> controllers = new ArrayList<>();
List<HierarchicalConfiguration> fields =
cfg.configurationsAt("data.capable-switch." +
"logical-switches." +
"switch.controllers.controller");
for (HierarchicalConfiguration sub : fields) {
controllers.add(new ControllerInfo(
IpAddress.valueOf(sub.getString("ip-address")),
Integer.parseInt(sub.getString("port")),
sub.getString("protocol")));
}
return controllers;
}
示例5: loadDrivers
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Loads a driver provider from the supplied hierarchical configuration.
*
* @param driversCfg hierarchical configuration containing the drivers definitions
* @param resolver driver resolver
* @return driver provider
*/
public DefaultDriverProvider loadDrivers(HierarchicalConfiguration driversCfg,
DriverResolver resolver) {
DefaultDriverProvider provider = new DefaultDriverProvider();
for (HierarchicalConfiguration cfg : driversCfg.configurationsAt(DRIVER)) {
DefaultDriver driver = loadDriver(cfg, resolver);
drivers.put(driver.name(), driver);
provider.addDriver(driver);
}
drivers.clear();
return provider;
}
示例6: parseBehaviours
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private Map<Class<? extends Behaviour>, Class<? extends Behaviour>>
parseBehaviours(HierarchicalConfiguration driverCfg) {
ImmutableMap.Builder<Class<? extends Behaviour>,
Class<? extends Behaviour>> behaviours = ImmutableMap.builder();
for (HierarchicalConfiguration b : driverCfg.configurationsAt(BEHAVIOUR)) {
behaviours.put(getClass(b.getString(API)), getClass(b.getString(IMPL)));
}
return behaviours.build();
}
示例7: parseProperties
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private Map<String, String> parseProperties(HierarchicalConfiguration driverCfg) {
ImmutableMap.Builder<String, String> properties = ImmutableMap.builder();
for (HierarchicalConfiguration b : driverCfg.configurationsAt(PROPERTY)) {
properties.put(b.getString(NAME), (String) b.getRootNode().getValue());
}
return properties.build();
}
示例8: loadDrivers
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Loads a driver provider from the supplied hierarchical configuration.
*
* @param driversCfg hierarchical configuration containing the drivers definitions
* @return driver provider
*/
public DefaultDriverProvider loadDrivers(HierarchicalConfiguration driversCfg) {
DefaultDriverProvider provider = new DefaultDriverProvider();
for (HierarchicalConfiguration cfg : driversCfg.configurationsAt(DRIVER)) {
provider.addDriver(loadDriver(cfg));
}
return provider;
}
示例9: SecurityConfig
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public SecurityConfig(@Nonnull HierarchicalConfiguration config) {
if (config != null) {
List<HierarchicalConfiguration> sizes = config.configurationsAt("groups/group");
for (HierarchicalConfiguration sizeConfig : sizes) {
String group = sizeConfig.getString("");
if (sizeConfig.getBoolean("@isDefault", false)) {
defaultGroups.add(group);
}
groups.add(group);
}
List<HierarchicalConfiguration> restrictionConfigs = config.configurationsAt("restrictions/restriction");
for (HierarchicalConfiguration restrictionConfig : restrictionConfigs) {
List<HierarchicalConfiguration> restrictionGroups = restrictionConfig.configurationsAt("groups/group");
String key = restrictionConfig.getString("@operation");
List<String> value = new ArrayList<String>();
for (HierarchicalConfiguration restrictionGroupConfig : restrictionGroups) {
value.add(restrictionGroupConfig.getString(""));
}
restrictionMap.put(key, value);
}
List<HierarchicalConfiguration> userConfigs = config.configurationsAt("users/user");
for (HierarchicalConfiguration userConfig : userConfigs) {
users.add(new DefaultUser(userConfig));
}
}
}
示例10: DefaultUser
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public DefaultUser(HierarchicalConfiguration config) {
this.name = config.getString("name");
this.email = config.getString("email");
this.password = config.getString("password");
this.admin = config.getBoolean("admin", false);
for (HierarchicalConfiguration c : (List<HierarchicalConfiguration>) config.configurationsAt("group")) {
groups.add(c.getString(""));
}
}
示例11: getChildConfigurationAt
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static HierarchicalConfiguration getChildConfigurationAt(HierarchicalConfiguration config, String key) {
if (config == null) {
return null;
}
List<HierarchicalConfiguration> configs = config.configurationsAt(key);
if (configs.size() > 1) {
LOG.warn("Child configuration with key " + key + " matches more than one node.");
} else if (configs.size() == 0) {
LOG.warn("Child configuration with key " + key + " has no entry in config file.");
}
return configs.size() != 0 ? configs.get(0) : null;
}
示例12: iterConfig
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private static ImmutableList<HierarchicalConfiguration> iterConfig(HierarchicalConfiguration c, String path) {
List<HierarchicalConfiguration> list = c.configurationsAt(path);
return list != null ? ListAdapter.adapt(list).toImmutable() : Lists.immutable.<HierarchicalConfiguration>empty();
}
示例13: parseWaveServerCienaPorts
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
public static List<HierarchicalConfiguration> parseWaveServerCienaPorts(HierarchicalConfiguration cfg) {
return cfg.configurationsAt("ws-ports.port-interface");
}
示例14: VmManagerConfig
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
*
* @param config
*/
@SuppressWarnings("unchecked")
public VmManagerConfig(@Nonnull HierarchicalConfiguration config) {
this.config = config;
if (this.config != null) {
List<HierarchicalConfiguration> creds = config.configurationsAt("credentials");
if (creds != null) {
for (HierarchicalConfiguration credentialsConfig : creds) {
CloudCredentials cloudCredentials = new CloudCredentials(credentialsConfig);
credentialsMap.put(cloudCredentials.getType(), cloudCredentials);
}
}
List<HierarchicalConfiguration> tags = config.configurationsAt("tags/tag");
if (tags != null) {
for (HierarchicalConfiguration tagsConfig : tags) {
InstanceTag tag = new InstanceTag(tagsConfig.getString("@name"), tagsConfig.getString(""));
if (tag.isValid()) {
tagList.add(tag);
}
}
}
HierarchicalConfiguration defaultInstance = config.configurationAt("default-instance-description");
List<HierarchicalConfiguration> regionConfigs = config.configurationsAt("instance-descriptions");
if (regionConfigs != null) {
for (HierarchicalConfiguration regionConfig : regionConfigs) {
VMRegion region = VMRegion.valueOf(regionConfig.getString("@region"));
Map<VMImageType, InstanceDescription> instanceMap = new HashMap<VMImageType, InstanceDescription>();
regionMap.put(region, instanceMap);
List<HierarchicalConfiguration> instanceConfigs = regionConfig
.configurationsAt("instance-descripion");
for (HierarchicalConfiguration instanceConfig : instanceConfigs) {
InstanceDescription description = new InstanceDescription(instanceConfig, defaultInstance);
instanceMap.put(description.getType(), description);
}
}
}
// get reserved elastic ips
List<HierarchicalConfiguration> eipConfig = config.configurationsAt("reserved-elastic-ips/eip");
if (eipConfig != null) {
for (HierarchicalConfiguration eip : eipConfig) {
reservedElasticIps.add(eip.getString(""));
}
}
// get instance type definitions
List<HierarchicalConfiguration> instanceTypesConfig = config.configurationsAt("instance-types/type");
instanceTypes = new ArrayList<VmInstanceType>();
if (instanceTypesConfig != null) {
for (HierarchicalConfiguration instanceTypeConfig : instanceTypesConfig) {
// example: <type name="c3.large" cost=".105" users="500" cpus="2" ecus="7" mem="3.75" />
VmInstanceType type = VmInstanceType.builder()
.withName(instanceTypeConfig.getString("@name"))
.withCost(instanceTypeConfig.getDouble("@cost", 0D))
.withMemory(instanceTypeConfig.getDouble("@mem", 0D))
.withJvmArgs(instanceTypeConfig.getString("@jvmArgs"))
.withEcus(instanceTypeConfig.getInt("@ecus", 0))
.withCpus(instanceTypeConfig.getInt("@cpus", 0))
.withDefault(instanceTypeConfig.getBoolean("@default", false))
.withUsers(instanceTypeConfig.getInt("@users", 0)).build();
instanceTypes.add(type);
}
}
}
}
示例15: registerFromDescriptor
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
public void registerFromDescriptor( URL url, ClassLoader cl )
throws NativesManagerException
{
try
{
XMLConfiguration config = new XMLConfiguration();
try ( InputStream reader = new BufferedInputStream( url.openStream() ) )
{
config.load( reader );
}
String basePath = config.getString( "base-path" );
if ( basePath == null )
{
basePath = EMPTY;
}
else if ( !basePath.isEmpty() )
{
basePath = ( stripEnd( basePath, "/" ) + "/" );
}
for ( HierarchicalConfiguration nativesConfig : config.configurationsAt( "natives" ) )
{
String osName = nativesConfig.getString( "os[@name]" );
for ( HierarchicalConfiguration archConfig : nativesConfig.configurationsAt( "arch" ) )
{
NativesInfo natives = new NativesInfo();
natives.osName = osName.toUpperCase();
natives.archName = getCanonicalArchitecture( archConfig.getString( "[@name]" ) ).toUpperCase();
natives.capnpPath = ( basePath + archConfig.getString( "capnp-exec-path" ) );
natives.capnpcJavaPath = ( basePath + archConfig.getString( "capnpc-java-exec-path" ) );
natives.capnpJavaSchemaPath = ( basePath + archConfig.getString( "capnp-java-schema-path" ) );
natives.capnpUrl = cl.getResource( natives.capnpPath );
natives.capnpcJavaUrl = cl.getResource( natives.capnpcJavaPath );
natives.capnpJavaSchemaUrl = cl.getResource( natives.capnpJavaSchemaPath );
nativesTable.put( natives.osName, natives.archName, natives );
}
}
}
catch ( Exception e )
{
throw new NativesManagerException( e );
}
}