本文整理汇总了Java中org.mc4j.ems.connection.settings.ConnectionSettings类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionSettings类的具体用法?Java ConnectionSettings怎么用?Java ConnectionSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionSettings类属于org.mc4j.ems.connection.settings包,在下文中一共展示了ConnectionSettings类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEmsConnection
import org.mc4j.ems.connection.settings.ConnectionSettings; //导入依赖的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;
}
示例2: setUp
import org.mc4j.ems.connection.settings.ConnectionSettings; //导入依赖的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);
}
示例3: internalStart
import org.mc4j.ems.connection.settings.ConnectionSettings; //导入依赖的package包/类
protected void internalStart() throws Exception {
Configuration pluginConfig = context.getPluginConfiguration();
String connectionTypeDescriptorClassName = pluginConfig.getSimple(JMXDiscoveryComponent.CONNECTION_TYPE)
.getStringValue();
if (JMXDiscoveryComponent.PARENT_TYPE.equals(connectionTypeDescriptorClassName)) {
// Our parent is itself a JMX component, so just reuse its connection.
this.connection = ((JMXComponent) context.getParentResourceComponent()).getEmsConnection();
this.connectionProvider = this.connection.getConnectionProvider();
} else {
final File tempDir = this.context.getTemporaryDirectory();
try {
this.connectionProvider = ConnectionProviderFactory.createConnectionProvider(pluginConfig,
this.context.getNativeProcess(), tempDir);
} catch (RuntimeException e) {
// check if Attach API failed, since this resource may have been discovered using jvmstat API
// avoid loading AttachNotSupportedException class, since its optional
if (e.getCause() != null &&
e.getCause().getClass().getName().equals(
ArtemisServerDiscoveryComponent.ATTACH_NOT_SUPPORTED_EXCEPTION_CLASS_NAME)) {
// create a connection provider using JvmStatUtility
final Class<?> connectionTypeDescriptorClass;
connectionTypeDescriptorClass = Class.forName(connectionTypeDescriptorClassName);
ConnectionTypeDescriptor connectionType =
(ConnectionTypeDescriptor) connectionTypeDescriptorClass.newInstance();
// create connection provider settings
ConnectionSettings settings = new ConnectionSettings();
if (!(connectionType instanceof J2SE5ConnectionTypeDescriptor)) {
throw new Exception("Unsupported connection type descriptor " + connectionTypeDescriptorClass);
}
settings.setConnectionType(connectionType);
// get service URL using jvmstat
final JMXServiceURL jmxServiceURL = JvmStatUtility.extractJMXServiceURL(context.getNativeProcess());
if (jmxServiceURL == null) {
throw new Exception("Failed to get JMX service URL using jvmstat");
}
settings.setServerUrl(jmxServiceURL.toString());
settings.getControlProperties().setProperty(
ConnectionFactory.COPY_JARS_TO_TEMP, String.valueOf(Boolean.TRUE));
settings.getControlProperties().setProperty(
ConnectionFactory.JAR_TEMP_DIR, tempDir.getAbsolutePath());
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.discoverServerClasses(settings);
connectionProvider = connectionFactory.getConnectionProvider(settings);
} else {
// re-throw
throw e;
}
}
this.connection = this.connectionProvider.connect();
this.connection.loadSynchronous(false);
}
}