|
From: <ls...@us...> - 2007-09-08 12:03:28
|
Revision: 3468
http://jnode.svn.sourceforge.net/jnode/?rev=3468&view=rev
Author: lsantha
Date: 2007-09-08 05:03:26 -0700 (Sat, 08 Sep 2007)
Log Message:
-----------
openjdk integration
Added Paths:
-----------
trunk/core/src/openjdk/com/com/sun/jmx/
trunk/core/src/openjdk/com/com/sun/jmx/defaults/
trunk/core/src/openjdk/com/com/sun/jmx/defaults/JmxProperties.java
trunk/core/src/openjdk/com/com/sun/jmx/defaults/ServiceName.java
trunk/core/src/openjdk/com/com/sun/jmx/defaults/package.html
trunk/core/src/openjdk/com/com/sun/jmx/interceptor/
trunk/core/src/openjdk/com/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
trunk/core/src/openjdk/com/com/sun/jmx/interceptor/MBeanServerInterceptor.java
trunk/core/src/openjdk/com/com/sun/jmx/interceptor/package.html
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/ConvertingMethod.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/DescriptorCache.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/DynamicMBean2.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/GetPropertyAction.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/Introspector.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/JmxMBeanServer.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/JmxMBeanServerBuilder.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MBeanAnalyzer.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MBeanInstantiator.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MBeanIntrospector.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MBeanServerDelegateImpl.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MBeanSupport.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MXBeanIntrospector.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MXBeanLookup.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MXBeanProxy.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/MXBeanSupport.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/ModifiableClassLoaderRepository.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/NamedObject.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/OpenConverter.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/PerInterface.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/Repository.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/SecureClassLoaderRepository.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/StandardMBeanSupport.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/SunJmxMBeanServer.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/Util.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/WeakIdentityHashMap.java
trunk/core/src/openjdk/com/com/sun/jmx/mbeanserver/package.html
trunk/core/src/openjdk/com/com/sun/jmx/remote/
trunk/core/src/openjdk/com/com/sun/jmx/remote/util/
trunk/core/src/openjdk/com/com/sun/jmx/remote/util/CacheMap.java
trunk/core/src/openjdk/com/com/sun/jmx/remote/util/ClassLoaderWithRepository.java
trunk/core/src/openjdk/com/com/sun/jmx/remote/util/ClassLogger.java
trunk/core/src/openjdk/com/com/sun/jmx/remote/util/EnvHelp.java
trunk/core/src/openjdk/com/com/sun/jmx/remote/util/OrderClassLoaders.java
trunk/core/src/openjdk/com/com/sun/jmx/remote/util/Service.java
trunk/core/src/openjdk/com/com/sun/management/
trunk/core/src/openjdk/com/com/sun/management/VMOption.java
trunk/core/src/openjdk/java/java/lang/instrument/
trunk/core/src/openjdk/java/java/lang/instrument/ClassDefinition.java
trunk/core/src/openjdk/java/java/lang/instrument/ClassFileTransformer.java
trunk/core/src/openjdk/java/java/lang/instrument/IllegalClassFormatException.java
trunk/core/src/openjdk/java/java/lang/instrument/Instrumentation.java
trunk/core/src/openjdk/java/java/lang/instrument/UnmodifiableClassException.java
trunk/core/src/openjdk/java/java/lang/instrument/package.html
trunk/core/src/openjdk/java/java/lang/management/
trunk/core/src/openjdk/java/java/lang/management/ClassLoadingMXBean.java
trunk/core/src/openjdk/java/java/lang/management/CompilationMXBean.java
trunk/core/src/openjdk/java/java/lang/management/GarbageCollectorMXBean.java
trunk/core/src/openjdk/java/java/lang/management/LockInfo.java
trunk/core/src/openjdk/java/java/lang/management/ManagementPermission.java
trunk/core/src/openjdk/java/java/lang/management/MemoryMXBean.java
trunk/core/src/openjdk/java/java/lang/management/MemoryManagerMXBean.java
trunk/core/src/openjdk/java/java/lang/management/MemoryNotificationInfo.java
trunk/core/src/openjdk/java/java/lang/management/MemoryPoolMXBean.java
trunk/core/src/openjdk/java/java/lang/management/MemoryType.java
trunk/core/src/openjdk/java/java/lang/management/MonitorInfo.java
trunk/core/src/openjdk/java/java/lang/management/OperatingSystemMXBean.java
trunk/core/src/openjdk/java/java/lang/management/RuntimeMXBean.java
trunk/core/src/openjdk/java/java/lang/management/ThreadMXBean.java
trunk/core/src/openjdk/java/java/lang/reflect/
trunk/core/src/openjdk/java/java/lang/reflect/AnnotatedElement.java
trunk/core/src/openjdk/java/java/lang/reflect/GenericArrayType.java
trunk/core/src/openjdk/java/java/lang/reflect/GenericDeclaration.java
trunk/core/src/openjdk/java/java/lang/reflect/GenericSignatureFormatError.java
trunk/core/src/openjdk/java/java/lang/reflect/InvocationHandler.java
trunk/core/src/openjdk/java/java/lang/reflect/InvocationTargetException.java
trunk/core/src/openjdk/java/java/lang/reflect/MalformedParameterizedTypeException.java
trunk/core/src/openjdk/java/java/lang/reflect/Member.java
trunk/core/src/openjdk/java/java/lang/reflect/ParameterizedType.java
trunk/core/src/openjdk/java/java/lang/reflect/Type.java
trunk/core/src/openjdk/java/java/lang/reflect/TypeVariable.java
trunk/core/src/openjdk/java/java/lang/reflect/UndeclaredThrowableException.java
trunk/core/src/openjdk/java/java/lang/reflect/WildcardType.java
trunk/core/src/openjdk/java/java/lang/reflect/package-info.java
trunk/core/src/openjdk/javax/javax/management/
trunk/core/src/openjdk/javax/javax/management/Descriptor.java
trunk/core/src/openjdk/javax/javax/management/DescriptorKey.java
trunk/core/src/openjdk/javax/javax/management/DescriptorRead.java
trunk/core/src/openjdk/javax/javax/management/ImmutableDescriptor.java
trunk/core/src/openjdk/javax/javax/management/JMX.java
trunk/core/src/openjdk/javax/javax/management/MBeanAttributeInfo.java
trunk/core/src/openjdk/javax/javax/management/MBeanConstructorInfo.java
trunk/core/src/openjdk/javax/javax/management/MBeanFeatureInfo.java
trunk/core/src/openjdk/javax/javax/management/MBeanInfo.java
trunk/core/src/openjdk/javax/javax/management/MBeanNotificationInfo.java
trunk/core/src/openjdk/javax/javax/management/MBeanOperationInfo.java
trunk/core/src/openjdk/javax/javax/management/MBeanParameterInfo.java
trunk/core/src/openjdk/javax/javax/management/MBeanServer.java
trunk/core/src/openjdk/javax/javax/management/MBeanServerConnection.java
trunk/core/src/openjdk/javax/javax/management/MBeanServerDelegate.java
trunk/core/src/openjdk/javax/javax/management/MBeanServerInvocationHandler.java
trunk/core/src/openjdk/javax/javax/management/MXBean.java
trunk/core/src/openjdk/javax/javax/management/NotificationBroadcasterSupport.java
trunk/core/src/openjdk/javax/javax/management/ObjectName.java
trunk/core/src/openjdk/javax/javax/management/StandardEmitterMBean.java
trunk/core/src/openjdk/javax/javax/management/StandardMBean.java
trunk/core/src/openjdk/javax/javax/management/loading/
trunk/core/src/openjdk/javax/javax/management/loading/PrivateClassLoader.java
trunk/core/src/openjdk/javax/javax/management/openmbean/
trunk/core/src/openjdk/javax/javax/management/openmbean/ArrayType.java
trunk/core/src/openjdk/javax/javax/management/openmbean/CompositeDataInvocationHandler.java
trunk/core/src/openjdk/javax/javax/management/openmbean/CompositeDataView.java
trunk/core/src/openjdk/javax/javax/management/openmbean/CompositeType.java
trunk/core/src/openjdk/javax/javax/management/openmbean/OpenMBeanAttributeInfo.java
trunk/core/src/openjdk/javax/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
trunk/core/src/openjdk/javax/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java
trunk/core/src/openjdk/javax/javax/management/openmbean/OpenMBeanOperationInfoSupport.java
trunk/core/src/openjdk/javax/javax/management/openmbean/OpenMBeanParameterInfo.java
trunk/core/src/openjdk/javax/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
trunk/core/src/openjdk/javax/javax/management/openmbean/OpenType.java
trunk/core/src/openjdk/javax/javax/management/openmbean/SimpleType.java
trunk/core/src/openjdk/javax/javax/management/remote/
trunk/core/src/openjdk/javax/javax/management/remote/JMXConnector.java
trunk/core/src/openjdk/javax/javax/management/remote/JMXConnectorFactory.java
trunk/core/src/openjdk/javax/javax/management/remote/JMXConnectorProvider.java
trunk/core/src/openjdk/javax/javax/management/remote/JMXConnectorServerFactory.java
trunk/core/src/openjdk/javax/javax/management/remote/JMXProviderException.java
trunk/core/src/openjdk/javax/javax/management/remote/JMXServiceURL.java
trunk/core/src/openjdk/sun/sun/management/
trunk/core/src/openjdk/sun/sun/management/LazyCompositeData.java
trunk/core/src/openjdk/sun/sun/management/LockDataConverter.java
trunk/core/src/openjdk/sun/sun/management/LockDataConverterMXBean.java
trunk/core/src/openjdk/sun/sun/management/MappedMXBeanType.java
trunk/core/src/openjdk/sun/sun/management/MemoryNotifInfoCompositeData.java
trunk/core/src/openjdk/sun/sun/management/MemoryUsageCompositeData.java
trunk/core/src/openjdk/sun/sun/management/MonitorInfoCompositeData.java
trunk/core/src/openjdk/sun/sun/management/StackTraceElementCompositeData.java
trunk/core/src/openjdk/sun/sun/management/ThreadInfoCompositeData.java
trunk/core/src/openjdk/sun/sun/management/Util.java
trunk/core/src/openjdk/sun/sun/management/VMOptionCompositeData.java
trunk/core/src/openjdk/vm/java/lang/NativeRuntime.java
trunk/core/src/openjdk/vm/java/lang/NativeSystem.java
Added: trunk/core/src/openjdk/com/com/sun/jmx/defaults/JmxProperties.java
===================================================================
--- trunk/core/src/openjdk/com/com/sun/jmx/defaults/JmxProperties.java (rev 0)
+++ trunk/core/src/openjdk/com/com/sun/jmx/defaults/JmxProperties.java 2007-09-08 12:03:26 UTC (rev 3468)
@@ -0,0 +1,232 @@
+/*
+ * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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 General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.jmx.defaults;
+
+import java.util.logging.Logger;
+
+/**
+ * This contains the property list defined for this
+ * JMX implementation.
+ *
+ *
+ * @since 1.5
+ */
+public class JmxProperties {
+
+ // private constructor defined to "hide" the default public constructor
+ private JmxProperties() {
+ }
+
+ // PUBLIC STATIC CONSTANTS
+ //------------------------
+
+ /**
+ * References the property that specifies the directory where
+ * the native libraries will be stored before the MLet Service
+ * loads them into memory.
+ * <p>
+ * Property Name: <B>jmx.mlet.library.dir</B>
+ */
+ public static final String JMX_INITIAL_BUILDER =
+ "javax.management.builder.initial";
+
+ /**
+ * References the property that specifies the directory where
+ * the native libraries will be stored before the MLet Service
+ * loads them into memory.
+ * <p>
+ * Property Name: <B>jmx.mlet.library.dir</B>
+ */
+ public static final String MLET_LIB_DIR = "jmx.mlet.library.dir";
+
+ /**
+ * References the property that specifies the full name of the JMX
+ * specification implemented by this product.
+ * <p>
+ * Property Name: <B>jmx.specification.name</B>
+ */
+ public static final String JMX_SPEC_NAME = "jmx.specification.name";
+
+ /**
+ * References the property that specifies the version of the JMX
+ * specification implemented by this product.
+ * <p>
+ * Property Name: <B>jmx.specification.version</B>
+ */
+ public static final String JMX_SPEC_VERSION = "jmx.specification.version";
+
+ /**
+ * References the property that specifies the vendor of the JMX
+ * specification implemented by this product.
+ * <p>
+ * Property Name: <B>jmx.specification.vendor</B>
+ */
+ public static final String JMX_SPEC_VENDOR = "jmx.specification.vendor";
+
+ /**
+ * References the property that specifies the full name of this product
+ * implementing the JMX specification.
+ * <p>
+ * Property Name: <B>jmx.implementation.name</B>
+ */
+ public static final String JMX_IMPL_NAME = "jmx.implementation.name";
+
+ /**
+ * References the property that specifies the name of the vendor of this
+ * product implementing the JMX specification.
+ * <p>
+ * Property Name: <B>jmx.implementation.vendor</B>
+ */
+ public static final String JMX_IMPL_VENDOR = "jmx.implementation.vendor";
+
+ /**
+ * References the property that specifies the version of this product
+ * implementing the JMX specification.
+ * <p>
+ * Property Name: <B>jmx.implementation.version</B>
+ */
+ public static final String JMX_IMPL_VERSION = "jmx.implementation.version";
+
+ /**
+ * Logger name for MBean Server information.
+ */
+ public static final String MBEANSERVER_LOGGER_NAME =
+ "javax.management.mbeanserver";
+
+ /**
+ * Logger for MBean Server information.
+ */
+ public static final Logger MBEANSERVER_LOGGER =
+ Logger.getLogger(MBEANSERVER_LOGGER_NAME);
+
+ /**
+ * Logger name for MLet service information.
+ */
+ public static final String MLET_LOGGER_NAME =
+ "javax.management.mlet";
+
+ /**
+ * Logger for MLet service information.
+ */
+ public static final Logger MLET_LOGGER =
+ Logger.getLogger(MLET_LOGGER_NAME);
+
+ /**
+ * Logger name for Monitor information.
+ */
+ public static final String MONITOR_LOGGER_NAME =
+ "javax.management.monitor";
+
+ /**
+ * Logger for Monitor information.
+ */
+ public static final Logger MONITOR_LOGGER =
+ Logger.getLogger(MONITOR_LOGGER_NAME);
+
+ /**
+ * Logger name for Timer information.
+ */
+ public static final String TIMER_LOGGER_NAME =
+ "javax.management.timer";
+
+ /**
+ * Logger for Timer information.
+ */
+ public static final Logger TIMER_LOGGER =
+ Logger.getLogger(TIMER_LOGGER_NAME);
+
+ /**
+ * Logger name for Event Management information.
+ */
+ public static final String NOTIFICATION_LOGGER_NAME =
+ "javax.management.notification";
+
+ /**
+ * Logger for Event Management information.
+ */
+ public static final Logger NOTIFICATION_LOGGER =
+ Logger.getLogger(NOTIFICATION_LOGGER_NAME);
+
+ /**
+ * Logger name for Relation Service.
+ */
+ public static final String RELATION_LOGGER_NAME =
+ "javax.management.relation";
+
+ /**
+ * Logger for Relation Service.
+ */
+ public static final Logger RELATION_LOGGER =
+ Logger.getLogger(RELATION_LOGGER_NAME);
+
+ /**
+ * Logger name for Model MBean.
+ */
+ public static final String MODELMBEAN_LOGGER_NAME =
+ "javax.management.modelmbean";
+
+ /**
+ * Logger for Model MBean.
+ */
+ public static final Logger MODELMBEAN_LOGGER =
+ Logger.getLogger(MODELMBEAN_LOGGER_NAME);
+
+ /**
+ * Logger name for all other JMX classes.
+ */
+ public static final String MISC_LOGGER_NAME =
+ "javax.management.misc";
+
+ /**
+ * Logger for all other JMX classes.
+ */
+ public static final Logger MISC_LOGGER =
+ Logger.getLogger(MISC_LOGGER_NAME);
+
+ /**
+ * Logger name for SNMP.
+ */
+ public static final String SNMP_LOGGER_NAME =
+ "javax.management.snmp";
+
+ /**
+ * Logger for SNMP.
+ */
+ public static final Logger SNMP_LOGGER =
+ Logger.getLogger(SNMP_LOGGER_NAME);
+
+ /**
+ * Logger name for SNMP Adaptor.
+ */
+ public static final String SNMP_ADAPTOR_LOGGER_NAME =
+ "javax.management.snmp.daemon";
+
+ /**
+ * Logger for SNMP Adaptor.
+ */
+ public static final Logger SNMP_ADAPTOR_LOGGER =
+ Logger.getLogger(SNMP_ADAPTOR_LOGGER_NAME);
+}
Added: trunk/core/src/openjdk/com/com/sun/jmx/defaults/ServiceName.java
===================================================================
--- trunk/core/src/openjdk/com/com/sun/jmx/defaults/ServiceName.java (rev 0)
+++ trunk/core/src/openjdk/com/com/sun/jmx/defaults/ServiceName.java 2007-09-08 12:03:26 UTC (rev 3468)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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 General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.jmx.defaults;
+
+/**
+ * Used for storing default values used by JMX services.
+ *
+ * @since 1.5
+ */
+public class ServiceName {
+
+ // private constructor defined to "hide" the default public constructor
+ private ServiceName() {
+ }
+
+ /**
+ * The object name of the MBeanServer delegate object
+ * <BR>
+ * The value is <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.
+ */
+ public static final String DELEGATE =
+ "JMImplementation:type=MBeanServerDelegate" ;
+
+ /**
+ * The default key properties for registering the class loader of the
+ * MLet service.
+ * <BR>
+ * The value is <CODE>type=MLet</CODE>.
+ */
+ public static final String MLET = "type=MLet";
+
+ /**
+ * The default domain.
+ * <BR>
+ * The value is <CODE>DefaultDomain</CODE>.
+ */
+ public static final String DOMAIN = "DefaultDomain";
+
+ /**
+ * The name of the JMX specification implemented by this product.
+ * <BR>
+ * The value is <CODE>Java Management Extensions</CODE>.
+ */
+ public static final String JMX_SPEC_NAME = "Java Management Extensions";
+
+ /**
+ * The version of the JMX specification implemented by this product.
+ * <BR>
+ * The value is <CODE>1.4</CODE>.
+ */
+ public static final String JMX_SPEC_VERSION = "1.4";
+
+ /**
+ * The vendor of the JMX specification implemented by this product.
+ * <BR>
+ * The value is <CODE>Sun Microsystems</CODE>.
+ */
+ public static final String JMX_SPEC_VENDOR = "Sun Microsystems";
+
+ /**
+ * The name of this product implementing the JMX specification.
+ * <BR>
+ * The value is <CODE>JMX</CODE>.
+ */
+ public static final String JMX_IMPL_NAME = "JMX";
+
+ /**
+ * The name of the vendor of this product implementing the
+ * JMX specification.
+ * <BR>
+ * The value is <CODE>Sun Microsystems</CODE>.
+ */
+ public static final String JMX_IMPL_VENDOR = "Sun Microsystems";
+}
Added: trunk/core/src/openjdk/com/com/sun/jmx/defaults/package.html
===================================================================
--- trunk/core/src/openjdk/com/com/sun/jmx/defaults/package.html (rev 0)
+++ trunk/core/src/openjdk/com/com/sun/jmx/defaults/package.html 2007-09-08 12:03:26 UTC (rev 3468)
@@ -0,0 +1,33 @@
+<html>
+<head>
+<title>jmx.defaults package</title>
+<!--
+
+Copyright 2002-2003 Sun Microsystems, Inc. All Rights Reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 only, as
+published by the Free Software Foundation. Sun designates this
+particular file as subject to the "Classpath" exception as provided
+by Sun in the LICENSE file that accompanied this code.
+
+This code 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 General Public License
+version 2 for more details (a copy is included in the LICENSE file that
+accompanied this code).
+
+You should have received a copy of the GNU General Public License version
+2 along with this work; if not, write to the Free Software Foundation,
+Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+CA 95054 USA or visit www.sun.com if you need additional information or
+have any questions.
+-->
+</head>
+<body bgcolor="white">
+ Provides specific classes to <B>Sun JMX Reference Implementation</B>.
+</BODY>
+</HTML>
Added: trunk/core/src/openjdk/com/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
===================================================================
--- trunk/core/src/openjdk/com/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java (rev 0)
+++ trunk/core/src/openjdk/com/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java 2007-09-08 12:03:26 UTC (rev 3468)
@@ -0,0 +1,1872 @@
+/*
+ * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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 General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.jmx.interceptor;
+
+// java import
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.WeakHashMap;
+import java.lang.ref.WeakReference;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.security.AccessControlContext;
+import java.security.Permission;
+import java.security.ProtectionDomain;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+// JMX import
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.JMException;
+import javax.management.JMRuntimeException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanPermission;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerDelegate;
+import javax.management.MBeanServerNotification;
+import javax.management.MBeanTrustPermission;
+import javax.management.NotCompliantMBeanException;
+import javax.management.Notification;
+import javax.management.NotificationBroadcaster;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.QueryEval;
+import javax.management.QueryExp;
+import javax.management.ReflectionException;
+import javax.management.RuntimeErrorException;
+import javax.management.RuntimeMBeanException;
+import javax.management.RuntimeOperationsException;
+
+// JMX RI
+import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
+import com.sun.jmx.mbeanserver.DynamicMBean2;
+import com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository;
+import com.sun.jmx.mbeanserver.MBeanInstantiator;
+import com.sun.jmx.mbeanserver.MXBeanSupport;
+import com.sun.jmx.mbeanserver.Repository;
+import com.sun.jmx.mbeanserver.NamedObject;
+import com.sun.jmx.defaults.ServiceName;
+import com.sun.jmx.mbeanserver.Introspector;
+import com.sun.jmx.remote.util.EnvHelp;
+
+/**
+ * This is the default class for MBean manipulation on the agent side. It
+ * contains the methods necessary for the creation, registration, and
+ * deletion of MBeans as well as the access methods for registered MBeans.
+ * This is the core component of the JMX infrastructure.
+ * <P>
+ * Every MBean which is added to the MBean server becomes manageable: its attributes and operations
+ * become remotely accessible through the connectors/adaptors connected to that MBean server.
+ * A Java object cannot be registered in the MBean server unless it is a JMX compliant MBean.
+ * <P>
+ * When an MBean is registered or unregistered in the MBean server an
+ * {@link javax.management.MBeanServerNotification MBeanServerNotification}
+ * Notification is emitted. To register an object as listener to MBeanServerNotifications
+ * you should call the MBean server method {@link #addNotificationListener addNotificationListener} with <CODE>ObjectName</CODE>
+ * the <CODE>ObjectName</CODE> of the {@link javax.management.MBeanServerDelegate MBeanServerDelegate}.
+ * This <CODE>ObjectName</CODE> is:
+ * <BR>
+ * <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.
+ *
+ * @since 1.5
+ */
+public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
+
+ /** The MBeanInstantiator object used by the
+ * DefaultMBeanServerInterceptor */
+ private final transient MBeanInstantiator instantiator;
+
+ /** The MBean server object that is associated to the
+ * DefaultMBeanServerInterceptor */
+ private transient MBeanServer server = null;
+
+ /** The MBean server object taht associated to the
+ * DefaultMBeanServerInterceptor */
+ private final transient MBeanServerDelegate delegate;
+
+ /** The Repository object used by the DefaultMBeanServerInterceptor */
+ private final transient Repository repository;
+
+ /** Wrappers for client listeners. */
+ /* See the comment before addNotificationListener below. */
+ private final transient
+ WeakHashMap<ListenerWrapper, WeakReference<ListenerWrapper>>
+ listenerWrappers =
+ new WeakHashMap<ListenerWrapper,
+ WeakReference<ListenerWrapper>>();
+
+ /** The default domain of the object names */
+ private final String domain;
+
+ /** True if the repository perform queries, false otherwise */
+ private boolean queryByRepo;
+
+ /** The sequence number identifyng the notifications sent */
+ // Now sequence number is handled by MBeanServerDelegate.
+ // private int sequenceNumber=0;
+
+ /**
+ * Creates a DefaultMBeanServerInterceptor with the specified
+ * repository instance.
+ * <p>Do not forget to call <code>initialize(outer,delegate)</code>
+ * before using this object.
+ * @param outer A pointer to the MBeanServer object that must be
+ * passed to the MBeans when invoking their
+ * {@link javax.management.MBeanRegistration} interface.
+ * @param delegate A pointer to the MBeanServerDelegate associated
+ * with the new MBeanServer. The new MBeanServer must register
+ * this MBean in its MBean repository.
+ * @param instantiator The MBeanInstantiator that will be used to
+ * instantiate MBeans and take care of class loading issues.
+ * @param repository The repository to use for this MBeanServer.
+ */
+ public DefaultMBeanServerInterceptor(MBeanServer outer,
+ MBeanServerDelegate delegate,
+ MBeanInstantiator instantiator,
+ Repository repository) {
+ if (outer == null) throw new
+ IllegalArgumentException("outer MBeanServer cannot be null");
+ if (delegate == null) throw new
+ IllegalArgumentException("MBeanServerDelegate cannot be null");
+ if (instantiator == null) throw new
+ IllegalArgumentException("MBeanInstantiator cannot be null");
+ if (repository == null) throw new
+ IllegalArgumentException("Repository cannot be null");
+
+ this.server = outer;
+ this.delegate = delegate;
+ this.instantiator = instantiator;
+ this.repository = repository;
+ this.domain = repository.getDefaultDomain();
+ }
+
+ public ObjectInstance createMBean(String className, ObjectName name)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException {
+
+ return createMBean(className, name, (Object[]) null, (String[]) null);
+
+ }
+
+ public ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException {
+
+ return createMBean(className, name, loaderName, (Object[]) null,
+ (String[]) null);
+ }
+
+ public ObjectInstance createMBean(String className, ObjectName name,
+ Object[] params, String[] signature)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException {
+
+ try {
+ return createMBean(className, name, null, true,
+ params, signature);
+ } catch (InstanceNotFoundException e) {
+ /* Can only happen if loaderName doesn't exist, but we just
+ passed null, so we shouldn't get this exception. */
+ throw EnvHelp.initCause(
+ new IllegalArgumentException("Unexpected exception: " + e), e);
+ }
+ }
+
+ public ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName,
+ Object[] params, String[] signature)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException {
+
+ return createMBean(className, name, loaderName, false,
+ params, signature);
+ }
+
+ private ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName,
+ boolean withDefaultLoaderRepository,
+ Object[] params, String[] signature)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException {
+
+ ObjectName logicalName = name;
+ Class theClass;
+
+ if (className == null) {
+ final RuntimeException wrapped =
+ new IllegalArgumentException("The class name cannot be null");
+ throw new RuntimeOperationsException(wrapped,
+ "Exception occurred during MBean creation");
+ }
+
+ if (name != null) {
+ if (name.isPattern()) {
+ final RuntimeException wrapped =
+ new IllegalArgumentException("Invalid name->" +
+ name.toString());
+ final String msg = "Exception occurred during MBean creation";
+ throw new RuntimeOperationsException(wrapped, msg);
+ }
+
+ name = nonDefaultDomain(name);
+ }
+
+ checkMBeanPermission(className, null, null, "instantiate");
+ checkMBeanPermission(className, null, name, "registerMBean");
+
+ /* Load the appropriate class. */
+ if (withDefaultLoaderRepository) {
+ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
+ MBEANSERVER_LOGGER.logp(Level.FINER,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "createMBean",
+ "ClassName = " + className + ", ObjectName = " + name);
+ }
+ theClass =
+ instantiator.findClassWithDefaultLoaderRepository(className);
+ } else if (loaderName == null) {
+ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
+ MBEANSERVER_LOGGER.logp(Level.FINER,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "createMBean", "ClassName = " + className +
+ ", ObjectName = " + name + ", Loader name = null");
+ }
+
+ theClass = instantiator.findClass(className,
+ server.getClass().getClassLoader());
+ } else {
+ loaderName = nonDefaultDomain(loaderName);
+
+ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
+ MBEANSERVER_LOGGER.logp(Level.FINER,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "createMBean", "ClassName = " + className +
+ ", ObjectName = " + name +
+ ", Loader name = " + loaderName);
+ }
+
+ theClass = instantiator.findClass(className, loaderName);
+ }
+
+ checkMBeanTrustPermission(theClass);
+
+ // Check that the MBean can be instantiated by the MBeanServer.
+ Introspector.testCreation(theClass);
+
+ // Check the JMX MBean compliance of the class
+ Introspector.checkCompliance(theClass);
+
+ Object moi= instantiator.instantiate(theClass, params, signature,
+ server.getClass().getClassLoader());
+
+ final String infoClassName = getNewMBeanClassName(moi);
+
+ return registerObject(infoClassName, moi, name);
+ }
+
+ public ObjectInstance registerMBean(Object object, ObjectName name)
+ throws InstanceAlreadyExistsException, MBeanRegistrationException,
+ NotCompliantMBeanException {
+
+ // ------------------------------
+ // ------------------------------
+ Class theClass = object.getClass();
+
+ Introspector.checkCompliance(theClass);
+
+ final String infoClassName = getNewMBeanClassName(object);
+
+ checkMBeanPermission(infoClassName, null, name, "registerMBean");
+ checkMBeanTrustPermission(theClass);
+
+ return registerObject(infoClassName, object, name);
+ }
+
+ private static String getNewMBeanClassName(Object mbeanToRegister)
+ throws NotCompliantMBeanException {
+ if (mbeanToRegister instanceof DynamicMBean) {
+ DynamicMBean mbean = (DynamicMBean) mbeanToRegister;
+ final String name;
+ try {
+ name = mbean.getMBeanInfo().getClassName();
+ } catch (Exception e) {
+ // Includes case where getMBeanInfo() returns null
+ NotCompliantMBeanException ncmbe =
+ new NotCompliantMBeanException("Bad getMBeanInfo()");
+ ncmbe.initCause(e);
+ throw ncmbe;
+ }
+ if (name == null) {
+ final String msg = "MBeanInfo has null class name";
+ throw new NotCompliantMBeanException(msg);
+ }
+ return name;
+ } else
+ return mbeanToRegister.getClass().getName();
+ }
+
+ private final Set<ObjectName> beingUnregistered =
+ new HashSet<ObjectName>();
+
+ public void unregisterMBean(ObjectName name)
+ throws InstanceNotFoundException, MBeanRegistrationException {
+
+ if (name == null) {
+ final RuntimeException wrapped =
+ new IllegalArgumentException("Object name cannot be null");
+ throw new RuntimeOperationsException(wrapped,
+ "Exception occurred trying to unregister the MBean");
+ }
+
+ name = nonDefaultDomain(name);
+
+ /* The semantics of preDeregister are tricky. If it throws an
+ exception, then the unregisterMBean fails. This allows an
+ MBean to refuse to be unregistered. If it returns
+ successfully, then the unregisterMBean can proceed. In
+ this case the preDeregister may have cleaned up some state,
+ and will not expect to be called a second time. So if two
+ threads try to unregister the same MBean at the same time
+ then one of them must wait for the other one to either (a)
+ call preDeregister and get an exception or (b) call
+ preDeregister successfully and unregister the MBean.
+ Suppose thread T1 is unregistering an MBean and thread T2
+ is trying to unregister the same MBean, so waiting for T1.
+ Then a deadlock is possible if the preDeregister for T1
+ ends up needing a lock held by T2. Given the semantics
+ just described, there does not seem to be any way to avoid
+ this. This will not happen to code where it is clear for
+ any given MBean what thread may unregister that MBean.
+
+ On the other hand we clearly do not want a thread that is
+ unregistering MBean A to have to wait for another thread
+ that is unregistering another MBean B (see bug 6318664). A
+ deadlock in this situation could reasonably be considered
+ gratuitous. So holding a global lock across the
+ preDeregister call would be bad.
+
+ So we have a set of ObjectNames that some thread is
+ currently unregistering. When a thread wants to unregister
+ a name, it must first check if the name is in the set, and
+ if so it must wait. When a thread successfully unregisters
+ a name it removes the name from the set and notifies any
+ waiting threads that the set has changed.
+
+ This implies that we must be very careful to ensure that
+ the name is removed from the set and waiters notified, no
+ matter what code path is taken. */
+
+ synchronized (beingUnregistered) {
+ while (beingUnregistered.contains(name)) {
+ try {
+ beingUnregistered.wait();
+ } catch (InterruptedException e) {
+ throw new MBeanRegistrationException(e, e.toString());
+ // pretend the exception came from preDeregister;
+ // in another execution sequence it could have
+ }
+ }
+ beingUnregistered.add(name);
+ }
+
+ try {
+ exclusiveUnregisterMBean(name);
+ } finally {
+ synchronized (beingUnregistered) {
+ beingUnregistered.remove(name);
+ beingUnregistered.notifyAll();
+ }
+ }
+ }
+
+ private void exclusiveUnregisterMBean(ObjectName name)
+ throws InstanceNotFoundException, MBeanRegistrationException {
+
+ DynamicMBean instance = getMBean(name);
+ // may throw InstanceNotFoundException
+
+ checkMBeanPermission(instance, null, name, "unregisterMBean");
+
+ if (instance instanceof MBeanRegistration)
+ preDeregisterInvoke((MBeanRegistration) instance);
+
+ repository.remove(name);
+ // may throw InstanceNotFoundException
+
+ /**
+ * Checks if the unregistered MBean is a ClassLoader
+ * If so, it removes the MBean from the default loader repository.
+ */
+
+ Object resource = getResource(instance);
+ if (resource instanceof ClassLoader
+ && resource != server.getClass().getClassLoader()) {
+ final ModifiableClassLoaderRepository clr =
+ instantiator.getClassLoaderRepository();
+ if (clr != null) clr.removeClassLoader(name);
+ }
+
+ // ---------------------
+ // Send deletion event
+ // ---------------------
+ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
+ MBEANSERVER_LOGGER.logp(Level.FINER,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "unregisterMBean", "Send delete notification of object " +
+ name.getCanonicalName());
+ }
+ sendNotification(MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
+ name);
+
+ if (instance instanceof MBeanRegistration)
+ postDeregisterInvoke((MBeanRegistration) instance);
+ }
+
+ public ObjectInstance getObjectInstance(ObjectName name)
+ throws InstanceNotFoundException {
+
+ name = nonDefaultDomain(name);
+ DynamicMBean instance = getMBean(name);
+
+ checkMBeanPermission(instance, null, name, "getObjectInstance");
+
+ final String className = getClassName(instance);
+
+ return new ObjectInstance(name, className);
+ }
+
+ public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ // Check if the caller has the right to invoke 'queryMBeans'
+ //
+ checkMBeanPermission((String) null, null, null, "queryMBeans");
+
+ // Perform query without "query".
+ //
+ Set<ObjectInstance> list = queryMBeansImpl(name, null);
+
+ // Check if the caller has the right to invoke 'queryMBeans'
+ // on each specific classname/objectname in the list.
+ //
+ Set<ObjectInstance> allowedList =
+ new HashSet<ObjectInstance>(list.size());
+ for (ObjectInstance oi : list) {
+ try {
+ checkMBeanPermission(oi.getClassName(), null,
+ oi.getObjectName(), "queryMBeans");
+ allowedList.add(oi);
+ } catch (SecurityException e) {
+ // OK: Do not add this ObjectInstance to the list
+ }
+ }
+
+ // Apply query to allowed MBeans only.
+ //
+ return filterListOfObjectInstances(allowedList, query);
+ } else {
+ // Perform query.
+ //
+ return queryMBeansImpl(name, query);
+ }
+ }
+
+ private Set<ObjectInstance> queryMBeansImpl(ObjectName name,
+ QueryExp query) {
+ // Query the MBeans on the repository
+ //
+ Set<NamedObject> list = null;
+ list = repository.query(name, query);
+
+ if (queryByRepo) {
+ // The repository performs the filtering
+ query = null;
+ }
+
+ return (objectInstancesFromFilteredNamedObjects(list, query));
+ }
+
+ public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
+ Set<ObjectName> queryList;
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ // Check if the caller has the right to invoke 'queryNames'
+ //
+ checkMBeanPermission((String) null, null, null, "queryNames");
+
+ // Perform query without "query".
+ //
+ Set<ObjectInstance> list = queryMBeansImpl(name, null);
+
+ // Check if the caller has the right to invoke 'queryNames'
+ // on each specific classname/objectname in the list.
+ //
+ Set<ObjectInstance> allowedList =
+ new HashSet<ObjectInstance>(list.size());
+ for (ObjectInstance oi : list) {
+ try {
+ checkMBeanPermission(oi.getClassName(), null,
+ oi.getObjectName(), "queryNames");
+ allowedList.add(oi);
+ } catch (SecurityException e) {
+ // OK: Do not add this ObjectInstance to the list
+ }
+ }
+
+ // Apply query to allowed MBeans only.
+ //
+ Set<ObjectInstance> queryObjectInstanceList =
+ filterListOfObjectInstances(allowedList, query);
+ queryList = new HashSet<ObjectName>(queryObjectInstanceList.size());
+ for (ObjectInstance oi : queryObjectInstanceList) {
+ queryList.add(oi.getObjectName());
+ }
+ } else {
+ // Perform query.
+ //
+ queryList = queryNamesImpl(name, query);
+ }
+ return queryList;
+ }
+
+ private Set<ObjectName> queryNamesImpl(ObjectName name, QueryExp query) {
+ // Query the MBeans on the repository
+ //
+ Set<NamedObject> list = null;
+ list = repository.query(name, query);
+
+ if (queryByRepo) {
+ // The repository performs the filtering
+ query = null;
+ }
+
+ return (objectNamesFromFilteredNamedObjects(list, query));
+ }
+
+ public boolean isRegistered(ObjectName name) {
+ if (name == null) {
+ throw new RuntimeOperationsException(
+ new IllegalArgumentException("Object name cannot be null"),
+ "Object name cannot be null");
+ }
+
+ name = nonDefaultDomain(name);
+
+// /* Permission check */
+// checkMBeanPermission(null, null, name, "isRegistered");
+
+ return (repository.contains(name));
+ }
+
+ public String[] getDomains() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ // Check if the caller has the right to invoke 'getDomains'
+ //
+ checkMBeanPermission((String) null, null, null, "getDomains");
+
+ // Return domains
+ //
+ String[] domains = repository.getDomains();
+
+ // Check if the caller has the right to invoke 'getDomains'
+ // on each specific domain in the list.
+ //
+ List<String> result = new ArrayList<String>(domains.length);
+ for (int i = 0; i < domains.length; i++) {
+ try {
+ ObjectName domain = new ObjectName(domains[i] + ":x=x");
+ checkMBeanPermission((String) null, null, domain, "getDomains");
+ result.add(domains[i]);
+ } catch (MalformedObjectNameException e) {
+ // Should never occur... But let's log it just in case.
+ if (MBEANSERVER_LOGGER.isLoggable(Level.SEVERE)) {
+ MBEANSERVER_LOGGER.logp(Level.SEVERE,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "getDomains",
+ "Failed to check permission for domain = " +
+ domains[i], e);
+ }
+ } catch (SecurityException e) {
+ // OK: Do not add this domain to the list
+ }
+ }
+
+ // Make an array from result.
+ //
+ return result.toArray(new String[result.size()]);
+ } else {
+ return repository.getDomains();
+ }
+ }
+
+ public Integer getMBeanCount() {
+ return (repository.getCount());
+ }
+
+ public Object getAttribute(ObjectName name, String attribute)
+ throws MBeanException, AttributeNotFoundException,
+ InstanceNotFoundException, ReflectionException {
+
+ if (name == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("Object name cannot be null"),
+ "Exception occurred trying to invoke the getter on the MBean");
+ }
+ if (attribute == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("Attribute cannot be null"),
+ "Exception occurred trying to invoke the getter on the MBean");
+ }
+
+ name = nonDefaultDomain(name);
+
+ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
+ MBEANSERVER_LOGGER.logp(Level.FINER,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "getAttribute",
+ "Attribute = " + attribute + ", ObjectName = " + name);
+ }
+
+ final DynamicMBean instance = getMBean(name);
+ checkMBeanPermission(instance, attribute, name, "getAttribute");
+
+ try {
+ return instance.getAttribute(attribute);
+ } catch (AttributeNotFoundException e) {
+ throw e;
+ } catch (Throwable t) {
+ rethrowMaybeMBeanException(t);
+ throw new AssertionError(); // not reached
+ }
+ }
+
+ public AttributeList getAttributes(ObjectName name, String[] attributes)
+ throws InstanceNotFoundException, ReflectionException {
+
+ if (name == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("ObjectName name cannot be null"),
+ "Exception occurred trying to invoke the getter on the MBean");
+ }
+
+ if (attributes == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("Attributes cannot be null"),
+ "Exception occurred trying to invoke the getter on the MBean");
+ }
+
+ name = nonDefaultDomain(name);
+
+ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
+ MBEANSERVER_LOGGER.logp(Level.FINER,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "getAttributes", "ObjectName = " + name);
+ }
+
+ final DynamicMBean instance = getMBean(name);
+ final String[] allowedAttributes;
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ allowedAttributes = attributes;
+ else {
+ final String classname = getClassName(instance);
+
+ // Check if the caller has the right to invoke 'getAttribute'
+ //
+ checkMBeanPermission(classname, null, name, "getAttribute");
+
+ // Check if the caller has the right to invoke 'getAttribute'
+ // on each specific attribute
+ //
+ List<String> allowedList =
+ new ArrayList<String>(attributes.length);
+ for (String attr : attributes) {
+ try {
+ checkMBeanPermission(classname, attr,
+ name, "getAttribute");
+ allowedList.add(attr);
+ } catch (SecurityException e) {
+ // OK: Do not add this attribute to the list
+ }
+ }
+ allowedAttributes = allowedList.toArray(new String[0]);
+ }
+
+ try {
+ return instance.getAttributes(allowedAttributes);
+ } catch (Throwable t) {
+ rethrow(t);
+ throw new AssertionError();
+ }
+ }
+
+ public void setAttribute(ObjectName name, Attribute attribute)
+ throws InstanceNotFoundException, AttributeNotFoundException,
+ InvalidAttributeValueException, MBeanException,
+ ReflectionException {
+
+ if (name == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("ObjectName name cannot be null"),
+ "Exception occurred trying to invoke the setter on the MBean");
+ }
+
+ if (attribute == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("Attribute cannot be null"),
+ "Exception occurred trying to invoke the setter on the MBean");
+ }
+
+ name = nonDefaultDomain(name);
+
+ if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
+ MBEANSERVER_LOGGER.logp(Level.FINER,
+ DefaultMBeanServerInterceptor.class.getName(),
+ "setAttribute", "ObjectName = " + name +
+ ", Attribute = " + attribute.getName());
+ }
+
+ DynamicMBean instance = getMBean(name);
+ checkMBeanPermission(instance, attribute.getName(),
+ name, "setAttribute");
+
+ try {
+ instance.setAttribute(attribute);
+ } catch (AttributeNotFoundException e) {
+ throw e;
+ } catch (InvalidAttributeValueException e) {
+ throw e;
+ } catch (Throwable t) {
+ rethrowMaybeMBeanException(t);
+ throw new AssertionError();
+ }
+ }
+
+ public AttributeList setAttributes(ObjectName name,
+ AttributeList attributes)
+ throws InstanceNotFoundException, ReflectionException {
+
+ if (name == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("ObjectName name cannot be null"),
+ "Exception occurred trying to invoke the setter on the MBean");
+ }
+
+ if (attributes == null) {
+ throw new RuntimeOperationsException(new
+ IllegalArgumentException("AttributeList cannot be null"),
+ "Exception occurred trying to invoke the setter on the MBean");
+ }
+
+ name = nonDefaultDomain(name);
+
+ final DynamicMBean instance = getMBean(name);
+ final AttributeList allowedAttributes;
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ allowedAttributes = attributes;
+ else {
+ String classname = getClassName(instance);
+
+ // Check if the caller has the right to invoke 'setAttribute'
+ //
+ checkMBeanPermission(classname, null, name, "setAttribute");
+
+ // Check if the caller has the right to invoke 'setAttribute'
+ // on each specific attribute
+ //
+ allowedAttributes = new AttributeList(attributes.size());
+ for (Iterator i = attributes.iterator(); i.hasNext();) {
+ try {
+ Attribute attribute = (Attribute) i.next();
+ checkMBeanPermission(classname, attribute.getName(),
+ name, "setAttribute");
+ allowedAttributes.add(attribute);
+ } catch (SecurityException e) {
+ // OK: Do not add this attribute to the list
+ }
+ }
+ }
+ try {
+ return instance.setAttributes(allowedAttributes);
+ } catch (Throwable t) {
+ rethrow(t);
+ throw new AssertionError();
+ }
+ }
+
+ public Object invoke(ObjectName name, String operationName,
+ Object params[], String signature[])
+ throws InstanceNotFoundException, MBeanException,
+ ReflectionException {
+
+ name = nonDefaultDomain(name);
+
+ DynamicMBean instance = getMBean(name);
+ checkMBeanPermission(instance, operationName, name, "invoke");
+ try {
+ return instance.invoke(operationName, params, signature);
+ } catch (Throwable t) {
+ rethrowMaybeMBeanException(t);
+ throw new AssertionError();
+ }
+ }
+
+ /* Centralize some of the tedious exception wrapping demanded by the JMX
+ spec. */
+ private static void rethrow(Throwable t)
+ throws ReflectionException {
+ try {
+ throw t;
+ } catch (ReflectionException e) {
+ throw e;
+ } catch (RuntimeOperationsException e) {
+ throw e;
+ } catch (RuntimeErrorException e) {
+ throw e;
+ } catch (RuntimeException e) {
+ throw new RuntimeMBeanException(e, e.toString());
+ } catch (Error e) {
+ throw new RuntimeErrorException(e, e.toString());
+ } catch (Throwable t2) {
+ // should not happen
+ throw new RuntimeException("Unexpected exception", t2);
+ }
+ }
+
+ private static void rethrowMaybeMBeanException(Throwable t)
+ throws ReflectionException, MBeanException {
+ if (t instanceof MBeanException)
+ throw (MBeanException) t;
+ rethrow(t);
+ }
+
+ /**
+ * Register <code>object</code> in the repository, with the
+ * given <code>name</code>.
+ * This method is called by the various createMBean() flavours
+ * and by registerMBean() after all MBean compliance tests
+ * have been performed.
+ * <p>
+ * This method does not performed any kind of test compliance,
+ * and the caller should make sure that the given <code>object</code>
+ * is MBean compliant.
+ * <p>
+ * This methods performed all the basic steps needed for object
+ * registration:
+ * <ul>
+ * <li>If the <code>object</code> implements the MBeanRegistration
+ * interface, it invokes preRegister() on the object.</li>
+ * <li>Then the object is added to the repository with the given
+ * <code>name</code>.</li>
+ * <li>Finally, if the <code>object</code> implements the
+ * MBeanRegistration interface, it invokes postRegister()
+ * on the object.</li>
+ * </ul>
+ * @param object A reference to a MBean compliant object.
+ * @param name The ObjectName of the <code>object</code> MBean.
+ * @return the actual ObjectName with which the object was registered.
+ * @exception InstanceAlreadyExistsException if an object is already
+ * registered with that name.
+ * @exception MBeanRegistrationException if an exception occurs during
+ * registration.
+ **/
+ private ObjectInstance registerObject(String classname,
+ Object object, ObjectName name)
+ throws InstanceAlreadyExistsException,
+ MBeanRegistrationException,
+ NotCompliantMBeanException {
+
+ if (object == null) {
+ final RuntimeException wrapped =
+ new IllegalArgumentException("Cannot add null object");
+ throw new RuntimeOperationsException(wrapped,
+ "Exception occurred trying to register the MBean");
+ }
+
+ DynamicMBean mbean = Introspector.makeDynamicMBean(object);
+
+ return registerDynamicMBean(classname, mbean, name);
+ }
+
+ private ObjectInstance registerDynamicMBean(String classname,
+ DynamicMBean mbean,
+ ObjectName name)
+ throws InstanceAlreadyExistsException,
+ MBeanRegistrationException,
+ NotCompliantMBeanExcep...
[truncated message content] |