Example usage for javax.management ObjectName ObjectName

List of usage examples for javax.management ObjectName ObjectName

Introduction

In this page you can find the example usage for javax.management ObjectName ObjectName.

Prototype

public ObjectName(String domain, String key, String value) throws MalformedObjectNameException 

Source Link

Document

Construct an object name with exactly one key property.

Usage

From source file:com.github.brandtg.switchboard.JdbcBasedLogIndex.java

@Override
public void start() throws Exception {
    Class.forName(driverClass);//w  w w . j  av a  2 s  .c  o  m
    LOG.info("Loaded driver {}", driverClass);

    // DBCP2 pool
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectionString, user, password);
    ObjectName poolName = new ObjectName(JdbcBasedLogIndex.class.getCanonicalName(),
            URLEncoder.encode(connectionString, ENCODING), "indexConnectionPool");
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
            poolName);
    ObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<PoolableConnection>(
            poolableConnectionFactory);
    poolableConnectionFactory.setPool(connectionPool);
    this.dataSource = new PoolingDataSource<PoolableConnection>(connectionPool);
    LOG.info("Opened connection pool to {} as {}", connectionString, user);

    createTable();
}

From source file:eu.peppol.persistence.jdbc.OxalisDataSourceFactoryDbcpImplTest.java

private PoolingDataSource createPoolingDataSource(ConnectionFactory driverConnectionFactory) {

    PoolableConnectionFactory poolableConnectionFactory = null;
    try {/* w ww. jav  a 2  s .c  o  m*/

        poolableConnectionFactory = new PoolableConnectionFactory(driverConnectionFactory,
                new ObjectName("no.difi.oxalis", "connectionPool", "TestPool"));

        GenericObjectPool<PoolableConnection> pool = new GenericObjectPool<PoolableConnection>(
                poolableConnectionFactory);
        poolableConnectionFactory.setPool(pool);
        poolableConnectionFactory.setValidationQuery("select 1");
        return new PoolingDataSource(pool);

    } catch (MalformedObjectNameException e) {
        throw new IllegalStateException("Unable to create poolable conneciton factory: " + e.getMessage(), e);
    }

}

From source file:com.alibaba.jstorm.utils.JStormUtils.java

/**
 * @return//from  w  w w.j  av  a2s  . c  o m
 * @@@ Todo
 */
public static Long getPhysicMemorySize() {
    Object object;
    try {
        object = ManagementFactory.getPlatformMBeanServer().getAttribute(
                new ObjectName("java.lang", "type", "OperatingSystem"), "TotalPhysicalMemorySize");
    } catch (Exception e) {
        LOG.warn("Failed to get system physical memory size,", e);
        return null;
    }

    Long ret = (Long) object;

    return ret;
}