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


Java ConnectionProvider类代码示例

本文整理汇总了Java中org.mc4j.ems.connection.support.ConnectionProvider的典型用法代码示例。如果您正苦于以下问题:Java ConnectionProvider类的具体用法?Java ConnectionProvider怎么用?Java ConnectionProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectionProvider类属于org.mc4j.ems.connection.support包,在下文中一共展示了ConnectionProvider类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEmsConnection

import org.mc4j.ems.connection.support.ConnectionProvider; //导入依赖的package包/类
@Override
public synchronized EmsConnection getEmsConnection() {
       if (connection == null) {
           Configuration pluginConfig = getResourceContext().getPluginConfiguration();
           ConnectionSettings connectionSettings = new ConnectionSettings();
           connectionSettings.setServerUrl(pluginConfig.getSimpleValue("host", null) + ":" + pluginConfig.getSimpleValue("port", null));
           ConnectionProvider connectionProvider = new WebsphereConnectionProvider(server.getAdminClient());
           // The connection settings are not required to establish the connection, but they
           // will still be used in logging:
           connectionProvider.initialize(connectionSettings);
           connection = connectionProvider.connect();
           
           // If this is not present, then EmbeddedJMXServerDiscoveryComponent will fail to
           // discover the platform MXBeans.
           connection.loadSynchronous(false);
       }
       return connection;
   }
 
开发者ID:kszbcss,项目名称:rhq-websphere-plugin,代码行数:19,代码来源:WebSphereServerComponent.java

示例2: setUp

import org.mc4j.ems.connection.support.ConnectionProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
   super.setUp();
   leakCheckRule.disable();

   jmxServiceURL = "service:jmx:rmi://localhost/jndi/rmi://localhost:" + jmxPort + "/jmxrmi";
   server = createServer(true, true);
   Configuration serverConfig = server.getConfiguration();
   serverConfig.setJMXManagementEnabled(true);
   serverConfig.setName(brokerName);
   String dataDir = this.temporaryFolder.getRoot().getAbsolutePath();
   serverConfig.setPagingDirectory(dataDir + "/" + serverConfig.getPagingDirectory());
   serverConfig.setBindingsDirectory(dataDir + "/" + serverConfig.getBindingsDirectory());
   serverConfig.setLargeMessagesDirectory(dataDir + "/" + serverConfig.getLargeMessagesDirectory());
   serverConfig.setJournalDirectory(dataDir + "/" + serverConfig.getJournalDirectory());

   mbeanServer = MBeanServerFactory.createMBeanServer();
   server.setMBeanServer(mbeanServer);
   server.start();
   factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
   objectNameBuilder = server.getManagementService().getObjectNameBuilder();
   connectJmx();
   System.out.println("server name: " + server.getConfiguration().getName());

   emsFactory = new ConnectionFactory();
   ConnectionSettings emsConnectionSettings = new ConnectionSettings();
   JSR160ConnectionTypeDescriptor descriptor = new JSR160ConnectionTypeDescriptor();
   emsConnectionSettings.initializeConnectionType(descriptor);
   emsConnectionSettings.setServerUrl(jmxServiceURL);

   ConnectionProvider provider = emsFactory.getConnectionProvider(emsConnectionSettings);
   emsConnection = provider.connect();
   emsConnection.loadSynchronous(true);
}
 
开发者ID:rh-messaging,项目名称:Artemis-JON-plugin,代码行数:35,代码来源:AmqJonRuntimeTestBase.java

示例3: discoverResource

import org.mc4j.ems.connection.support.ConnectionProvider; //导入依赖的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


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