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


Java Configuration.put方法代码示例

本文整理汇总了Java中org.rhq.core.domain.configuration.Configuration.put方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.put方法的具体用法?Java Configuration.put怎么用?Java Configuration.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.rhq.core.domain.configuration.Configuration的用法示例。


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

示例1: loadResourceConfiguration

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的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;
}
 
开发者ID:rh-messaging,项目名称:Artemis-JON-plugin,代码行数:18,代码来源:ArtemisResourceComponent.java

示例2: loadResourceConfiguration

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
public Configuration loadResourceConfiguration() throws Exception {
    Configuration config = new Configuration();
    Map<String,Object> dsProps = getContext().getDataSourceProperties();
    config.put(new PropertySimple("primary", dsProps.get("serverName") + ":" + dsProps.get("portNumber")));
    String alternateServerName = (String)dsProps.get("clientRerouteAlternateServerName");
    if (alternateServerName != null && alternateServerName.length() > 0) {
        config.put(new PropertySimple("alternate", alternateServerName + ":" + dsProps.get("clientRerouteAlternatePortNumber")));
    } else {
        config.put(new PropertySimple("alternate", null));
    }
    config.put(new PropertySimple("databaseName", (String)dsProps.get("databaseName")));
    if (log.isDebugEnabled()) {
        log.debug("Loaded resource configuration: " + config.toString(true));
    }
    return config;
}
 
开发者ID:kszbcss,项目名称:rhq-websphere-plugin,代码行数:17,代码来源:DB2MonitorComponent.java

示例3: discover

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
private DiscoveredResourceDetails discover(ResourceDiscoveryContext context, ProcessScanResult p) throws SocketException, IOException {
    String[] cl = p.getProcessInfo().getCommandLine();
    InetSocketAddress ia = address(cl);
    log.info("connecting to " + ia);
    Socket socket = connect(ia);
    Stats stats = new Stats(socket);
    try {
        stats.info();
        log.info("discovered " + ia + " stats " + stats.info().size());
    } finally {
        stats.close();
    }
    String name = "memcached " + toString(ia);
    Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
    pluginConfiguration.put(new PropertySimple(MemcachedComponent.PORT, ia.getPort()));
    pluginConfiguration.put(new PropertySimple(MemcachedComponent.HOSTNAME, ia.getHostName()));
    DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
            context.getResourceType(),
            name, // database key
            name, // UI name
            null, // Version
            name,
            pluginConfiguration,
            null); // process info
    return detail;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:27,代码来源:MemcachedDiscovery.java

示例4: discover

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
private void discover(ResourceDiscoveryContext context, Set<DiscoveredResourceDetails> details, MongoClient client) {
    int port = client.getAddress().getPort();
    String host = client.getAddress().getHost();

    String rname = "mongodb server " + port;
    log.info("discovered mongodb " + rname);
    Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
    String uri = "mongodb://" + host + ":" + port;
    pluginConfiguration.put(new PropertySimple(MongoDBServerComponent.URI, uri));
    StatClient statClient = new StatClient(client);
    String ver = statClient.getString("version");
    DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
            context.getResourceType(),
            uri, // database key
            rname, // UI name
            ver,
            "MongoDB " + port,
            pluginConfiguration,
            null); // process info

    details.add(detail);
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:23,代码来源:MongoDBServerDiscovery.java

示例5: discover

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
private DiscoveredResourceDetails discover(ResourceDiscoveryContext context, DB db, String name) {
    DBCollection collection = db.getCollection(name);
    collection.getStats();

    String rname = "mongodb " + db.getName() + "." + name;
    log.debug("discovered mongodb collection " + rname);
    Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
    pluginConfiguration.put(new PropertySimple(MongoDBCollectionComponent.COLLECTION, name));
    String ver = null;
    DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
            context.getResourceType(),
            name, // database key
            rname, // UI name
            ver,
            "MongoDB Collection " + name,
            pluginConfiguration,
            null); // process info

    return detail;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:21,代码来源:MongoDBCollectionDiscovery.java

示例6: discover

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
private DiscoveredResourceDetails discover(ResourceDiscoveryContext context, MongoClient client, String name) {
    DB db = client.getDB(name);
    db.getStats();

    String rname = "mongodb " + name;
    log.debug("discovered " + rname);
    Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
    pluginConfiguration.put(new PropertySimple(MongoDBComponent.DB, name));
    String ver = null;
    DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
            context.getResourceType(),
            name,  // database key
            rname, // UI name
            ver,
            "MongoDB " + name,
            pluginConfiguration,
            null); // process info

    return detail;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:21,代码来源:MongoDBDiscovery.java

示例7: loadResourceConfiguration

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的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;
}
 
