Author: thomas.diesler(a)jboss.com
Date: 2010-04-07 16:18:21 -0400 (Wed, 07 Apr 2010)
New Revision: 103658
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXServiceURLFactory.java
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
projects/jboss-osgi/projects/spi/trunk/pom.xml
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Externalize JMXServiceURL creation to JMXServiceURLFactory
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXServiceURLFactory.java
===================================================================
---
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXServiceURLFactory.java
(rev 0)
+++
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXServiceURLFactory.java 2010-04-07
20:18:21 UTC (rev 103658)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.osgi.jmx;
+
+//$Id: JMXConnectorService.java 103656 2010-04-07 20:02:31Z thomas.diesler(a)jboss.com $
+
+import java.net.MalformedURLException;
+
+import javax.management.remote.JMXServiceURL;
+
+/**
+ * A factory for the JMXServiceURL
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 07-Apr-2010
+ */
+public abstract class JMXServiceURLFactory
+{
+ public static JMXServiceURL getServiceURL(String host, int conPort, int regPort)
+ {
+ String jmxConnectorURL = "service:jmx:rmi://" + host + ":" +
conPort + "/jndi/rmi://" + host + ":" + regPort +
"/osgi-jmx-connector";
+ try
+ {
+ return new JMXServiceURL(jmxConnectorURL);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Invalid connector URL: " +
jmxConnectorURL);
+ }
+ }
+}
\ No newline at end of file
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
---
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-04-07
20:06:49 UTC (rev 103657)
+++
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-04-07
20:18:21 UTC (rev 103658)
@@ -26,7 +26,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.net.InetAddress;
-import java.net.MalformedURLException;
import java.rmi.Remote;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
@@ -81,19 +80,6 @@
}
}
- static JMXServiceURL getServiceURL(String host, int conPort, int regPort)
- {
- String jmxConnectorURL = "service:jmx:rmi://" + host + ":" +
conPort + "/jndi/rmi://" + host + ":" + regPort +
"/osgi-jmx-connector";
- try
- {
- return new JMXServiceURL(jmxConnectorURL);
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Invalid connector URL: " +
jmxConnectorURL);
- }
- }
-
public void start(MBeanServer mbeanServer) throws IOException
{
// create new connector server and start it
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
===================================================================
---
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-04-07
20:06:49 UTC (rev 103657)
+++
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-04-07
20:18:21 UTC (rev 103658)
@@ -44,6 +44,7 @@
import javax.naming.StringRefAddr;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jmx.JMXServiceURLFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -154,7 +155,7 @@
int conPort = Integer.parseInt(jmxRmiPort);
int regPort = Integer.parseInt(rmiRegistryPort);
- JMXServiceURL serviceURL = JMXConnectorService.getServiceURL(jmxHost, conPort,
regPort);
+ JMXServiceURL serviceURL = JMXServiceURLFactory.getServiceURL(jmxHost, conPort,
regPort);
try
{
jmxConnector = new JMXConnectorService(serviceURL, regPort);
Modified: projects/jboss-osgi/projects/spi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/pom.xml 2010-04-07 20:06:49 UTC (rev 103657)
+++ projects/jboss-osgi/projects/spi/trunk/pom.xml 2010-04-07 20:18:21 UTC (rev 103658)
@@ -32,7 +32,7 @@
<!-- Properties -->
<properties>
<version.args4j>2.0.12</version.args4j>
- <version.jboss.osgi.jmx>1.0.4</version.jboss.osgi.jmx>
+ <version.jboss.osgi.jmx>1.0.5-SNAPSHOT</version.jboss.osgi.jmx>
<version.jboss.osgi.vfs>1.0.0</version.jboss.osgi.vfs>
<version.jboss.shrinkwrap>1.0.0-alpha-7</version.jboss.shrinkwrap>
<version.osgi>4.2.0</version.osgi>
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-04-07
20:06:49 UTC (rev 103657)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-04-07
20:18:21 UTC (rev 103658)
@@ -30,7 +30,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.management.MBeanServerConnection;
@@ -38,13 +37,10 @@
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jmx.JMXConstantsExt;
import org.jboss.osgi.jmx.MBeanProxy;
import org.jboss.osgi.jmx.ObjectNameFactory;
import org.jboss.osgi.jmx.ServiceStateMBeanExt;
@@ -231,57 +227,12 @@
}
catch (NamingException ex)
{
- log.debug("Cannot obtain MBeanServerConnection through the
RMIAdaptor", ex);
+ throw new IllegalStateException("Cannot obtain
MBeanServerConnection");
}
}
-
- // Fall back to the JMXConnector
- if (mbeanServer == null)
- {
- jmxConnector = getJMXConnector();
- if (jmxConnector != null)
- {
- try
- {
- mbeanServer = jmxConnector.getMBeanServerConnection();
- }
- catch (IOException ex)
- {
- log.debug("Cannot obtain MBeanServerConnection through
JMXConnector", ex);
- }
- }
- }
-
- if (mbeanServer == null)
- throw new IllegalStateException("Cannot obtain
MBeanServerConnection");
-
return mbeanServer;
}
- private JMXConnector getJMXConnector()
- {
- JMXConnector connector = null;
- try
- {
- String host = getServerHost();
- String rmiPort = System.getProperty(JMXConstantsExt.REMOTE_JMX_RMI_PORT,
"1098");
-
- // Construct the JSR160 remote address
- JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://" + host
+ "/jndi/rmi://" + host + ":" + rmiPort + "/jmxconnector");
-
- // The environment map, null in this case
- Map<String, ?> env = null;
-
- // Create the JMXCconnectorServer
- connector = JMXConnectorFactory.connect(address, env);
- }
- catch (Exception ex)
- {
- log.debug("Cannot obtain JMXConnector", ex);
- }
- return connector;
- }
-
@Override
public void shutdown()
{
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2010-04-07 20:06:49 UTC (rev 103657)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2010-04-07 20:18:21 UTC (rev 103658)
@@ -444,15 +444,6 @@
<properties>
<target.container.excludes>org/jboss/test/osgi/nothing-to-exclude</target.container.excludes>
</properties>
- <dependencies>
- <dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jmx-invoker-adaptor-client</artifactId>
- <version>${version.jmx.invoker.adaptor.client}</version>
- <scope>test</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
</profile>
<!--
@@ -470,15 +461,6 @@
<properties>
<target.container.excludes>org/jboss/test/osgi/nothing-to-exclude</target.container.excludes>
</properties>
- <dependencies>
- <dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jmx-invoker-adaptor-client</artifactId>
- <version>${version.jmx.invoker.adaptor.client}</version>
- <scope>test</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
</profile>
<!--
@@ -496,21 +478,6 @@
<properties>
<target.container.excludes>org/jboss/test/osgi/nothing-to-exclude</target.container.excludes>
</properties>
- <dependencies>
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-client</artifactId>
- <version>6.0.0.20100216-M2</version>
- <scope>test</scope>
- <type>pom</type>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.slf4j</groupId>
- <artifactId>slf4j-jboss-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
</profile>
<!--
@@ -528,23 +495,7 @@
<properties>
<target.container.excludes>org/jboss/test/osgi/nothing-to-exclude</target.container.excludes>
</properties>
- <dependencies>
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-client</artifactId>
- <version>6.0.0-SNAPSHOT</version>
- <scope>test</scope>
- <type>pom</type>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.slf4j</groupId>
- <artifactId>slf4j-jboss-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
</profile>
-
</profiles>
</project>