Author: richard.opalka(a)jboss.com
Date: 2011-02-22 06:56:06 -0500 (Tue, 22 Feb 2011)
New Revision: 13782
Modified:
common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
Log:
[JBWS-3221] initial fix - more refactorings comming soon
Modified: common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2011-02-22
11:54:56 UTC (rev 13781)
+++ common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2011-02-22
11:56:06 UTC (rev 13782)
@@ -22,6 +22,7 @@
package org.jboss.wsf.test;
import java.io.File;
+import java.io.IOException;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MalformedURLException;
@@ -31,6 +32,8 @@
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.xml.namespace.QName;
@@ -219,20 +222,44 @@
{
if (server == null)
{
- Hashtable jndiEnv = null;
- try
- {
- InitialContext iniCtx = new InitialContext();
- jndiEnv = iniCtx.getEnvironment();
- server =
(MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
- }
- catch (NamingException ex)
- {
- throw new RuntimeException("Cannot obtain MBeanServerConnection using
jndi props: " + jndiEnv, ex);
- }
+ if (getIntegrationTarget().startsWith("jboss7"))
+ {
+ server = getAS7ServerConnection();
+ }
+ else
+ {
+ server = getAS6ServerConnection();
+ }
}
return server;
}
+
+ private static MBeanServerConnection getAS7ServerConnection()
+ {
+ String host = getServerHost();
+ String urlString = System.getProperty("jmx.service.url",
"service:jmx:rmi:///jndi/rmi://" + host + ":" + 1090 +
"/jmxrmi");
+ try {
+ JMXServiceURL serviceURL = new JMXServiceURL(urlString);
+ return JMXConnectorFactory.connect(serviceURL,
null).getMBeanServerConnection();
+ } catch (IOException ex) {
+ throw new IllegalStateException("Cannot obtain MBeanServerConnection to:
" + urlString, ex);
+ }
+ }
+
+ private static MBeanServerConnection getAS6ServerConnection()
+ {
+ Hashtable jndiEnv = null;
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+ jndiEnv = iniCtx.getEnvironment();
+ return
(MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ }
+ catch (NamingException ex)
+ {
+ throw new RuntimeException("Cannot obtain MBeanServerConnection using jndi
props: " + jndiEnv, ex);
+ }
+ }
public static String getIntegrationTarget()
{
Show replies by date