开发者ID:kszbcss,项目名称:rhq-websphere-plugin,代码行数:29,代码来源:ConfigurationFacetSupport.java

示例8: loadResourceConfiguration

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
@Override
public Configuration loadResourceConfiguration() throws Exception {
       Configuration config = new Configuration();
       String clusterName = server.getClusterName();
       config.put(new PropertySimple("clusterName", clusterName));
       config.put(new PropertySimple("clusterKey", clusterName == null ? null : server.getCell() + "/" + clusterName));
       return config;
   }
 
开发者ID:kszbcss,项目名称:rhq-websphere-plugin,代码行数:9,代码来源:WebSphereServerComponent.java

示例9: discoverResource

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
public final DiscoveredResourceDetails discoverResource(Configuration pluginConfig,
                                                        ResourceDiscoveryContext discoveryContext)
      throws InvalidPluginConfigurationException {

    final String resourceTypeName = discoveryContext.getResourceType().getName();

    // get the user provided Connector Address
    final String connectorAddress = pluginConfig.getSimpleValue(
          JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, null);
    if (connectorAddress == null) {
        throw new InvalidPluginConfigurationException(
              "A connector address must be specified when manually adding a " +
                    resourceTypeName);
    }

    // property for JMXServerComponent to use to connect to the process later
    // also needed by ConnectionProviderFactory.createConnectionProvider below
    pluginConfig.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
          J2SE5ConnectionTypeDescriptor.class.getName()));

    // check whether we can connect to the process
    ConnectionProvider connectionProvider;
    EmsConnection connection;
    try {
        connectionProvider = ConnectionProviderFactory.createConnectionProvider(pluginConfig, null,
              discoveryContext.getParentResourceContext().getTemporaryDirectory());
        connection = connectionProvider.connect();
        connection.loadSynchronous(false);
    } catch (Exception e) {
        if (e.getCause() instanceof SecurityException) {
            throw new InvalidPluginConfigurationException("Failed to authenticate to " +
                  resourceTypeName + " with connector address [" + connectorAddress +
                  "] - principal and/or credentials connection properties are not set correctly.");
        }
        throw new RuntimeException("Failed to connect to " + resourceTypeName +
              " with connector address [" + connectorAddress + "]", e);
    }

    // try to get the actual JVM Process from the EMS connection, returns null if native layer is not available
    final ProcessInfo jvmProcess = getJvmProcess(discoveryContext, connection, connectorAddress);

    // get home path, either from plugin config or discovered process
    final String homePath;
    final String homePropertyName = pluginConfig.getSimpleValue(HOME_PROPERTY);
    if (jvmProcess == null) {
        homePath = pluginConfig.getSimpleValue(homePropertyName);
    } else {
        homePath = getSystemPropertyValue(jvmProcess, homePropertyName);
    }
    if (homePath == null || homePath.isEmpty()) {
        throw new InvalidPluginConfigurationException("Missing required property " + homePropertyName);
    }

    // create resource details using the JVM process, which may be null if not found
    DiscoveredResourceDetails details = buildResourceDetails(pluginConfig,
          discoveryContext, jvmProcess, connectorAddress);

    // catastrophic failure in manual add if version file is missing
    if (details == null) {
        throw new InvalidPluginConfigurationException(
              String.format("Version file %s could not be found in %s",
                    pluginConfig.getSimpleValue(VERSION_FILE_PROPERTY), homePath));
    }

    // add a flag to indicate that this resource was manually added
    pluginConfig.put(new PropertySimple("manuallyAdded", true));

    // populate system properties in plugin properties
    if (!populateResourceProperties(discoveryContext, details)) {
        throw new InvalidPluginConfigurationException(
              "Error setting plugin properties, check agent log for details (you may have to enable debug first)");
    }

    // configure log file after resource properties are set
    initLogEventSourcesConfigProp(new File(homePath), pluginConfig, jvmProcess);

    return details;
}
 
开发者ID:rh-messaging,项目名称:Artemis-JON-plugin,代码行数:79,代码来源:ArtemisServerDiscoveryComponent.java

