[jboss-cvs] JBossAS SVN: r103437 - in trunk: build and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 1 10:56:48 EDT 2010
Author: smarlow at redhat.com
Date: 2010-04-01 10:56:48 -0400 (Thu, 01 Apr 2010)
New Revision: 103437
Added:
trunk/server/src/etc/deploy/jmx-jboss-beans.xml
trunk/system/src/main/java/org/jboss/system/server/jmx/
trunk/system/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java
trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java
Removed:
trunk/jbossas-jmx-remoting/
Modified:
trunk/build/build.xml
trunk/build/pom.xml
trunk/pom.xml
Log:
JBAS-7827 Create a JSR-160 connector server deployment in AS
Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml 2010-04-01 14:44:21 UTC (rev 103436)
+++ trunk/build/build.xml 2010-04-01 14:56:48 UTC (rev 103437)
@@ -186,7 +186,6 @@
module-server,
module-deployment,
module-jbossas-remoting,
- module-jbossas-jmx-remoting,
module-cluster,
module-varia,
module-iiop,
@@ -610,31 +609,7 @@
</target>
- <!-- ===================== -->
- <!-- JBoss AS JMX Remoting -->
- <!-- ===================== -->
- <target name="module-jbossas-jmx-remoting">
- <property name="jbossas-jmx-remoting.module.name" value="jbossas-jmx-remoting"/>
- <property name="jbossas-jmx-remoting.module.output"
- value="${project.root}/${jbossas-jmx-remoting.module.name}/target"/>
-
- <unjar src="${jbossas-jmx-remoting.module.output}/jmx-remoting.sar" dest="${install.default}/deploy/jmx-remoting.sar"/>
- <unjar src="${jbossas-jmx-remoting.module.output}/jmx-remoting.sar" dest="${install.all}/deploy/jmx-remoting.sar"/>
-
- </target>
-
- <target name="module-jbossas-jmx-remoting-all" depends="module-jbossas-jmx-remoting">
- <!-- Copy the generated javadocs -->
- <mkdir dir="${install.api}/${jbossas-jmx-remoting.module.name}"/>
- <copy todir="${install.api}/${jbossas-jmx-remoting.module.name}" filtering="no">
- <fileset dir="${jbossas-jmx-remoting.module.output}/api">
- <include name="**/*"/>
- </fileset>
- </copy>
-
- </target>
-
<!-- ======== -->
<!-- EJB 3.0 -->
<!-- ======== -->
@@ -885,7 +860,6 @@
</fileset>
</copy>
- <copy file="${server.module.output}/resources/jmx-invoker-adaptor/META-INF/jboss-service.xml" tofile="${install.all.deploy}/jmx-invoker-service.xml"/>
<!-- Copy the "all" configuration files -->
<mkdir dir="${install.server}/all/conf"/>
Modified: trunk/build/pom.xml
===================================================================
--- trunk/build/pom.xml 2010-04-01 14:44:21 UTC (rev 103436)
+++ trunk/build/pom.xml 2010-04-01 14:56:48 UTC (rev 103437)
@@ -136,11 +136,6 @@
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-jbossas-jmx-remoting</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-jbossas-remoting</artifactId>
<optional>true</optional>
</dependency>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-01 14:44:21 UTC (rev 103436)
+++ trunk/pom.xml 2010-04-01 14:56:48 UTC (rev 103437)
@@ -339,11 +339,6 @@
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-jbossas-jmx-remoting</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-jbossas-remoting</artifactId>
<version>${project.version}</version>
</dependency>
@@ -561,7 +556,6 @@
<module>server</module>
<module>deployment</module>
<module>jbossas-remoting</module>
- <module>jbossas-jmx-remoting</module>
<module>hornetq-int</module>
<module>cluster</module>
<module>varia</module>
Added: trunk/server/src/etc/deploy/jmx-jboss-beans.xml
===================================================================
--- trunk/server/src/etc/deploy/jmx-jboss-beans.xml (rev 0)
+++ trunk/server/src/etc/deploy/jmx-jboss-beans.xml 2010-04-01 14:56:48 UTC (rev 103437)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!--
+ Configure JSR-160 style JMX connector for use with jconsole and other remote access programs such as twiddle.
+
+ To invoke jconsole with this JMX connector, issue:
+ jconsole service:jmx:rmi:///jndi/rmi://hostname:rmiRegistryPort/jmxrmi
+ or
+ jconsole service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi
+
+ -->
+
+ <bean name="InitialContext" class="javax.naming.InitialContext"/>
+
+ <bean name="JMXConnector" class="org.jboss.system.server.jmx.JMXConnector">
+
+ <!-- configuration properties -->
+
+ <!-- specify the hostname that will run the JMX connector -->
+ <property name="hostname">${jboss.bind.address}</property>
+
+ <!-- specify the port that the JMX connector is looked up through (used in JMXServiceURL) -->
+ <property name="rmiRegistryPort" class="int">1090</property>
+
+ <!-- security domain name
+ <property name="securityDomain">java:/jaas/jmx-console</property>
+ -->
+
+ <!-- specify the mbean server that is used internally, this shouldn't be changed here. -->
+ <property name="mbeanServer" class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer" /></property>
+ <property name="context" class="javax.naming.InitialContext"><inject bean="InitialContext"/></property>
+ </bean>
+</deployment>
+
Added: trunk/system/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java (rev 0)
+++ trunk/system/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java 2010-04-01 14:56:48 UTC (rev 103437)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.system.server.jmx;
+
+import javax.management.remote.JMXConnectorFactory;
+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;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * RMIAdapter replacement using JMXConnector
+ * @author Scott Marlow smarlow at redhat.com
+ *
+ */
+public class JMXAdapter implements ObjectFactory {
+
+ public JMXAdapter() {
+
+ }
+
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
+ if ( obj != null && obj instanceof Reference) {
+ Reference ref = (Reference)obj;
+ // The JMXServiceURL points to the jmx server
+ RefAddr urlRef = ref.get("JMXServiceURL");
+ String url = (String)urlRef.getContent();
+ JMXServiceURL jmxserviceURL = new JMXServiceURL(url);
+ // TODO: security...
+ HashMap env = new HashMap();
+ javax.management.remote.JMXConnector jmxc = JMXConnectorFactory.connect(jmxserviceURL, env);
+ return jmxc.getMBeanServerConnection();
+ }
+ return null;
+ }
+}
Added: trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java (rev 0)
+++ trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java 2010-04-01 14:56:48 UTC (rev 103437)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.system.server.jmx;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.rmi.RMIConnectorServer;
+import javax.management.remote.rmi.RMIJRMPServerImpl;
+import javax.naming.InitialContext;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import java.lang.management.ManagementFactory;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.HashMap;
+
+/**
+ * setup JSR-160 JMXConnector
+ * @author Scott Marlow smarlow at redhat.com
+ *
+ */
+public class JMXConnector {
+
+ /* start of configurable settings */
+ private int rmiRegistryPort=1090; // create a RMI registry at this port
+ private String hostname= "localhost";
+ private static final String RMI_BIND_NAME = "jmxrmi";
+ private static final String JNDI_BIND_NAME = "jmx/invoker/RMIAdaptor";
+ private MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+ private InitialContext context;
+
+ /* end of configurable settings */
+ private RMIConnectorServer adapter;
+ private RMIJRMPServerImpl rmiServer;
+ private Registry registry;
+ private String securityDomain;
+ private static final Logger log = Logger.getLogger(JMXConnector.class);
+
+
+ public JMXConnector() {
+
+ }
+
+ public InitialContext getContext() {
+ return context;
+ }
+
+ public void setContext(InitialContext context) {
+ this.context = context;
+ }
+
+ public String getSecurityDomain() {
+ return securityDomain;
+ }
+
+ public void setSecurityDomain(String securityDomain) {
+ this.securityDomain = securityDomain;
+ }
+
+ public MBeanServer getMbeanServer() {
+ return mbeanServer;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer) {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public int getRmiRegistryPort() {
+ return rmiRegistryPort;
+ }
+
+ public void setRmiRegistryPort(int rmiRegistryPort) {
+ this.rmiRegistryPort = rmiRegistryPort;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public void start() throws Exception {
+ rmiServer = new RMIJRMPServerImpl( 0, null, null, new HashMap());
+ registry = LocateRegistry.createRegistry(rmiRegistryPort);
+ JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostname);
+ HashMap env = new HashMap();
+ adapter = new RMIConnectorServer(url, env, rmiServer, mbeanServer);
+ adapter.start();
+ url = adapter.getAddress();
+ registry.bind(RMI_BIND_NAME, rmiServer.toStub());
+
+ if(log.isDebugEnabled()) {
+ log.debug("started JMXConnector (" + url.toString() + ")");
+ }
+ // TODO: JBAS-7871
+ Reference reference = new Reference(MBeanServerConnection.class.getName(), JMXAdapter.class.getName(), null);
+ reference.add(new StringRefAddr("JMXServiceURL", url.toString()));
+ Util.rebind(context, JNDI_BIND_NAME, reference);
+ //Object test = Util.lookup(context, JNDI_BIND_NAME, MBeanServerConnection.class);
+ //log.info("test = " + test);
+ }
+
+ public void stop() throws Exception {
+ registry.unbind(RMI_BIND_NAME);
+ adapter.stop();
+ Util.unbind(context, JNDI_BIND_NAME);
+ }
+
+}
More information about the jboss-cvs-commits
mailing list