本文整理汇总了Java中org.rhq.core.domain.configuration.definition.ConfigurationDefinition类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationDefinition类的具体用法?Java ConfigurationDefinition怎么用?Java ConfigurationDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationDefinition类属于org.rhq.core.domain.configuration.definition包,在下文中一共展示了ConfigurationDefinition类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadResourceConfiguration
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
@Override
public Configuration loadResourceConfiguration() {
Configuration configuration = new Configuration();
ConfigurationDefinition configurationDefinition = this.getResourceContext().getResourceType()
.getResourceConfigurationDefinition();
for (PropertyDefinition property : configurationDefinition.getPropertyDefinitions().values()) {
if (property instanceof PropertyDefinitionSimple) {
EmsAttribute attribute = getEmsBean().getAttribute(property.getName());
if (attribute != null) {
configuration.put(new PropertySimple(property.getName(), attribute.refresh()));
}
}
}
return configuration;
}
示例2: loadResourceConfiguration
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
public Configuration loadResourceConfiguration() throws Exception {
Configuration configuration = new Configuration();
ConfigurationDefinition configurationDefinition = component.getResourceContext().getResourceType().getResourceConfigurationDefinition();
Set<String> attributeNames = new HashSet<String>();
for (PropertyDefinition property : configurationDefinition.getPropertyDefinitions().values()) {
if (property instanceof PropertyDefinitionSimple) {
attributeNames.add(property.getName());
}
}
AttributeList attributes;
try {
attributes = mbean.getAttributes(attributeNames.toArray(new String[attributeNames.size()]));
} catch (InstanceNotFoundException ex) {
// In some cases, the MBean is created lazily; we then simply ignore the InstanceNotFoundException
// and don't load any configuration
if (ignoreMissingMBean) {
// TODO: not sure if this is the right way; maybe RHQ will save a new configuration if we do this...
return null;
} else {
throw ex;
}
}
for (int i=0; i<attributes.size(); i++) {
Attribute attribute = (Attribute)attributes.get(i);
configuration.put(new PropertySimple(attribute.getName(), attribute.getValue()));
}
return configuration;
}
示例3: updateResourceConfiguration
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
ConfigurationDefinition configurationDefinition = component.getResourceContext().getResourceType().getResourceConfigurationDefinition();
AttributeList attributes = new AttributeList();
for (PropertySimple property : report.getConfiguration().getSimpleProperties().values()) {
PropertyDefinitionSimple definition = configurationDefinition.getPropertyDefinitionSimple(property.getName());
if (!definition.isReadOnly()) {
Object value;
switch (definition.getType()) {
case INTEGER:
value = Integer.valueOf(property.getIntegerValue());
break;
case LONG:
value = Long.valueOf(property.getLongValue());
break;
case BOOLEAN:
value = Boolean.valueOf(property.getBooleanValue());
break;
case FLOAT:
value = Float.valueOf(property.getFloatValue());
break;
case DOUBLE:
value = Double.valueOf(property.getDoubleValue());
break;
default:
value = property.getStringValue();
break;
}
attributes.add(new Attribute(property.getName(), value));
}
}
try {
mbean.setAttributes(attributes);
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
} catch (Exception ex) {
report.setErrorMessage(ThrowableUtil.getStackAsString(ex));
report.setStatus(ConfigurationUpdateStatus.FAILURE);
}
}
示例4: setConfiguration
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
@Override
protected void setConfiguration(Configuration configuration, ResourceType resourceType) {
if (resourceType.getName().equals(name)) {
ConfigurationDefinition def = resourceType.getPluginConfigurationDefinition();
Configuration conf = def.getDefaultTemplate().getConfiguration();
conf.getSimple(VerdadComponent.EXECUTABLE).setStringValue(vdFile.toString());
log.debug("" + conf.getAllProperties());
}
}
示例5: setConfiguration
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
@Override
protected void setConfiguration(Configuration configuration, ResourceType resourceType) {
if (resourceType.getName().equals(name)) {
ConfigurationDefinition def = resourceType.getPluginConfigurationDefinition();
Configuration conf = def.getDefaultTemplate().getConfiguration();
conf.getSimple(VerdadComponent.EXECUTABLE).setStringValue("/usr/bin/false");
}
}
示例6: setConfiguration
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
@Override
protected void setConfiguration(Configuration configuration, ResourceType resourceType) {
if (resourceType.getName().equals(protocol)) {
ConfigurationDefinition configurationDefinition = resourceType.getPluginConfigurationDefinition();
configurationDefinition.getDefaultTemplate().getConfiguration().
getSimple("executable").setStringValue(dir + "/src/test/script/netstat");
}
}
示例7: setConfiguration
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
@Override
protected void setConfiguration(Configuration configuration, ResourceType resourceType) {
if (resourceType.getName().equals(PORT)) {
// configuration.setSimpleValue(PortDiscovery.ADDRESS, "localhost:" + ss.getPort());
ConfigurationDefinition configurationDefinition = resourceType.getPluginConfigurationDefinition();
configurationDefinition.getDefaultTemplate().getConfiguration().
getSimple(PortDiscovery.ADDRESS).
setStringValue("localhost:" + ss.getPort());
log.debug("" + configuration.getAllProperties());
}
}
示例8: loadPluginConfigDefFor
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
/**
* This method does a few things. It first searches the descriptor with the specified
* <code>path</code>. When a matching element is found, which is presumably either a
* {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
* {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its plugin
* configuration is retrieved. It then gets parsed and the resulting
* {@link ConfigurationDefinition} is returned.
*
* @param descriptor The plugin descriptor
* @param path The XPath-ish expression that specifies the path to the element from which
* the plugin configuration should be loaded
* @param configName A name to give the configuration definition
* @return The parsed {@link ConfigurationDefinition}
*/
public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor descriptor, String path,
String configName) {
try {
ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getPluginConfiguration());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例9: loadResourceConfigDefFor
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; //导入依赖的package包/类
/**
* This method does a few things. It first searches the descriptor with the specified
* <code>path</code>. When a matching element is found, which is presumably either a
* {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
* {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its resource
* configuration is retrieved. It then gets parsed and the resulting
* {@link ConfigurationDefinition} is returned.
*
* @param descriptor The plugin descriptor
* @param path The XPath-ish expression that specifies the path to the element from which
* the resource configuration should be loaded
* @param configName A name to give the configuration definition
* @return The parsed {@link ConfigurationDefinition}
*/
public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor descriptor, String path,
String configName) {
try {
ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getResourceConfiguration());
} catch (Exception e) {
throw new RuntimeException(e);
}
}