示例10: buildResourceDetails

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
protected DiscoveredResourceDetails buildResourceDetails(Configuration pluginConfig,
                                                         ResourceDiscoveryContext context, ProcessInfo process,
                                                         String connectorAddress) {
    // this also checks for the resourceKey property in the process if its not null
    final String resourceKey = buildResourceKey(pluginConfig, context, process);

    // find resource home directory
    final Configuration defaultConfig = context.getDefaultPluginConfiguration();
    final String homeProperty = defaultConfig.getSimpleValue(HOME_PROPERTY);

    // use provided home property value or find the matching system property
    final String homePath;
    if (process == null) {
        homePath = pluginConfig.getSimpleValue(homeProperty);
    } else {
        homePath = getSystemPropertyValue(process, homeProperty);
    }
    if (homePath == null || homePath.isEmpty()) {
        throw new InvalidPluginConfigurationException("Missing required property " + homeProperty);
    }
    final File homeDir = new File(homePath);
    if (!homeDir.exists()) {
        throw new InvalidPluginConfigurationException(
              String.format("Home directory %s does NOT exist", homePath));
    }

    // get resource name using resourceKey property
    final String name = String.format("%s %s", resourceKey, context.getResourceType().getName());

    // get resource version from versionFile property
    String version = getResourceVersion(defaultConfig, homeDir);
    // this method returns null if the version file can't be found
    if (version == null) {
        return null;
    }
    String description = context.getResourceType().getDescription() +
          ", monitored via " + (connectorAddress == null ? "Sun JVM Attach API" : "JMX Remoting");

    // property for JMXServerComponent to use to connect to the process later
    pluginConfig.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
          J2SE5ConnectionTypeDescriptor.class.getName()));

    return new DiscoveredResourceDetails(context.getResourceType(), resourceKey, name, version, description,
          pluginConfig, process);
}
 
开发者ID:rh-messaging,项目名称:Artemis-JON-plugin,代码行数:46,代码来源:ArtemisServerDiscoveryComponent.java

示例11: discoverResources

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
@Override
public Set<DiscoveredResourceDetails> discoverResources(
        ResourceDiscoveryContext context)
        throws InvalidPluginConfigurationException, Exception {

    Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
    List<ProcessScanResult> processes = context.getAutoDiscoveredProcesses();
    for (ProcessScanResult p : processes) {
        String[] cl = p.getProcessInfo().getCommandLine();
        int port = DEFAULT_PORT;
        for (int i = 1; i < cl.length; i++) { // 0 = command
            String arg = cl[i];
            if (!arg.startsWith("-")) {
                File f = new File(arg);
                if (!f.isAbsolute())
                    f = new File(p.getProcessInfo().getCurrentWorkingDirectory(), arg);
                port = port(f);
            }
            if (arg.equals("--port"))
                port = Integer.parseInt(cl[++i]);
        }
        // load conf file?
        log.debug("connecting to " + port);
        Properties props;
        Client2 client = new Client2("localhost", port);
        try {
            props = client.infoAll();
            log.info("discovered redis " + port + " props " + props.size());
        } catch (JedisException e) {
            log.warn("failed connection to " + port, e);
            continue;
        } finally {
            client.disconnect();
        }
        client.info();
        String name = "redis " + port;
        Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
        pluginConfiguration.put(new PropertySimple(RedisComponent.PORT, port));
        DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
                context.getResourceType(),
                name, // database key
                name, // UI name
                props.getProperty("redis_version"), // Version
                "Redis Server "+ port,
                pluginConfiguration,
                null); // process info

        details.add(detail);
    }
    return details;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:52,代码来源:RedisDiscovery.java

示例12: discoverResources

import org.rhq.core.domain.configuration.Configuration; //导入方法依赖的package包/类
/**
 * Discover table rows by querying the table name, which is either the resource name
 * or 'table' configuration value.
 */
@Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MibComponent> rdc) throws Exception {

    Set<DiscoveredResourceDetails> drd = new HashSet<DiscoveredResourceDetails>();
    Configuration conf = rdc.getDefaultPluginConfiguration();

    MibComponent mibComponent = rdc.getParentResourceComponent();
    String tableName = rdc.getResourceType().getName();
    tableName = conf.getSimpleValue(TABLE, tableName);

    log.debug("discover table " + tableName);
    MibIndex index = mibComponent.getIndex();
    TableRecord tableRecord = index.getTableRecord(tableName);
    OID oids[] = { tableRecord.getOids()[0] };
    List<TableEvent> events = mibComponent.getSnmpComponent().getTable(oids);

    for (TableEvent event : events) {
        conf = conf.deepCopy();
        log.debug("events " + event);
        if (event.getIndex() == null) {
            log.debug("empty index");
            continue;
        }
        log.debug("event index " + event.getIndex());
        String name = toString(tableRecord.index(event));
        log.debug("decode " + name);
        String version = null;

        String key = event.getIndex().toString();
        conf.put(new PropertySimple(INDEX, key));
        conf.put(new PropertySimple(TABLE, tableName));

        DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
                rdc.getResourceType(), // ResourceType
                key,    // key
                name, // help resource name
                version, // Version
                "SNMP table " + tableName + ", row index " + name, // description
                conf,
                null // process information
        );
        drd.add(detail);
    }

    return drd;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:51,代码来源:MibTableDiscovery.java


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