JBoss-OSGI SVN: r103676 - projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-08 02:26:36 -0400 (Thu, 08 Apr 2010)
New Revision: 103676
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
Log:
[JBOSGI-307] - JSR160 compliant JMXConnector
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-08 06:23:55 UTC (rev 103675)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-04-08 06:26:36 UTC (rev 103676)
@@ -24,9 +24,7 @@
//$Id$
import java.io.IOException;
-import java.io.Serializable;
import java.net.InetAddress;
-import java.rmi.Remote;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
@@ -54,11 +52,6 @@
private boolean shutdownRegistry;
private Registry rmiRegistry;
- static class RemoteObj implements Remote, Serializable
- {
- private static final long serialVersionUID = 1L;
- }
-
public JMXConnectorService(JMXServiceURL serviceURL, int regPort) throws IOException
{
this.serviceURL = serviceURL;
14 years, 2 months
JBoss-OSGI SVN: r103675 - in projects/jboss-osgi/projects: bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-08 02:23:55 -0400 (Thu, 08 Apr 2010)
New Revision: 103675
Removed:
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXServiceURLFactory.java
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/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
Log:
[JBOSGI-307] - JSR160 compliant JMXConnector
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java 2010-04-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -37,8 +37,6 @@
String REMOTE_JMX_RMI_PORT = "org.jboss.osgi.jmx.rmi.port";
/** The property that sets the port that the RMI Registry binds to: org.jboss.osgi.jmx.rmi.registry.port */
String REMOTE_JMX_RMI_REGISTRY_PORT = "org.jboss.osgi.jmx.rmi.registry.port";
- /** The property that sets the JNDI name the RMIAdaptor binds to: org.jboss.osgi.jmx.rmi.adaptor */
- String REMOTE_JMX_RMI_ADAPTOR = "org.jboss.osgi.jmx.rmi.adaptor";
/** The default host that the RMIAdaptor binds to: localhost */
String DEFAULT_REMOTE_JMX_HOST = "localhost";
@@ -46,6 +44,4 @@
String DEFAULT_REMOTE_JMX_RMI_PORT = "1198";
/** The default port that the RMI Registry binds to: 1090 */
String DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT = "1090";
- /** The default JNDI name the RMIAdaptor binds to: osgi/jmx/RMIAdaptor */
- String DEFAULT_JMX_RMI_ADAPTOR = "osgi/jmx/RMIAdaptor";
}
\ No newline at end of file
Modified: 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 2010-04-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXServiceURLFactory.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -23,6 +23,13 @@
//$Id: JMXConnectorService.java 103656 2010-04-07 20:02:31Z thomas.diesler(a)jboss.com $
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_HOST;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_HOST;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_REGISTRY_PORT;
+
import java.net.MalformedURLException;
import javax.management.remote.JMXServiceURL;
@@ -35,9 +42,23 @@
*/
public abstract class JMXServiceURLFactory
{
- public static JMXServiceURL getServiceURL(String host, int conPort, int regPort)
+ public static JMXServiceURL getServiceURL()
{
- String jmxConnectorURL = "service:jmx:rmi://" + host + ":" + conPort + "/jndi/rmi://" + host + ":" + regPort + "/osgi-jmx-connector";
+ return getServiceURL(null, null, null);
+ }
+
+ public static JMXServiceURL getServiceURL(String host, Integer jmxPort, Integer rmiPort)
+ {
+ if (host == null)
+ host = System.getProperty(REMOTE_JMX_HOST, DEFAULT_REMOTE_JMX_HOST);
+
+ if (jmxPort == null)
+ jmxPort = Integer.parseInt(System.getProperty(REMOTE_JMX_RMI_PORT, DEFAULT_REMOTE_JMX_RMI_PORT));
+
+ if (rmiPort == null)
+ rmiPort = Integer.parseInt(System.getProperty(REMOTE_JMX_RMI_REGISTRY_PORT, DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT));
+
+ String jmxConnectorURL = "service:jmx:rmi://" + host + ":" + jmxPort + "/jndi/rmi://" + host + ":" + rmiPort + "/osgi-jmx-connector";
try
{
return new JMXServiceURL(jmxConnectorURL);
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-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -39,7 +39,7 @@
import org.jboss.logging.Logger;
/**
- * A Service Activator that registers an MBeanServer
+ * A RMI/JRMP connector service.
*
* @author thomas.diesler(a)jboss.com
* @since 24-Apr-2009
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-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -23,25 +23,18 @@
//$Id$
-import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_JMX_RMI_ADAPTOR;
import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_HOST;
import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_PORT;
import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT;
import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_HOST;
-import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR;
import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_PORT;
import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_REGISTRY_PORT;
import java.io.IOException;
import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
import javax.management.remote.JMXServiceURL;
-import javax.naming.Context;
import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
import org.jboss.logging.Logger;
import org.jboss.osgi.jmx.JMXServiceURLFactory;
@@ -63,9 +56,8 @@
private JMXConnectorService jmxConnector;
private String jmxHost;
- private String jmxRmiPort;
- private String rmiRegistryPort;
- private String rmiAdaptorName;
+ private String jmxPortStr;
+ private String rmiPortStr;
private MBeanServer mbeanServer;
private FrameworkStateExt frameworkState;
private ServiceStateExt serviceState;
@@ -101,18 +93,14 @@
if (jmxHost == null)
jmxHost = DEFAULT_REMOTE_JMX_HOST;
- jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
- if (jmxRmiPort == null)
- jmxRmiPort = DEFAULT_REMOTE_JMX_RMI_PORT;
+ jmxPortStr = context.getProperty(REMOTE_JMX_RMI_PORT);
+ if (jmxPortStr == null)
+ jmxPortStr = DEFAULT_REMOTE_JMX_RMI_PORT;
- rmiRegistryPort = context.getProperty(REMOTE_JMX_RMI_REGISTRY_PORT);
- if (rmiRegistryPort == null)
- rmiRegistryPort = DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT;
+ rmiPortStr = context.getProperty(REMOTE_JMX_RMI_REGISTRY_PORT);
+ if (rmiPortStr == null)
+ rmiPortStr = DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT;
- rmiAdaptorName = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
- if (rmiAdaptorName == null)
- rmiAdaptorName = DEFAULT_JMX_RMI_ADAPTOR;
-
// Start tracking the NamingService
InitialContextTracker tracker = new InitialContextTracker(context);
tracker.open();
@@ -141,8 +129,6 @@
class InitialContextTracker extends ServiceTracker
{
- private boolean rmiAdaptorBound;
-
public InitialContextTracker(BundleContext context)
{
super(context, InitialContext.class.getName(), null);
@@ -153,12 +139,12 @@
{
InitialContext iniCtx = (InitialContext)super.addingService(reference);
- int conPort = Integer.parseInt(jmxRmiPort);
- int regPort = Integer.parseInt(rmiRegistryPort);
- JMXServiceURL serviceURL = JMXServiceURLFactory.getServiceURL(jmxHost, conPort, regPort);
+ int jmxPort = Integer.parseInt(jmxPortStr);
+ int rmiPort = Integer.parseInt(rmiPortStr);
+ JMXServiceURL serviceURL = JMXServiceURLFactory.getServiceURL(jmxHost, jmxPort, rmiPort);
try
{
- jmxConnector = new JMXConnectorService(serviceURL, regPort);
+ jmxConnector = new JMXConnectorService(serviceURL, rmiPort);
jmxConnector.start(mbeanServer);
}
catch (IOException ex)
@@ -167,37 +153,12 @@
return iniCtx;
}
- // Bind the RMIAdaptor
- try
- {
- String[] tokens = rmiAdaptorName.split("/");
- Context ctx = iniCtx;
- for (int i = 0; i < tokens.length - 1; i++)
- {
- String token = tokens[i];
- ctx = ctx.createSubcontext(token);
- }
- StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL.toString());
- Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
- iniCtx.bind(rmiAdaptorName, ref);
- rmiAdaptorBound = true;
-
- log.debug("MBeanServerConnection bound to: " + rmiAdaptorName);
- }
- catch (NamingException ex)
- {
- log.error("Cannot bind RMIAdaptor", ex);
- return iniCtx;
- }
-
return iniCtx;
}
@Override
public void removedService(ServiceReference reference, Object service)
{
- InitialContext iniCtx = (InitialContext)service;
-
// Stop JMXConnectorService
if (jmxConnector != null)
{
@@ -205,20 +166,6 @@
jmxConnector = null;
}
- // Unbind the RMIAdaptor
- if (rmiAdaptorBound == true)
- {
- try
- {
- iniCtx.unbind(rmiAdaptorName);
- log.info("MBeanServerConnection unbound from: " + rmiAdaptorName);
- }
- catch (NamingException ex)
- {
- log.error("Cannot unbind RMIAdaptor", ex);
- }
- }
-
super.removedService(reference, service);
}
}
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java 2010-04-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -1,189 +0,0 @@
-/**
- *
- */
-package org.jboss.osgi.jmx.internal;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Set;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServerConnection;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-
-import org.jboss.logging.Logger;
-
-public class RMIAdaptor implements MBeanServerConnection, Serializable
-{
- private static final long serialVersionUID = -360532663805790477L;
-
- // Provide logging
- private transient final Logger log = Logger.getLogger(RMIAdaptor.class);
-
- private transient MBeanServerConnection delegate;
-
- public RMIAdaptor(JMXServiceURL url) throws IOException
- {
- log.debug("Connect JMXConnector to: " + url);
- JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
- delegate = jmxc.getMBeanServerConnection();
- }
-
- public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
- throws InstanceNotFoundException, IOException
- {
- delegate.addNotificationListener(name, listener, filter, handback);
- }
-
- public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException,
- IOException
- {
- delegate.addNotificationListener(name, listener, filter, handback);
- }
-
- public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException,
- InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException
- {
- return delegate.createMBean(className, name, params, signature);
- }
-
- public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException,
- InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException
- {
- return delegate.createMBean(className, name, loaderName, params, signature);
- }
-
- public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException,
- MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException
- {
- return delegate.createMBean(className, name, loaderName);
- }
-
- public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException,
- MBeanException, NotCompliantMBeanException, IOException
- {
- return delegate.createMBean(className, name);
- }
-
- public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException,
- ReflectionException, IOException
- {
- return delegate.getAttribute(name, attribute);
- }
-
- public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException, IOException
- {
- return delegate.getAttributes(name, attributes);
- }
-
- public String getDefaultDomain() throws IOException
- {
- return delegate.getDefaultDomain();
- }
-
- public String[] getDomains() throws IOException
- {
- return delegate.getDomains();
- }
-
- public Integer getMBeanCount() throws IOException
- {
- return delegate.getMBeanCount();
- }
-
- public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException
- {
- return delegate.getMBeanInfo(name);
- }
-
- public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException, IOException
- {
- return delegate.getObjectInstance(name);
- }
-
- public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException,
- ReflectionException, IOException
- {
- return delegate.invoke(name, operationName, params, signature);
- }
-
- public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException, IOException
- {
- return delegate.isInstanceOf(name, className);
- }
-
- public boolean isRegistered(ObjectName name) throws IOException
- {
- return delegate.isRegistered(name);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public Set queryMBeans(ObjectName name, QueryExp query) throws IOException
- {
- return delegate.queryMBeans(name, query);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public Set queryNames(ObjectName name, QueryExp query) throws IOException
- {
- return delegate.queryNames(name, query);
- }
-
- public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
- throws InstanceNotFoundException, ListenerNotFoundException, IOException
- {
- delegate.removeNotificationListener(name, listener, filter, handback);
- }
-
- public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException,
- IOException
- {
- delegate.removeNotificationListener(name, listener);
- }
-
- public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException,
- ListenerNotFoundException, IOException
- {
- delegate.removeNotificationListener(name, listener, filter, handback);
- }
-
- public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException
- {
- delegate.removeNotificationListener(name, listener);
- }
-
- public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException,
- MBeanException, ReflectionException, IOException
- {
- delegate.setAttribute(name, attribute);
- }
-
- public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException, IOException
- {
- return delegate.setAttributes(name, attributes);
- }
-
- public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException
- {
- delegate.unregisterMBean(name);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java 2010-04-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -1,30 +0,0 @@
-/**
- *
- */
-package org.jboss.osgi.jmx.internal;
-
-// $Id$
-
-import java.io.Serializable;
-import java.util.Hashtable;
-
-import javax.management.remote.JMXServiceURL;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-
-public class RMIAdaptorFactory implements ObjectFactory, Serializable
-{
- private static final long serialVersionUID = 2560477127430087074L;
-
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
- {
- Reference ref = (Reference)obj;
- RefAddr refAddr = ref.get(JMXServiceURL.class.getName());
- String serviceURL = (String)refAddr.getContent();
- JMXServiceURL url = new JMXServiceURL(serviceURL);
- return new RMIAdaptor(url);
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java 2010-04-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -23,7 +23,6 @@
//$Id: ServiceStateTestCase.java 103562 2010-04-06 10:25:15Z thomas.diesler(a)jboss.com $
-import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_JMX_RMI_ADAPTOR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -34,8 +33,8 @@
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
-import javax.naming.InitialContext;
+import org.jboss.osgi.jmx.JMXServiceURLFactory;
import org.jboss.osgi.jmx.ObjectNameFactory;
import org.junit.Test;
import org.osgi.jmx.framework.BundleStateMBean;
@@ -54,13 +53,13 @@
public void testJMXConnector() throws Exception
{
// The address of the connector server
- JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://localhost:1198/jndi/rmi://localhost:1090/osgi-jmx-connector");
+ JMXServiceURL serviceURL = JMXServiceURLFactory.getServiceURL(getServerHost(), null, null);
// The environment map, null in this case
Map<String, ?> environment = null;
// Create the JMXCconnectorServer
- JMXConnector cntor = JMXConnectorFactory.connect(address, environment);
+ JMXConnector cntor = JMXConnectorFactory.connect(serviceURL, environment);
// Obtain a "stub" for the remote MBeanServer
MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
@@ -77,23 +76,4 @@
assertTrue(isMBeanRegistered(mbsc, bndName, true));
assertTrue(isMBeanRegistered(mbsc, srvName, true));
}
-
- @Test
- public void testRMIAdaptor() throws Exception
- {
- InitialContext iniCtx = getInitialContext();
- MBeanServerConnection mbsc = (MBeanServerConnection)iniCtx.lookup(DEFAULT_JMX_RMI_ADAPTOR);
-
- // Call the remote MBeanServer
- String domain = mbsc.getDefaultDomain();
- assertEquals("DefaultDomain", domain);
-
- ObjectName fwkName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
- ObjectName bndName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
- ObjectName srvName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
-
- assertTrue(isMBeanRegistered(mbsc, fwkName, true));
- assertTrue(isMBeanRegistered(mbsc, bndName, true));
- assertTrue(isMBeanRegistered(mbsc, srvName, true));
- }
}
\ No newline at end of file
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-08 06:06:55 UTC (rev 103674)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-04-08 06:23:55 UTC (rev 103675)
@@ -37,10 +37,11 @@
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
import javax.management.remote.JMXConnector;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jmx.JMXServiceURLFactory;
import org.jboss.osgi.jmx.MBeanProxy;
import org.jboss.osgi.jmx.ObjectNameFactory;
import org.jboss.osgi.jmx.ServiceStateMBeanExt;
@@ -63,7 +64,7 @@
{
// Provide logging
private static final Logger log = Logger.getLogger(RemoteRuntime.class);
-
+
private MBeanServerConnection mbeanServer;
private JMXConnector jmxConnector;
@@ -77,7 +78,7 @@
{
return true;
}
-
+
@Override
OSGiBundle installBundleInternal(BundleInfo info) throws BundleException
{
@@ -217,15 +218,16 @@
@Override
public MBeanServerConnection getMBeanServer()
{
- // Get the MBeanServerConnection through the RMIAdaptor
+ // Get the MBeanServerConnection through the JMXConnector
if (mbeanServer == null)
{
try
{
- InitialContext iniCtx = getInitialContext();
- mbeanServer = (MBeanServerConnection)iniCtx.lookup("osgi/jmx/RMIAdaptor");
+ JMXServiceURL serviceURL = JMXServiceURLFactory.getServiceURL(getServerHost(), null, null);
+ jmxConnector = JMXConnectorFactory.connect(serviceURL, null);
+ mbeanServer = jmxConnector.getMBeanServerConnection();
}
- catch (NamingException ex)
+ catch (IOException ex)
{
throw new IllegalStateException("Cannot obtain MBeanServerConnection");
}
@@ -237,7 +239,7 @@
public void shutdown()
{
super.shutdown();
-
+
// Close the JMXConnector
if (jmxConnector != null)
{
14 years, 2 months
JBoss-OSGI SVN: r103659 - in projects/jboss-osgi/trunk/distribution/installer/src/main/resources: runtime/server/conf and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-07 16:31:24 -0400 (Wed, 07 Apr 2010)
New Revision: 103659
Modified:
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-all.properties
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-default.properties
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-web.properties
Log:
Remove references to explicit ports
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml 2010-04-07 20:18:21 UTC (rev 103658)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-equinox.xml 2010-04-07 20:31:24 UTC (rev 103659)
@@ -74,11 +74,8 @@
<entry><key>felix.cm.dir</key><value>${jboss.server.data.dir}/osgi-configadmin</value></entry>
<!-- JMX bundle properties -->
<entry><key>org.jboss.osgi.jmx.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jmx.port</key><value>1098</value></entry>
<!-- JNDI bundle properties -->
<entry><key>org.jboss.osgi.jndi.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jndi.rmi.port</key><value>1098</value></entry>
- <entry><key>org.jboss.osgi.jndi.port</key><value>1099</value></entry>
<!-- JTA Object Store -->
<entry><key>com.arjuna.ats.arjuna.objectstore.objectStoreDir</key><value>${jboss.server.data.dir}/tx-object-store</value></entry>
</map>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml 2010-04-07 20:18:21 UTC (rev 103658)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-felix.xml 2010-04-07 20:31:24 UTC (rev 103659)
@@ -74,11 +74,8 @@
<entry><key>felix.cm.dir</key><value>${jboss.server.data.dir}/osgi-configadmin</value></entry>
<!-- JMX bundle properties -->
<entry><key>org.jboss.osgi.jmx.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jmx.port</key><value>1098</value></entry>
<!-- JNDI bundle properties -->
<entry><key>org.jboss.osgi.jndi.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jndi.rmi.port</key><value>1098</value></entry>
- <entry><key>org.jboss.osgi.jndi.port</key><value>1099</value></entry>
<!-- JTA Object Store -->
<entry><key>com.arjuna.ats.arjuna.objectstore.objectStoreDir</key><value>${jboss.server.data.dir}/tx-object-store</value></entry>
</map>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2010-04-07 20:18:21 UTC (rev 103658)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2010-04-07 20:31:24 UTC (rev 103659)
@@ -54,11 +54,8 @@
<entry><key>felix.cm.dir</key><value>${jboss.server.data.dir}/osgi-configadmin</value></entry>
<!-- JMX bundle properties -->
<entry><key>org.jboss.osgi.jmx.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jmx.port</key><value>1098</value></entry>
<!-- JNDI bundle properties -->
<entry><key>org.jboss.osgi.jndi.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jndi.rmi.port</key><value>1098</value></entry>
- <entry><key>org.jboss.osgi.jndi.port</key><value>1099</value></entry>
<!-- JTA Object Store -->
<entry><key>com.arjuna.ats.arjuna.objectstore.objectStoreDir</key><value>${jboss.server.data.dir}/tx-object-store</value></entry>
</map>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2010-04-07 20:18:21 UTC (rev 103658)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2010-04-07 20:31:24 UTC (rev 103659)
@@ -55,11 +55,8 @@
<entry><key>felix.cm.dir</key><value>${osgi.server.home}/data/osgi-configadmin</value></entry>
<!-- JMX bundle properties -->
<entry><key>org.jboss.osgi.jmx.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jmx.port</key><value>1098</value></entry>
<!-- JNDI bundle properties -->
<entry><key>org.jboss.osgi.jndi.host</key><value>${jboss.bind.address}</value></entry>
- <entry><key>org.jboss.osgi.jndi.rmi.port</key><value>1098</value></entry>
- <entry><key>org.jboss.osgi.jndi.port</key><value>1099</value></entry>
<!-- JTA Object Store -->
<entry><key>com.arjuna.ats.arjuna.objectstore.objectStoreDir</key><value>${osgi.server.home}/data/ObjectStore</value></entry>
</map>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-all.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-all.properties 2010-04-07 20:18:21 UTC (rev 103658)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-all.properties 2010-04-07 20:31:24 UTC (rev 103659)
@@ -14,12 +14,9 @@
# JMX bundle properties
org.jboss.osgi.jmx.host=${jboss.bind.address}
-org.jboss.osgi.jmx.rmi.port=1098
# JNDI bundle properties
org.jboss.osgi.jndi.host=${jboss.bind.address}
-org.jboss.osgi.jndi.rmi.port=1098
-org.jboss.osgi.jndi.port=1099
# Husky socket connector properties
org.jboss.osgi.husky.runtime.connector.host=${jboss.bind.address}
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-default.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-default.properties 2010-04-07 20:18:21 UTC (rev 103658)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-default.properties 2010-04-07 20:31:24 UTC (rev 103659)
@@ -8,12 +8,9 @@
# JMX bundle properties
org.jboss.osgi.jmx.host=${jboss.bind.address}
-org.jboss.osgi.jmx.rmi.port=1098
# JNDI bundle properties
org.jboss.osgi.jndi.host=${jboss.bind.address}
-org.jboss.osgi.jndi.rmi.port=1098
-org.jboss.osgi.jndi.port=1099
# Husky socket connector properties
org.jboss.osgi.husky.runtime.connector.host=${jboss.bind.address}
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-web.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-web.properties 2010-04-07 20:18:21 UTC (rev 103658)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-extra-web.properties 2010-04-07 20:31:24 UTC (rev 103659)
@@ -14,12 +14,9 @@
# JMX bundle properties
org.jboss.osgi.jmx.host=${jboss.bind.address}
-org.jboss.osgi.jmx.rmi.port=1098
# JNDI bundle properties
org.jboss.osgi.jndi.host=${jboss.bind.address}
-org.jboss.osgi.jndi.rmi.port=1098
-org.jboss.osgi.jndi.port=1099
# Husky socket connector properties
org.jboss.osgi.husky.runtime.connector.host=${jboss.bind.address}
14 years, 2 months
JBoss-OSGI SVN: r103658 - in projects/jboss-osgi: projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
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>
14 years, 2 months
JBoss-OSGI SVN: r103656 - in projects/jboss-osgi/projects/bundles/jmx/trunk: impl and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-07 16:02:31 -0400 (Wed, 07 Apr 2010)
New Revision: 103656
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/pom.xml
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/JMXCapability.java
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/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java
Log:
Add explicit port for RMI registry
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java 2010-04-07 20:00:05 UTC (rev 103655)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java 2010-04-07 20:02:31 UTC (rev 103656)
@@ -33,10 +33,19 @@
{
/** The property that sets the host that the RMIAdaptor binds to: org.jboss.osgi.jmx.host */
String REMOTE_JMX_HOST = "org.jboss.osgi.jmx.host";
- /** The property that sets the port that the RMIAdaptor binds to: org.jboss.osgi.jmx.port */
+ /** The property that sets the port that the RMIAdaptor binds to: org.jboss.osgi.jmx.rmi.port */
String REMOTE_JMX_RMI_PORT = "org.jboss.osgi.jmx.rmi.port";
+ /** The property that sets the port that the RMI Registry binds to: org.jboss.osgi.jmx.rmi.registry.port */
+ String REMOTE_JMX_RMI_REGISTRY_PORT = "org.jboss.osgi.jmx.rmi.registry.port";
/** The property that sets the JNDI name the RMIAdaptor binds to: org.jboss.osgi.jmx.rmi.adaptor */
String REMOTE_JMX_RMI_ADAPTOR = "org.jboss.osgi.jmx.rmi.adaptor";
+
+ /** The default host that the RMIAdaptor binds to: localhost */
+ String DEFAULT_REMOTE_JMX_HOST = "localhost";
+ /** The default port that the RMIAdaptor binds to: 1198 */
+ String DEFAULT_REMOTE_JMX_RMI_PORT = "1198";
+ /** The default port that the RMI Registry binds to: 1090 */
+ String DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT = "1090";
/** The default JNDI name the RMIAdaptor binds to: osgi/jmx/RMIAdaptor */
- String REMOTE_JMX_RMI_ADAPTOR_NAME = "osgi/jmx/RMIAdaptor";
+ String DEFAULT_JMX_RMI_ADAPTOR = "osgi/jmx/RMIAdaptor";
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/pom.xml 2010-04-07 20:00:05 UTC (rev 103655)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/pom.xml 2010-04-07 20:02:31 UTC (rev 103656)
@@ -194,10 +194,6 @@
<argLine>${surefire.jpda.args}</argLine>
<systemProperties>
<property>
- <name>java.protocol.handler.pkgs</name>
- <value>org.jboss.net.protocol|org.jboss.virtual.protocol</value>
- </property>
- <property>
<name>log4j.output.dir</name>
<value>${project.build.directory}</value>
</property>
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/JMXCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-04-07 20:00:05 UTC (rev 103655)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/JMXCapability.java 2010-04-07 20:02:31 UTC (rev 103656)
@@ -23,6 +23,13 @@
//$Id$
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_HOST;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_HOST;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_REGISTRY_PORT;
+
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -63,8 +70,9 @@
{
super(MBeanServer.class.getName());
- addSystemProperty("org.jboss.osgi.jmx.host", System.getProperty("jboss.bind.address", "localhost"));
- addSystemProperty("org.jboss.osgi.jmx.rmi.port", "1198");
+ addSystemProperty(REMOTE_JMX_HOST, System.getProperty("jboss.bind.address", DEFAULT_REMOTE_JMX_HOST));
+ addSystemProperty(REMOTE_JMX_RMI_PORT, DEFAULT_REMOTE_JMX_RMI_PORT);
+ addSystemProperty(REMOTE_JMX_RMI_REGISTRY_PORT, DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT);
addDependency(new CompendiumCapability());
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:00:05 UTC (rev 103655)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-04-07 20:02:31 UTC (rev 103656)
@@ -24,9 +24,10 @@
//$Id$
import java.io.IOException;
+import java.io.Serializable;
import java.net.InetAddress;
import java.net.MalformedURLException;
-import java.rmi.RemoteException;
+import java.rmi.Remote;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
@@ -48,38 +49,41 @@
{
// Provide logging
private static final Logger log = Logger.getLogger(JMXConnectorService.class);
-
+
private JMXServiceURL serviceURL;
private JMXConnectorServer jmxConnectorServer;
private boolean shutdownRegistry;
private Registry rmiRegistry;
- public JMXConnectorService(MBeanServer mbeanServer, String host, int rmiPort) throws IOException
+ static class RemoteObj implements Remote, Serializable
{
- // check to see if registry already created
- rmiRegistry = LocateRegistry.getRegistry(host, rmiPort);
+ private static final long serialVersionUID = 1L;
+ }
+
+ public JMXConnectorService(JMXServiceURL serviceURL, int regPort) throws IOException
+ {
+ this.serviceURL = serviceURL;
+
+ String host = serviceURL.getHost();
+
+ // Check to see if registry already created
+ rmiRegistry = LocateRegistry.getRegistry(host, regPort);
try
{
rmiRegistry.list();
- log.debug("RMI registry running at host=" + host + ",port=" + rmiPort);
+ log.debug("RMI registry running at host=" + host + ",port=" + regPort);
}
- catch (RemoteException e)
+ catch (Exception ex)
{
- log.debug("No RMI registry running at host=" + host + ",port=" + rmiPort + ". Will create one.");
- rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(InetAddress.getByName(host)));
+ log.debug("No RMI registry running at host=" + host + ",port=" + regPort + ". Will create one.");
+ rmiRegistry = LocateRegistry.createRegistry(regPort, null, new DefaultSocketFactory(InetAddress.getByName(host)));
shutdownRegistry = true;
}
-
- // create new connector server and start it
- serviceURL = getServiceURL(host, rmiPort);
- jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
-
- log.debug("JMXConnectorServer created: " + serviceURL);
}
- static JMXServiceURL getServiceURL(String host, int rmiPort)
+ static JMXServiceURL getServiceURL(String host, int conPort, int regPort)
{
- String jmxConnectorURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + "/jmxconnector";
+ String jmxConnectorURL = "service:jmx:rmi://" + host + ":" + conPort + "/jndi/rmi://" + host + ":" + regPort + "/osgi-jmx-connector";
try
{
return new JMXServiceURL(jmxConnectorURL);
@@ -90,34 +94,20 @@
}
}
- public void start()
+ public void start(MBeanServer mbeanServer) throws IOException
{
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ // create new connector server and start it
+ jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
+ log.debug("JMXConnectorServer created: " + serviceURL);
- jmxConnectorServer.start();
-
- log.debug("JMXConnectorServer started: " + serviceURL);
- }
- catch (IOException ex)
- {
- log.error("Cannot start JMXConnectorServer", ex);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
+ jmxConnectorServer.start();
+ log.debug("JMXConnectorServer started: " + serviceURL);
}
public void stop()
{
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
{
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-
jmxConnectorServer.stop();
// Shutdown the registry if this service created it
@@ -133,9 +123,5 @@
{
log.warn("Cannot stop JMXConnectorServer", ex);
}
- finally
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
}
}
\ No newline at end of file
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:00:05 UTC (rev 103655)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-04-07 20:02:31 UTC (rev 103656)
@@ -23,6 +23,15 @@
//$Id$
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_JMX_RMI_ADAPTOR;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_HOST;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_HOST;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_PORT;
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_REGISTRY_PORT;
+
import java.io.IOException;
import javax.management.MBeanServer;
@@ -35,7 +44,6 @@
import javax.naming.StringRefAddr;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jmx.JMXConstantsExt;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -55,6 +63,7 @@
private JMXConnectorService jmxConnector;
private String jmxHost;
private String jmxRmiPort;
+ private String rmiRegistryPort;
private String rmiAdaptorName;
private MBeanServer mbeanServer;
private FrameworkStateExt frameworkState;
@@ -87,20 +96,24 @@
packageState = new PackageStateExt(sysContext, mbeanServer);
packageState.start();
- jmxHost = context.getProperty(JMXConstantsExt.REMOTE_JMX_HOST);
+ jmxHost = context.getProperty(REMOTE_JMX_HOST);
if (jmxHost == null)
- jmxHost = "localhost";
+ jmxHost = DEFAULT_REMOTE_JMX_HOST;
- jmxRmiPort = context.getProperty(JMXConstantsExt.REMOTE_JMX_RMI_PORT);
+ jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
if (jmxRmiPort == null)
- jmxRmiPort = "1098";
+ jmxRmiPort = DEFAULT_REMOTE_JMX_RMI_PORT;
- rmiAdaptorName = context.getProperty(JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR);
+ rmiRegistryPort = context.getProperty(REMOTE_JMX_RMI_REGISTRY_PORT);
+ if (rmiRegistryPort == null)
+ rmiRegistryPort = DEFAULT_REMOTE_JMX_RMI_REGISTRY_PORT;
+
+ rmiAdaptorName = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
if (rmiAdaptorName == null)
- rmiAdaptorName = JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR_NAME;
+ rmiAdaptorName = DEFAULT_JMX_RMI_ADAPTOR;
// Start tracking the NamingService
- InitialContextTracker tracker = new InitialContextTracker(context, rmiAdaptorName);
+ InitialContextTracker tracker = new InitialContextTracker(context);
tracker.open();
}
@@ -127,63 +140,55 @@
class InitialContextTracker extends ServiceTracker
{
- private String rmiAdaptorName;
private boolean rmiAdaptorBound;
- public InitialContextTracker(BundleContext context, String rmiAdaptorName)
+ public InitialContextTracker(BundleContext context)
{
super(context, InitialContext.class.getName(), null);
- this.rmiAdaptorName = rmiAdaptorName;
}
@Override
public Object addingService(ServiceReference reference)
{
InitialContext iniCtx = (InitialContext)super.addingService(reference);
-
- JMXServiceURL serviceURL = JMXConnectorService.getServiceURL(jmxHost, Integer.parseInt(jmxRmiPort));
+
+ int conPort = Integer.parseInt(jmxRmiPort);
+ int regPort = Integer.parseInt(rmiRegistryPort);
+ JMXServiceURL serviceURL = JMXConnectorService.getServiceURL(jmxHost, conPort, regPort);
try
{
- // Try to start the JMXConnector, this should fail if it is already running
- // [TODO] is there a better way to check whether the connector is already running?
- jmxConnector = new JMXConnectorService(mbeanServer, jmxHost, Integer.parseInt(jmxRmiPort));
- jmxConnector.start();
+ jmxConnector = new JMXConnectorService(serviceURL, regPort);
+ jmxConnector.start(mbeanServer);
}
catch (IOException ex)
{
- // Assume that the JMXConnector is already running if we cannot start it
- log.debug("Assume JMXConnectorServer already running on: " + serviceURL);
+ log.error("Cannot start JMXConnectorServer on: " + serviceURL, ex);
+ return iniCtx;
}
+ // Bind the RMIAdaptor
try
{
- // Check if the RMIAdaptor is already bound
- iniCtx.lookup(rmiAdaptorName);
- }
- catch (NamingException lookupEx)
- {
- // Bind the RMIAdaptor
- try
+ String[] tokens = rmiAdaptorName.split("/");
+ Context ctx = iniCtx;
+ for (int i = 0; i < tokens.length - 1; i++)
{
- String[] tokens = rmiAdaptorName.split("/");
- Context ctx = iniCtx;
- for (int i = 0; i < tokens.length - 1; i++)
- {
- String token = tokens[i];
- ctx = ctx.createSubcontext(token);
- }
- StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL.toString());
- Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
- iniCtx.bind(rmiAdaptorName, ref);
- rmiAdaptorBound = true;
+ String token = tokens[i];
+ ctx = ctx.createSubcontext(token);
+ }
+ StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL.toString());
+ Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
+ iniCtx.bind(rmiAdaptorName, ref);
+ rmiAdaptorBound = true;
- log.info("MBeanServerConnection bound to: " + rmiAdaptorName);
- }
- catch (NamingException ex)
- {
- log.error("Cannot bind RMIAdaptor", ex);
- }
+ log.debug("MBeanServerConnection bound to: " + rmiAdaptorName);
}
+ catch (NamingException ex)
+ {
+ log.error("Cannot bind RMIAdaptor", ex);
+ return iniCtx;
+ }
+
return iniCtx;
}
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java 2010-04-07 20:00:05 UTC (rev 103655)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java 2010-04-07 20:02:31 UTC (rev 103656)
@@ -30,14 +30,20 @@
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
+import org.jboss.logging.Logger;
+
public class RMIAdaptor implements MBeanServerConnection, Serializable
{
- private static final long serialVersionUID = 6066226353118090215L;
+ private static final long serialVersionUID = -360532663805790477L;
- private MBeanServerConnection delegate;
+ // Provide logging
+ private transient final Logger log = Logger.getLogger(RMIAdaptor.class);
+
+ private transient MBeanServerConnection delegate;
public RMIAdaptor(JMXServiceURL url) throws IOException
{
+ log.debug("Connect JMXConnector to: " + url);
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
delegate = jmxc.getMBeanServerConnection();
}
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java 2010-04-07 20:00:05 UTC (rev 103655)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java 2010-04-07 20:02:31 UTC (rev 103656)
@@ -23,7 +23,7 @@
//$Id: ServiceStateTestCase.java 103562 2010-04-06 10:25:15Z thomas.diesler(a)jboss.com $
-import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR_NAME;
+import static org.jboss.osgi.jmx.JMXConstantsExt.DEFAULT_JMX_RMI_ADAPTOR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -54,7 +54,7 @@
public void testJMXConnector() throws Exception
{
// The address of the connector server
- JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:1098/jmxconnector");
+ JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://localhost:1198/jndi/rmi://localhost:1090/osgi-jmx-connector");
// The environment map, null in this case
Map<String, ?> environment = null;
@@ -82,7 +82,7 @@
public void testRMIAdaptor() throws Exception
{
InitialContext iniCtx = getInitialContext();
- MBeanServerConnection mbsc = (MBeanServerConnection)iniCtx.lookup(REMOTE_JMX_RMI_ADAPTOR_NAME);
+ MBeanServerConnection mbsc = (MBeanServerConnection)iniCtx.lookup(DEFAULT_JMX_RMI_ADAPTOR);
// Call the remote MBeanServer
String domain = mbsc.getDefaultDomain();
14 years, 2 months
JBoss-OSGI SVN: r103623 - in projects/jboss-osgi/trunk: testsuite and 2 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-07 05:46:57 -0400 (Wed, 07 Apr 2010)
New Revision: 103623
Modified:
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/PublisherInterceptor.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log4j.xml
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Fix HttpService binding to user bundle.
Update to jboss-osgi-deployer-1.0.7-SNAPSHOT
Fix remote runtime test suite
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2010-04-07 09:44:09 UTC (rev 103622)
+++ projects/jboss-osgi/trunk/pom.xml 2010-04-07 09:46:57 UTC (rev 103623)
@@ -58,7 +58,7 @@
<version.jboss.osgi.blueprint>1.0.0.Beta2</version.jboss.osgi.blueprint>
<version.jboss.osgi.common>1.0.4</version.jboss.osgi.common>
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
- <version.jboss.osgi.deployers>1.0.6</version.jboss.osgi.deployers>
+ <version.jboss.osgi.deployers>1.0.7-SNAPSHOT</version.jboss.osgi.deployers>
<version.jboss.osgi.deployment>1.0.2</version.jboss.osgi.deployment>
<version.jboss.osgi.equinox>3.5.2</version.jboss.osgi.equinox>
<version.jboss.osgi.felix>2.0.4</version.jboss.osgi.felix>
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/PublisherInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/PublisherInterceptor.java 2010-04-07 09:44:09 UTC (rev 103622)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/interceptor/processor/PublisherInterceptor.java 2010-04-07 09:46:57 UTC (rev 103623)
@@ -96,12 +96,12 @@
private HttpService getHttpService(InvocationContext context, boolean required)
{
- BundleContext syscontext = context.getSystemContext();
- ServiceReference sref = syscontext.getServiceReference(HttpService.class.getName());
+ BundleContext bndContext = context.getBundle().getBundleContext();
+ ServiceReference sref = bndContext.getServiceReference(HttpService.class.getName());
if (sref == null && required == true)
throw new IllegalStateException("Required HttpService not available");
- HttpService httpService = (HttpService)syscontext.getService(sref);
+ HttpService httpService = (HttpService)bndContext.getService(sref);
return httpService;
}
}
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log4j.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log4j.xml 2010-04-07 09:44:09 UTC (rev 103622)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log4j.xml 2010-04-07 09:46:57 UTC (rev 103623)
@@ -32,10 +32,11 @@
<!-- Limit categories -->
<!-- ================ -->
- <!-- Show jboss deployer traces -->
+ <!-- Show jboss traces - ->
<category name="org.jboss">
<priority value="TRACE" />
</category>
+ -->
<!-- ======================= -->
<!-- Setup the Root category -->
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2010-04-07 09:44:09 UTC (rev 103622)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2010-04-07 09:46:57 UTC (rev 103623)
@@ -427,14 +427,6 @@
<properties>
<target.container.excludes>org/jboss/test/osgi/jbossas/**</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>
- <type>pom</type>
- </dependency>
- </dependencies>
</profile>
<!--
14 years, 2 months
JBoss-OSGI SVN: r103622 - in projects/jboss-osgi/projects: bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-07 05:44:09 -0400 (Wed, 07 Apr 2010)
New Revision: 103622
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java
Removed:
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java
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/test/java/org/jboss/test/osgi/jmx/AbstractJMXTestCase.java
projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/resources/jboss-osgi-framework.properties
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
Log:
Use REMOTE_JMX_RMI_ADAPTOR_NAME = "osgi/jmx/RMIAdaptor"
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java 2010-04-07 09:39:57 UTC (rev 103621)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/api/src/main/java/org/jboss/osgi/jmx/JMXConstantsExt.java 2010-04-07 09:44:09 UTC (rev 103622)
@@ -37,4 +37,6 @@
String REMOTE_JMX_RMI_PORT = "org.jboss.osgi.jmx.rmi.port";
/** The property that sets the JNDI name the RMIAdaptor binds to: org.jboss.osgi.jmx.rmi.adaptor */
String REMOTE_JMX_RMI_ADAPTOR = "org.jboss.osgi.jmx.rmi.adaptor";
+ /** The default JNDI name the RMIAdaptor binds to: osgi/jmx/RMIAdaptor */
+ String REMOTE_JMX_RMI_ADAPTOR_NAME = "osgi/jmx/RMIAdaptor";
}
\ No newline at end of file
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 09:39:57 UTC (rev 103621)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-04-07 09:44:09 UTC (rev 103622)
@@ -26,8 +26,13 @@
import java.io.IOException;
import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
import javax.management.remote.JMXServiceURL;
+import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
import org.jboss.logging.Logger;
import org.jboss.osgi.jmx.JMXConstantsExt;
@@ -46,10 +51,11 @@
{
// Provide logging
private static final Logger log = Logger.getLogger(JMXServiceActivator.class);
-
+
private JMXConnectorService jmxConnector;
private String jmxHost;
private String jmxRmiPort;
+ private String rmiAdaptorName;
private MBeanServer mbeanServer;
private FrameworkStateExt frameworkState;
private ServiceStateExt serviceState;
@@ -72,15 +78,15 @@
// Register the ServiceStateMBean
serviceState = new ServiceStateExt(sysContext, mbeanServer);
serviceState.start();
-
+
// Register the BundleStateMBean
bundleState = new BundleStateExt(sysContext, mbeanServer);
bundleState.start();
-
+
// Register the PackageStateMBean
packageState = new PackageStateExt(sysContext, mbeanServer);
packageState.start();
-
+
jmxHost = context.getProperty(JMXConstantsExt.REMOTE_JMX_HOST);
if (jmxHost == null)
jmxHost = "localhost";
@@ -89,8 +95,12 @@
if (jmxRmiPort == null)
jmxRmiPort = "1098";
+ rmiAdaptorName = context.getProperty(JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR);
+ if (rmiAdaptorName == null)
+ rmiAdaptorName = JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR_NAME;
+
// Start tracking the NamingService
- InitialContextTracker tracker = new InitialContextTracker(context);
+ InitialContextTracker tracker = new InitialContextTracker(context, rmiAdaptorName);
tracker.open();
}
@@ -104,10 +114,10 @@
// Unregister the BundleStateMBean
bundleState.stop();
-
+
// Unregister the PackageStateMBean
packageState.stop();
-
+
if (jmxConnector != null)
{
jmxConnector.stop();
@@ -117,9 +127,13 @@
class InitialContextTracker extends ServiceTracker
{
- public InitialContextTracker(BundleContext context)
+ private String rmiAdaptorName;
+ private boolean rmiAdaptorBound;
+
+ public InitialContextTracker(BundleContext context, String rmiAdaptorName)
{
super(context, InitialContext.class.getName(), null);
+ this.rmiAdaptorName = rmiAdaptorName;
}
@Override
@@ -140,18 +154,65 @@
// Assume that the JMXConnector is already running if we cannot start it
log.debug("Assume JMXConnectorServer already running on: " + serviceURL);
}
+
+ try
+ {
+ // Check if the RMIAdaptor is already bound
+ iniCtx.lookup(rmiAdaptorName);
+ }
+ catch (NamingException lookupEx)
+ {
+ // Bind the RMIAdaptor
+ try
+ {
+ String[] tokens = rmiAdaptorName.split("/");
+ Context ctx = iniCtx;
+ for (int i = 0; i < tokens.length - 1; i++)
+ {
+ String token = tokens[i];
+ ctx = ctx.createSubcontext(token);
+ }
+ StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL.toString());
+ Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
+ iniCtx.bind(rmiAdaptorName, ref);
+ rmiAdaptorBound = true;
+
+ log.info("MBeanServerConnection bound to: " + rmiAdaptorName);
+ }
+ catch (NamingException ex)
+ {
+ log.error("Cannot bind RMIAdaptor", ex);
+ }
+ }
return iniCtx;
}
@Override
public void removedService(ServiceReference reference, Object service)
{
+ InitialContext iniCtx = (InitialContext)service;
+
// Stop JMXConnectorService
if (jmxConnector != null)
{
jmxConnector.stop();
jmxConnector = null;
}
+
+ // Unbind the RMIAdaptor
+ if (rmiAdaptorBound == true)
+ {
+ try
+ {
+ iniCtx.unbind(rmiAdaptorName);
+ log.info("MBeanServerConnection unbound from: " + rmiAdaptorName);
+ }
+ catch (NamingException ex)
+ {
+ log.error("Cannot unbind RMIAdaptor", ex);
+ }
+ }
+
super.removedService(reference, service);
}
}
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/AbstractJMXTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/AbstractJMXTestCase.java 2010-04-07 09:39:57 UTC (rev 103621)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/AbstractJMXTestCase.java 2010-04-07 09:44:09 UTC (rev 103622)
@@ -60,7 +60,7 @@
private MBeanServer server;
@BeforeClass
- public static void setUpClass() throws Exception
+ public static void beforeAbstractJMXTestCase() throws Exception
{
// Install/Start the jboss-osgi-jmx bundle
String bundleName = System.getProperty("project.build.finalName");
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java 2010-04-07 09:39:57 UTC (rev 103621)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java 2010-04-07 09:44:09 UTC (rev 103622)
@@ -1,88 +0,0 @@
-/*
- * 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.test.osgi.jmx;
-
-//$Id: ServiceStateTestCase.java 103562 2010-04-06 10:25:15Z thomas.diesler(a)jboss.com $
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URL;
-import java.util.Map;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-
-import org.jboss.osgi.jmx.ObjectNameFactory;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.jmx.framework.BundleStateMBean;
-import org.osgi.jmx.framework.FrameworkMBean;
-import org.osgi.jmx.framework.ServiceStateMBean;
-
-/**
- * Test JSR160 remote connectivity.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 06-Apr-2010
- */
-public class JSR160TestCase extends AbstractJMXTestCase
-{
- @Test
- public void testJMXConnector() throws Exception
- {
- URL url = getTestArchiveURL("bundles/jboss-osgi-common-core.jar");
- Bundle bundle = systemContext.installBundle(url.toExternalForm());
- bundle.start();
-
- url = getTestArchiveURL("bundles/jboss-osgi-jndi.jar");
- bundle = systemContext.installBundle(url.toExternalForm());
- bundle.start();
-
- // The address of the connector server
- JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:1098/jmxconnector");
-
- // The environment map, null in this case
- Map<String, ?> environment = null;
-
- // Create the JMXCconnectorServer
- JMXConnector cntor = JMXConnectorFactory.connect(address, environment);
-
- // Obtain a "stub" for the remote MBeanServer
- MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
-
- // Call the remote MBeanServer
- String domain = mbsc.getDefaultDomain();
- assertEquals("DefaultDomain", domain);
-
- ObjectName fwkName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
- ObjectName bndName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
- ObjectName srvName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
-
- assertTrue(isMBeanRegistered(mbsc, fwkName, true));
- assertTrue(isMBeanRegistered(mbsc, bndName, true));
- assertTrue(isMBeanRegistered(mbsc, srvName, true));
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java (from rev 103579, projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/java/org/jboss/test/osgi/jmx/JSR160TestCase.java 2010-04-07 09:44:09 UTC (rev 103622)
@@ -0,0 +1,99 @@
+/*
+ * 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.test.osgi.jmx;
+
+//$Id: ServiceStateTestCase.java 103562 2010-04-06 10:25:15Z thomas.diesler(a)jboss.com $
+
+import static org.jboss.osgi.jmx.JMXConstantsExt.REMOTE_JMX_RMI_ADAPTOR_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.naming.InitialContext;
+
+import org.jboss.osgi.jmx.ObjectNameFactory;
+import org.junit.Test;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * Test JSR160 remote connectivity.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 06-Apr-2010
+ */
+public class JSR160TestCase extends AbstractJMXTestCase
+{
+ @Test
+ public void testJMXConnector() throws Exception
+ {
+ // The address of the connector server
+ JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:1098/jmxconnector");
+
+ // The environment map, null in this case
+ Map<String, ?> environment = null;
+
+ // Create the JMXCconnectorServer
+ JMXConnector cntor = JMXConnectorFactory.connect(address, environment);
+
+ // Obtain a "stub" for the remote MBeanServer
+ MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
+
+ // Call the remote MBeanServer
+ String domain = mbsc.getDefaultDomain();
+ assertEquals("DefaultDomain", domain);
+
+ ObjectName fwkName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ ObjectName bndName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ ObjectName srvName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+
+ assertTrue(isMBeanRegistered(mbsc, fwkName, true));
+ assertTrue(isMBeanRegistered(mbsc, bndName, true));
+ assertTrue(isMBeanRegistered(mbsc, srvName, true));
+ }
+
+ @Test
+ public void testRMIAdaptor() throws Exception
+ {
+ InitialContext iniCtx = getInitialContext();
+ MBeanServerConnection mbsc = (MBeanServerConnection)iniCtx.lookup(REMOTE_JMX_RMI_ADAPTOR_NAME);
+
+ // Call the remote MBeanServer
+ String domain = mbsc.getDefaultDomain();
+ assertEquals("DefaultDomain", domain);
+
+ ObjectName fwkName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ ObjectName bndName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ ObjectName srvName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+
+ assertTrue(isMBeanRegistered(mbsc, fwkName, true));
+ assertTrue(isMBeanRegistered(mbsc, bndName, true));
+ assertTrue(isMBeanRegistered(mbsc, srvName, true));
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/resources/jboss-osgi-framework.properties 2010-04-07 09:39:57 UTC (rev 103621)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/impl/src/test/resources/jboss-osgi-framework.properties 2010-04-07 09:44:09 UTC (rev 103622)
@@ -32,4 +32,7 @@
org.jboss.osgi.spi.framework.autoStart=\
file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
file://${test.archive.directory}/bundles/jboss-osgi-common.jar \
- file://${test.archive.directory}/bundles/org.apache.aries.jmx.jar
\ No newline at end of file
+ file://${test.archive.directory}/bundles/org.apache.aries.jmx.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-common-core.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-jndi.jar
+
\ No newline at end of file
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-04-07 09:39:57 UTC (rev 103621)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-04-07 09:44:09 UTC (rev 103622)
@@ -134,7 +134,7 @@
{
Throwable cause = rte.getCause() != null ? rte.getCause() : rte;
if (cause instanceof InstanceNotFoundException == false)
- log.warn("Cannot get state for bundle: " + bundleId, cause);
+ log.warn("Cannot get state for bundle: " + this, cause);
return Bundle.UNINSTALLED;
}
@@ -281,7 +281,7 @@
}
catch (IOException ex)
{
- throw new BundleException("Cannot start bundle: " + bundleId, ex);
+ throw new BundleException("Cannot start bundle: " + this, ex);
}
}
@@ -295,7 +295,7 @@
}
catch (IOException ex)
{
- throw new BundleException("Cannot stop bundle: " + bundleId, ex);
+ throw new BundleException("Cannot stop bundle: " + this, ex);
}
}
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 09:39:57 UTC (rev 103621)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-04-07 09:44:09 UTC (rev 103622)
@@ -67,6 +67,9 @@
{
// Provide logging
private static final Logger log = Logger.getLogger(RemoteRuntime.class);
+
+ private MBeanServerConnection mbeanServer;
+ private JMXConnector jmxConnector;
public RemoteRuntime(OSGiRuntimeHelper helper)
{
@@ -74,6 +77,12 @@
}
@Override
+ public boolean isRemoteRuntime()
+ {
+ return true;
+ }
+
+ @Override
OSGiBundle installBundleInternal(BundleInfo info) throws BundleException
{
try
@@ -212,7 +221,46 @@
@Override
public MBeanServerConnection getMBeanServer()
{
- MBeanServerConnection mbeanServer = null;
+ // Get the MBeanServerConnection through the RMIAdaptor
+ if (mbeanServer == null)
+ {
+ try
+ {
+ InitialContext iniCtx = getInitialContext();
+ mbeanServer = (MBeanServerConnection)iniCtx.lookup("osgi/jmx/RMIAdaptor");
+ }
+ catch (NamingException ex)
+ {
+ log.debug("Cannot obtain MBeanServerConnection through the RMIAdaptor", ex);
+ }
+ }
+
+ // 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();
@@ -225,36 +273,31 @@
Map<String, ?> env = null;
// Create the JMXCconnectorServer
- JMXConnector cntor = JMXConnectorFactory.connect(address, env);
-
- // Obtain a "stub" for the remote MBeanServer
- mbeanServer = cntor.getMBeanServerConnection();
+ connector = JMXConnectorFactory.connect(address, env);
}
catch (Exception ex)
{
- log.warn("Cannot obtain MBeanServerConnection", ex);
+ log.debug("Cannot obtain JMXConnector", ex);
}
+ return connector;
+ }
- // Fall back to the legacy JNDI name
- if (mbeanServer == null)
+ @Override
+ public void shutdown()
+ {
+ super.shutdown();
+
+ // Close the JMXConnector
+ if (jmxConnector != null)
{
try
{
- InitialContext iniCtx = getInitialContext();
- mbeanServer = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ jmxConnector.close();
}
- catch (NamingException ex)
+ catch (IOException ex)
{
- log.warn("Cannot obtain MBeanServerConnection", ex);
+ log.warn("Cannot close JMXConnector", ex);
}
}
-
- return mbeanServer;
}
-
- @Override
- public boolean isRemoteRuntime()
- {
- return true;
- }
}
14 years, 2 months
JBoss-OSGI SVN: r103621 - projects/jboss-osgi/projects/runtime/deployers/trunk/vfs30.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-07 05:39:57 -0400 (Wed, 07 Apr 2010)
New Revision: 103621
Modified:
projects/jboss-osgi/projects/runtime/deployers/trunk/vfs30/pom.xml
Log:
Use jboss-deployers-2.2.0.Alpha4
Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/vfs30/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/vfs30/pom.xml 2010-04-07 09:07:52 UTC (rev 103620)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/vfs30/pom.xml 2010-04-07 09:39:57 UTC (rev 103621)
@@ -28,7 +28,7 @@
</parent>
<properties>
- <version.jboss.deployers>2.2.0.Alpha3</version.jboss.deployers>
+ <version.jboss.deployers>2.2.0.Alpha4</version.jboss.deployers>
</properties>
<!-- Dependencies -->
14 years, 2 months
JBoss-OSGI SVN: r103572 - projects/jboss-osgi/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-06 09:53:11 -0400 (Tue, 06 Apr 2010)
New Revision: 103572
Modified:
projects/jboss-osgi/trunk/pom.xml
Log:
Update jmx, spi
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2010-04-06 13:52:41 UTC (rev 103571)
+++ projects/jboss-osgi/trunk/pom.xml 2010-04-06 13:53:11 UTC (rev 103572)
@@ -67,12 +67,12 @@
<version.jboss.osgi.husky>1.0.4</version.jboss.osgi.husky>
<version.jboss.osgi.jaxb>2.1.10.SP4</version.jboss.osgi.jaxb>
<version.jboss.osgi.jbossas>1.0.3</version.jboss.osgi.jbossas>
- <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.jndi>1.0.3</version.jboss.osgi.jndi>
<version.jboss.osgi.jta>1.0.1</version.jboss.osgi.jta>
<version.jboss.osgi.reflect>2.2.0</version.jboss.osgi.reflect>
<version.jboss.osgi.serviceloader>1.0.1</version.jboss.osgi.serviceloader>
- <version.jboss.osgi.spi>1.0.5.SP1</version.jboss.osgi.spi>
+ <version.jboss.osgi.spi>1.0.6-SNAPSHOT</version.jboss.osgi.spi>
<version.jboss.osgi.vfs>1.0.0</version.jboss.osgi.vfs>
<version.jboss.osgi.webapp>0.7.2.SP2</version.jboss.osgi.webapp>
<version.jboss.osgi.webconsole>1.0.3</version.jboss.osgi.webconsole>
14 years, 2 months
JBoss-OSGI SVN: r103571 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-04-06 09:52:41 -0400 (Tue, 06 Apr 2010)
New Revision: 103571
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
Log:
Use JSR160 JMXConnector. Deprecate jmx/invoker/RMIAdaptor JNDI binding.
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-06 13:51:42 UTC (rev 103570)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-04-06 13:52:41 UTC (rev 103571)
@@ -30,24 +30,29 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
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;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.jboss.osgi.testing.OSGiServiceReference;
-import org.jboss.osgi.testing.OSGiRuntimeHelper;
import org.osgi.framework.BundleException;
import org.osgi.jmx.framework.BundleStateMBean;
import org.osgi.jmx.framework.ServiceStateMBean;
@@ -62,8 +67,6 @@
{
// Provide logging
private static final Logger log = Logger.getLogger(RemoteRuntime.class);
-
- private MBeanServerConnection mbeanServer;
public RemoteRuntime(OSGiRuntimeHelper helper)
{
@@ -209,6 +212,30 @@
@Override
public MBeanServerConnection getMBeanServer()
{
+ MBeanServerConnection mbeanServer = 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
+ JMXConnector cntor = JMXConnectorFactory.connect(address, env);
+
+ // Obtain a "stub" for the remote MBeanServer
+ mbeanServer = cntor.getMBeanServerConnection();
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot obtain MBeanServerConnection", ex);
+ }
+
+ // Fall back to the legacy JNDI name
if (mbeanServer == null)
{
try
@@ -218,9 +245,10 @@
}
catch (NamingException ex)
{
- throw new IllegalStateException("Cannot obtain MBeanServerConnection", ex);
+ log.warn("Cannot obtain MBeanServerConnection", ex);
}
}
+
return mbeanServer;
}
14 years, 2 months