[jboss-cvs] JBossAS SVN: r105859 - in projects: jmx-connector and 20 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 9 08:45:09 EDT 2010
Author: smarlow at redhat.com
Date: 2010-06-09 08:45:08 -0400 (Wed, 09 Jun 2010)
New Revision: 105859
Added:
projects/jmx-connector/
projects/jmx-connector/jmxconnector-metadata/
projects/jmx-connector/jmxconnector-metadata/pom.xml
projects/jmx-connector/jmxconnector-metadata/src/
projects/jmx-connector/jmxconnector-metadata/src/main/
projects/jmx-connector/jmxconnector-metadata/src/main/java/
projects/jmx-connector/jmxconnector-metadata/src/main/java/org/
projects/jmx-connector/jmxconnector-metadata/src/main/java/org/jboss/
projects/jmx-connector/jmxconnector-metadata/src/main/java/org/jboss/jmxconnector/
projects/jmx-connector/jmxconnector-metadata/src/main/java/org/jboss/jmxconnector/metadata/
projects/jmx-connector/jmxconnector-metadata/src/main/java/org/jboss/jmxconnector/metadata/JMXConnectorMetaData.java
projects/jmx-connector/jmxconnector-metadata/src/main/resources/
projects/jmx-connector/jmxconnector-metadata/src/main/resources/schema/
projects/jmx-connector/jmxconnector-metadata/src/main/resources/schema/jmxconnector_1_0.xsd
projects/jmx-connector/jmxconnector/
projects/jmx-connector/jmxconnector/pom.xml
projects/jmx-connector/jmxconnector/src/
projects/jmx-connector/jmxconnector/src/main/
projects/jmx-connector/jmxconnector/src/main/java/
projects/jmx-connector/jmxconnector/src/main/java/org/
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnector.java
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnectorAuthenticator.java
projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/MBeanServerWrapper.java
projects/jmx-connector/jmxconnector/src/test/
projects/jmx-connector/jmxconnector/src/test/java/
projects/jmx-connector/pom.xml
Log:
move jsr-160 jmx connector into its own location
Added: projects/jmx-connector/jmxconnector/pom.xml
===================================================================
--- projects/jmx-connector/jmxconnector/pom.xml (rev 0)
+++ projects/jmx-connector/jmxconnector/pom.xml 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.jmxconnector</groupId>
+ <artifactId>jboss-jmxconnector</artifactId>
+ <version>1.0.Beta1</version>
+ <packaging>jar</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <!-- skip>true</skip -->
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <version>3.0.0.Beta2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.17.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.picketbox</groupId>
+ <artifactId>picketbox-bare</artifactId>
+ <version>3.0.0.Beta4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java
===================================================================
--- projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java (rev 0)
+++ projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXAdapter.java 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,106 @@
+/*
+ * 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.*;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * RMIAdapter replacement using JMXConnector
+ * @author Scott Marlow smarlow at redhat.com
+ *
+ */
+public class JMXAdapter implements ObjectFactory {
+ // cache the connection to the server so that we don't leak each new JMXConnector
+ private static Map<String,javax.management.remote.JMXConnector> jmxConnectorMap = new ConcurrentHashMap<String,javax.management.remote.JMXConnector>();
+
+ 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);
+ javax.management.remote.JMXConnector jmxc = null;
+ jmxc = jmxConnectorMap.get(url);
+
+ if(jmxc != null) {
+ try {
+ // attempt to detect that the cached connection is broken
+ jmxc.getConnectionId();
+ }
+ catch(IOException e) {
+ close(jmxc);
+ jmxc = null; // ignore the broken connection and get a new one
+ }
+ }
+
+ if(jmxc == null) {
+ jmxc = JMXConnectorFactory.connect(jmxserviceURL, new HashMap());
+ jmxConnectorMap.put(url, jmxc);
+ }
+ return jmxc.getMBeanServerConnection();
+ }
+ return null;
+ }
+
+ /**
+ * Can be called from the client side application to close all (JMXConnector) connections to the server.
+ * If new connections are obtained while current connections are being closed, the new connections will not
+ * be closed.
+ */
+ public static void closeAll() {
+ Collection<String> keys = jmxConnectorMap.keySet();
+ Collection<javax.management.remote.JMXConnector> values = jmxConnectorMap.values();
+ for (javax.management.remote.JMXConnector c : values) {
+ close(c);
+ }
+ for (String key : keys) {
+ jmxConnectorMap.remove(key);
+ }
+
+ }
+
+ private static void close(javax.management.remote.JMXConnector jmxc) {
+ try {
+ jmxc.close(); // clean up any local resources associated with the connection (e.g. background threads)
+ }
+ catch( IOException ignore)
+ {
+ }
+ }
+
+}
Added: projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnector.java
===================================================================
--- projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnector.java (rev 0)
+++ projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnector.java 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,196 @@
+/*
+ * 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.net.sockets.DefaultClientSocketFactory;
+import org.jboss.net.sockets.DefaultSocketFactory;
+import org.jboss.util.naming.Util;
+import org.picketbox.factories.SecurityFactory;
+
+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.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.rmi.NotBoundException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+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 int rmiServerPort=1091; // rmi server will listen on 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 static final String LEGACY_BIND_NAME = "jmx/rmi/RMIAdaptor";
+ private MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+ private InitialContext context;
+
+ private String securityDomain;
+
+ /* end of configurable settings */
+ private RMIConnectorServer adapter;
+ private RMIJRMPServerImpl rmiServer;
+ private Registry registry;
+ 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 int getRmiServerPort() {
+ return rmiServerPort;
+ }
+
+ public void setRmiServerPort(int rmiServerPort) {
+ this.rmiServerPort = rmiServerPort;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public void start() {
+ try {
+ if(log.isInfoEnabled()) {
+ log.info("starting JMXConnector on host " + hostname + ":" + rmiRegistryPort);
+ }
+ DefaultClientSocketFactory clientSocketFactory = new DefaultClientSocketFactory();
+ clientSocketFactory.setBindAddress(hostname);
+ DefaultSocketFactory serverSocketFactory = new DefaultSocketFactory();
+ serverSocketFactory.setBindAddress(hostname);
+ registry = LocateRegistry.createRegistry(rmiRegistryPort, clientSocketFactory, serverSocketFactory);
+ HashMap env = new HashMap();
+ if( securityDomain != null)
+ env.put(RMIConnectorServer.AUTHENTICATOR, new JMXConnectorAuthenticator( securityDomain) );
+ // note: don't pass clientSocketFactory to RMIJRMPServerImpl ctor or JBAS-7933 regression will occur.
+ rmiServer = new RMIJRMPServerImpl(rmiServerPort, null, serverSocketFactory, env);
+ JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostname);
+ adapter = new RMIConnectorServer(url, env, rmiServer, wrapMBeanServer(mbeanServer));
+ adapter.start();
+ url = adapter.getAddress();
+ registry.rebind(RMI_BIND_NAME, rmiServer.toStub());
+
+ if(log.isDebugEnabled()) {
+ log.debug("started JMXConnector (" + url.toString() + ")" +
+ (securityDomain!=null ? " domain=" + securityDomain : "") );
+ }
+
+ // For legacy access, bind a JMXAdapter to the JNDI names
+ 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);
+ Util.rebind(context, LEGACY_BIND_NAME, reference);
+ //Object test = Util.lookup(context, JNDI_BIND_NAME, MBeanServerConnection.class);
+ //log.info("test = " + test);
+ SecurityFactory.prepare();
+ } catch (IOException e) {
+ log.error("Could not start JMXConnector", e);
+ } catch (NamingException e) {
+ log.error("couldn't bind legacy adaptor (" +JNDI_BIND_NAME + " or " + LEGACY_BIND_NAME + ")", e);
+ }
+ }
+
+ public void stop() {
+ try {
+ registry.unbind(RMI_BIND_NAME);
+ Util.unbind(context, JNDI_BIND_NAME);
+ Util.unbind(context, LEGACY_BIND_NAME);
+ UnicastRemoteObject.unexportObject(registry, true);
+ log.info(this.getClass().getSimpleName() + " stopped");
+ } catch (NotBoundException e) {
+ log.error("connector was not bound ("+RMI_BIND_NAME+") to registry", e);
+ } catch (IOException e) {
+ log.error("couldn't unbind ("+RMI_BIND_NAME+") connector", e);
+ } catch (NamingException e) {
+ log.error("couldn't unbind legacy adaptor (" +JNDI_BIND_NAME + " or " + LEGACY_BIND_NAME + ")", e);
+ }
+ finally {
+ try {
+ SecurityFactory.release();
+ adapter.stop();
+ } catch (IOException e) {
+ log.error("Could not stop connector", e);
+ }
+ }
+ }
+
+ private MBeanServer wrapMBeanServer(MBeanServer mbServer) {
+ return new MBeanServerWrapper(mbServer);
+ }
+}
\ No newline at end of file
Added: projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnectorAuthenticator.java
===================================================================
--- projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnectorAuthenticator.java (rev 0)
+++ projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/JMXConnectorAuthenticator.java 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,96 @@
+/*
+ * 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.security.AuthenticationManager;
+import org.jboss.security.SecurityContext;
+import org.picketbox.factories.SecurityFactory;
+
+import javax.management.remote.JMXAuthenticator;
+import javax.management.remote.JMXPrincipal;
+import javax.security.auth.Subject;
+import java.security.Principal;
+
+/**
+ * Handles authentication checking for JSR-160 JMXConnector (using PicketBox)
+ * login-config.xml is expected to contain an application-policy for the specified
+ * securityDomainName.
+ *
+ * @author Scott Marlow smarlow at redhat.com
+ *
+ */
+
+class JMXConnectorAuthenticator implements JMXAuthenticator {
+
+ String securityDomainName;
+
+ JMXConnectorAuthenticator(String securityDomainName)
+ {
+ this.securityDomainName = securityDomainName;
+ }
+
+ /**
+ * @inheritDoc
+ *
+ */
+ public synchronized Subject authenticate(Object creds) {
+ AuthenticationManager am;
+ SecurityContext securityContext;
+
+ // wine and complain if we don't get what we expect.
+ if (creds == null) {
+ throw new SecurityException(
+ "JMXConnectorAuthenticator requires userid/password credentials to be passed in");
+ }
+ if (! (creds instanceof String[])) {
+ // only support passing in array of Strings
+ throw new SecurityException(
+ "JMXConnectorAuthenticator can only handle authentication parameter that is array of two strings, instead got " +
+ creds.getClass().getName());
+ }
+ String[] pair = (String[]) creds;
+ if( pair.length != 2 ) {
+ // only support passing userid + password
+ throw new SecurityException(
+ "JMXConnectorAuthenticator can only handle authentication parameter that is array of two strings, instead got " +
+ pair.length +" strings");
+ }
+
+ String user, pass;
+ user = pair[0];
+ pass = pair[1];
+ Principal principal = new JMXPrincipal(user);
+ Subject subject = new Subject();
+
+ securityContext = SecurityFactory.establishSecurityContext(securityDomainName);
+ am = securityContext.getAuthenticationManager();
+
+ boolean result = am.isValid(principal, pass , subject);
+ if( result ) {
+ subject.setReadOnly();
+ }
+ else {
+ throw new SecurityException("user authentication check failed");
+ }
+ return subject;
+ }
+}
\ No newline at end of file
Added: projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/MBeanServerWrapper.java
===================================================================
--- projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/MBeanServerWrapper.java (rev 0)
+++ projects/jmx-connector/jmxconnector/src/main/java/org/jboss/system/server/jmx/MBeanServerWrapper.java 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,234 @@
+/*
+ * 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.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.MBeanAttributeInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.OperationsException;
+import javax.management.QueryExp;
+import javax.management.ReflectionException;
+import javax.management.loading.ClassLoaderRepository;
+import java.io.ObjectInputStream;
+import java.util.Set;
+
+
+/**
+ * wrap the MBeanServer and minimize NotSerializableException
+ *
+ * @author Scott Marlow smarlow at redhat.com
+ *
+ */
+public class MBeanServerWrapper implements MBeanServer {
+
+ private MBeanServer x;
+
+ public MBeanServerWrapper( MBeanServer delegateTo) {
+ this.x = delegateTo;
+ }
+
+ public MBeanInfo getMBeanInfo(ObjectName name)
+ throws InstanceNotFoundException, IntrospectionException, ReflectionException {
+
+ MBeanInfo info = x.getMBeanInfo(name);
+ return new MBeanInfo(
+ info.getClassName(),
+ info.getDescription(),
+ deepCopy(info.getAttributes()), // Strip the Descriptors
+ info.getConstructors(),
+ info.getOperations(),
+ info.getNotifications());
+ }
+
+ public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
+ return x.createMBean(className, name);
+ }
+
+ public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException {
+ return x.createMBean(className, name, loaderName);
+ }
+
+ public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
+ return x.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 {
+ return x.createMBean(className, name, loaderName, params, signature);
+ }
+
+ public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
+ return x.registerMBean(object, name);
+ }
+
+ public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException {
+ x.unregisterMBean(name);
+ }
+
+ public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException {
+ return x.getObjectInstance(name);
+ }
+
+ public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
+ return x.queryMBeans(name, query);
+ }
+
+ public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
+ return x.queryNames(name, query);
+ }
+
+ public boolean isRegistered(ObjectName name) {
+ return x.isRegistered(name);
+ }
+
+ public Integer getMBeanCount() {
+ return x.getMBeanCount();
+ }
+
+ public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
+ return x.getAttribute(name, attribute);
+ }
+
+ public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException {
+ return x.getAttributes(name, attributes);
+ }
+
+ public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
+ x.setAttribute(name, attribute);
+ }
+
+ public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException {
+ return x.setAttributes(name, attributes);
+ }
+
+ public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException {
+ return x.invoke(name, operationName, params, signature);
+ }
+
+ public String getDefaultDomain() {
+ return x.getDefaultDomain();
+ }
+
+ public String[] getDomains() {
+ return x.getDomains();
+ }
+
+ public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException {
+ x.addNotificationListener(name, listener, filter, handback);
+ }
+
+ public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException {
+ x.addNotificationListener(name, listener, filter, handback);
+ }
+
+ public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException {
+ x.removeNotificationListener(name, listener);
+ }
+
+ public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException {
+ x.removeNotificationListener(name, listener, filter, handback);
+ }
+
+ public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException {
+ x.removeNotificationListener(name, listener);
+ }
+
+ public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException {
+ x.removeNotificationListener(name, listener, filter, handback);
+ }
+
+
+ public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException {
+ return x.isInstanceOf(name, className);
+ }
+
+ public Object instantiate(String className) throws ReflectionException, MBeanException {
+ return x.instantiate(className);
+ }
+
+ public Object instantiate(String className, ObjectName loaderName) throws ReflectionException, MBeanException, InstanceNotFoundException {
+ return x.instantiate(className, loaderName);
+ }
+
+ public Object instantiate(String className, Object[] params, String[] signature) throws ReflectionException, MBeanException {
+ return x.instantiate(className, params, signature);
+ }
+
+ public Object instantiate(String className, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, MBeanException, InstanceNotFoundException {
+ return x.instantiate(className, loaderName, params, signature);
+ }
+
+ public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, OperationsException {
+ return x.deserialize(name, data);
+ }
+
+ public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException {
+ return x.deserialize(className, data);
+ }
+
+ public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, ReflectionException {
+ return x.deserialize(className, loaderName, data);
+ }
+
+ public ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException {
+ return x.getClassLoaderFor(mbeanName);
+ }
+
+ public ClassLoader getClassLoader(ObjectName loaderName) throws InstanceNotFoundException {
+ return x.getClassLoader(loaderName);
+ }
+
+ public ClassLoaderRepository getClassLoaderRepository() {
+ return x.getClassLoaderRepository();
+ }
+
+ private MBeanAttributeInfo[] deepCopy(MBeanAttributeInfo[] attrs)
+ {
+ MBeanAttributeInfo[] copy = new MBeanAttributeInfo[attrs.length];
+ for (int i = 0; i < attrs.length; i++)
+ {
+ MBeanAttributeInfo attr = attrs[i];
+ copy[i] = new MBeanAttributeInfo(
+ attr.getName(),
+ attr.getType(),
+ attr.getDescription(),
+ attr.isReadable(),
+ attr.isWritable(),
+ attr.isIs());
+ }
+ return copy;
+ }
+}
Added: projects/jmx-connector/jmxconnector-metadata/pom.xml
===================================================================
--- projects/jmx-connector/jmxconnector-metadata/pom.xml (rev 0)
+++ projects/jmx-connector/jmxconnector-metadata/pom.xml 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.jmxconnector</groupId>
+ <artifactId>jboss-jmxconnector-metadata</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0.Beta1</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.jmxconnector</groupId>
+ <artifactId>jboss-jmxconnector</artifactId>
+ <version>1.0.Beta1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>2.0.9.GA</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-aop-mc-int</artifactId>
+ <version>2.0.9.GA</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <finalName>jboss-jmxconnector-metadata</finalName>
+ </build>
+ <distributionManagement>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Maven2 Repository</name>
+ <url>http://repository.jboss.org/maven2</url>
+ </repository>
+ </distributionManagement>
+</project>
Added: projects/jmx-connector/jmxconnector-metadata/src/main/java/org/jboss/jmxconnector/metadata/JMXConnectorMetaData.java
===================================================================
--- projects/jmx-connector/jmxconnector-metadata/src/main/java/org/jboss/jmxconnector/metadata/JMXConnectorMetaData.java (rev 0)
+++ projects/jmx-connector/jmxconnector-metadata/src/main/java/org/jboss/jmxconnector/metadata/JMXConnectorMetaData.java 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jmxconnector.metadata;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+import javax.xml.bind.annotation.*;
+import java.io.Serializable;
+import java.lang.String;
+import java.util.List;
+
+/**
+ *
+ */
+ at XmlRootElement(name="JMXConnector", namespace="urn:jboss:jmxconnector:1.0")
+ at JBossXmlSchema(namespace="urn:jboss:jmxconnector:1.0", elementFormDefault= XmlNsForm.QUALIFIED)
+ at XmlType(
+ name="JMXConnector",
+ namespace="urn:jboss:jmxconnector:1.0"
+)
+public class JMXConnectorMetaData extends JBossObject implements Serializable
+{
+ private String securityDomain;
+ private String hostname;
+ private int rmiRegistryPort;
+ private int rmiServerPort;
+
+ public String getSecurityDomain() {
+ return securityDomain;
+ }
+
+ @XmlAttribute(required = false)
+ public void setSecurityDomain(String securityDomain) {
+ this.securityDomain = securityDomain;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ @XmlAttribute(required = false)
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public int getRmiRegistryPort() {
+ return rmiRegistryPort;
+ }
+
+ @XmlAttribute(required = false)
+ public void setRmiRegistryPort(int rmiRegistryPort) {
+ this.rmiRegistryPort = rmiRegistryPort;
+ }
+
+ public int getRmiServerPort() {
+ return rmiServerPort;
+ }
+
+ @XmlAttribute(required = false)
+ public void setRmiServerPort(int rmiServerPort) {
+ this.rmiServerPort = rmiServerPort;
+ }
+
+
+}
+
Added: projects/jmx-connector/jmxconnector-metadata/src/main/resources/schema/jmxconnector_1_0.xsd
===================================================================
--- projects/jmx-connector/jmxconnector-metadata/src/main/resources/schema/jmxconnector_1_0.xsd (rev 0)
+++ projects/jmx-connector/jmxconnector-metadata/src/main/resources/schema/jmxconnector_1_0.xsd 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ 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.
+ -->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ targetNamespace="urn:jboss:jmxconnector:1.0"
+ xmlns="urn:jboss:jmxconnector:1.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:element name="JMXConnector"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="securityDomain" type="xsd:string"/>
+ <xsd:element name="hostname" type="xsd:string"/>
+ <xsd:element name="rmiRegistryPort" type="xsd:integer"/>
+ <xsd:element name="rmiServerPort" type="xsd:integer"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+
Added: projects/jmx-connector/pom.xml
===================================================================
--- projects/jmx-connector/pom.xml (rev 0)
+++ projects/jmx-connector/pom.xml 2010-06-09 12:45:08 UTC (rev 105859)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.jboss.jmxconnector</groupId>
+ <artifactId>jmxconnector-all</artifactId>
+ <version>1.0.Beta1</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>jmxconnector</module>
+ <module>jmxconnector-metadata</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <!-- skip>true</skip -->
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <version>3.0.0.Beta2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.17.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.picketbox</groupId>
+ <artifactId>picketbox-bare</artifactId>
+ <version>3.0.0.Beta4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
More information about the jboss-cvs-commits
mailing list