feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
274
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/AMXClient.java
Normal file
274
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/AMXClient.java
Normal file
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.management.Attribute;
|
||||
import javax.management.AttributeList;
|
||||
import javax.management.AttributeNotFoundException;
|
||||
import javax.management.Descriptor;
|
||||
import javax.management.InstanceNotFoundException;
|
||||
import javax.management.IntrospectionException;
|
||||
import javax.management.InvalidAttributeValueException;
|
||||
import javax.management.JMException;
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.ReflectionException;
|
||||
import javax.management.RuntimeOperationsException;
|
||||
import javax.management.modelmbean.ModelMBeanInfo;
|
||||
|
||||
|
||||
/** This class implements a generic AMXMBeanInterface MBean which is connected to a possibly
|
||||
* remote MBeanServerConnection (note that MBeanServer isA MBeanServerConnection,
|
||||
* so we can actually create an AMXClientImpl simply by using the MBeanServer
|
||||
* from the mom: this is useful for testing).
|
||||
* <P>
|
||||
* Note that this version of the AMXMBeanInterface API provides a generic get/set API that
|
||||
* is identical to DynamicMBean, except that it only throws unchecked exceptions.
|
||||
* This is far more convenient in practice than the JMX-standard checked exceptions.
|
||||
*
|
||||
* @author ken
|
||||
*/
|
||||
public class AMXClient implements AMXMBeanInterface {
|
||||
private static ObjectName makeObjectName( String str ) {
|
||||
try {
|
||||
return new ObjectName(str);
|
||||
} catch (MalformedObjectNameException ex) {
|
||||
return null ;
|
||||
}
|
||||
}
|
||||
|
||||
/** Special object name used to represent a NULL objectName result.
|
||||
*/
|
||||
public static final ObjectName NULL_OBJECTNAME = makeObjectName(
|
||||
"null:type=Null,name=Null" ) ;
|
||||
|
||||
private MBeanServerConnection server ;
|
||||
private ObjectName oname ;
|
||||
|
||||
@Override
|
||||
public boolean equals( Object obj ) {
|
||||
if (this == obj) {
|
||||
return true ;
|
||||
}
|
||||
|
||||
if (!(obj instanceof AMXClient)) {
|
||||
return false ;
|
||||
}
|
||||
|
||||
AMXClient other = (AMXClient)obj ;
|
||||
|
||||
return oname.equals( other.oname ) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 47 * hash + (this.oname != null ? this.oname.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AMXClient[" + oname + "]" ;
|
||||
}
|
||||
|
||||
private <T> T fetchAttribute( String name, Class<T> type ) {
|
||||
try {
|
||||
Object obj = server.getAttribute( oname, name ) ;
|
||||
if (NULL_OBJECTNAME.equals( obj )) {
|
||||
return null ;
|
||||
} else {
|
||||
return type.cast( obj ) ;
|
||||
}
|
||||
} catch (JMException exc) {
|
||||
throw new GmbalException( "Exception in fetchAttribute", exc ) ;
|
||||
} catch (IOException exc) {
|
||||
throw new GmbalException( "Exception in fetchAttribute", exc ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public AMXClient( MBeanServerConnection server,
|
||||
ObjectName oname ) {
|
||||
this.server = server ;
|
||||
this.oname = oname ;
|
||||
}
|
||||
|
||||
private AMXClient makeAMX( ObjectName on ) {
|
||||
if (on == null) {
|
||||
return null ;
|
||||
}
|
||||
return new AMXClient( this.server, on ) ;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return fetchAttribute( "Name", String.class ) ;
|
||||
}
|
||||
|
||||
public Map<String,?> getMeta() {
|
||||
try {
|
||||
ModelMBeanInfo mbi = (ModelMBeanInfo) server.getMBeanInfo( oname );
|
||||
Descriptor desc = mbi.getMBeanDescriptor() ;
|
||||
Map<String,Object> result = new HashMap<String,Object>() ;
|
||||
for (String str : desc.getFieldNames()) {
|
||||
result.put( str, desc.getFieldValue( str )) ;
|
||||
}
|
||||
return result ;
|
||||
} catch (MBeanException ex) {
|
||||
throw new GmbalException( "Exception in getMeta", ex ) ;
|
||||
} catch (RuntimeOperationsException ex) {
|
||||
throw new GmbalException( "Exception in getMeta", ex ) ;
|
||||
} catch (InstanceNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in getMeta", ex ) ;
|
||||
} catch (IntrospectionException ex) {
|
||||
throw new GmbalException( "Exception in getMeta", ex ) ;
|
||||
} catch (ReflectionException ex) {
|
||||
throw new GmbalException( "Exception in getMeta", ex ) ;
|
||||
} catch (IOException ex) {
|
||||
throw new GmbalException( "Exception in getMeta", ex ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public AMXClient getParent() {
|
||||
ObjectName res = fetchAttribute( "Parent", ObjectName.class ) ;
|
||||
return makeAMX( res ) ;
|
||||
}
|
||||
|
||||
public AMXClient[] getChildren() {
|
||||
ObjectName[] onames = fetchAttribute( "Children",
|
||||
ObjectName[].class ) ;
|
||||
return makeAMXArray( onames ) ;
|
||||
}
|
||||
|
||||
private AMXClient[] makeAMXArray( ObjectName[] onames ) {
|
||||
AMXClient[] result = new AMXClient[onames.length] ;
|
||||
int ctr=0 ;
|
||||
for (ObjectName on : onames ) {
|
||||
result[ctr++] = makeAMX( on ) ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
public Object getAttribute(String attribute) {
|
||||
try {
|
||||
return server.getAttribute(oname, attribute);
|
||||
} catch (MBeanException ex) {
|
||||
throw new GmbalException( "Exception in getAttribute", ex ) ;
|
||||
} catch (AttributeNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in getAttribute", ex ) ;
|
||||
} catch (ReflectionException ex) {
|
||||
throw new GmbalException( "Exception in getAttribute", ex ) ;
|
||||
} catch (InstanceNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in getAttribute", ex ) ;
|
||||
} catch (IOException ex) {
|
||||
throw new GmbalException( "Exception in getAttribute", ex ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttribute(String name, Object value ) {
|
||||
Attribute attr = new Attribute( name, value ) ;
|
||||
setAttribute( attr ) ;
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute) {
|
||||
try {
|
||||
server.setAttribute(oname, attribute);
|
||||
} catch (InstanceNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in setAttribute", ex ) ;
|
||||
} catch (AttributeNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in setAttribute", ex ) ;
|
||||
} catch (InvalidAttributeValueException ex) {
|
||||
throw new GmbalException( "Exception in setAttribute", ex ) ;
|
||||
} catch (MBeanException ex) {
|
||||
throw new GmbalException( "Exception in setAttribute", ex ) ;
|
||||
} catch (ReflectionException ex) {
|
||||
throw new GmbalException( "Exception in setAttribute", ex ) ;
|
||||
} catch (IOException ex) {
|
||||
throw new GmbalException( "Exception in setAttribute", ex ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public AttributeList getAttributes(String[] attributes) {
|
||||
try {
|
||||
return server.getAttributes(oname, attributes);
|
||||
} catch (InstanceNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in getAttributes", ex ) ;
|
||||
} catch (ReflectionException ex) {
|
||||
throw new GmbalException( "Exception in getAttributes", ex ) ;
|
||||
} catch (IOException ex) {
|
||||
throw new GmbalException( "Exception in getAttributes", ex ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public AttributeList setAttributes(AttributeList attributes) {
|
||||
try {
|
||||
return server.setAttributes(oname, attributes);
|
||||
} catch (InstanceNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in setAttributes", ex ) ;
|
||||
} catch (ReflectionException ex) {
|
||||
throw new GmbalException( "Exception in setAttributes", ex ) ;
|
||||
} catch (IOException ex) {
|
||||
throw new GmbalException( "Exception in setAttributes", ex ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public Object invoke(String actionName, Object[] params, String[] signature)
|
||||
throws MBeanException, ReflectionException {
|
||||
try {
|
||||
return server.invoke(oname, actionName, params, signature);
|
||||
} catch (InstanceNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in invoke", ex ) ;
|
||||
} catch (IOException ex) {
|
||||
throw new GmbalException( "Exception in invoke", ex ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public MBeanInfo getMBeanInfo() {
|
||||
try {
|
||||
return server.getMBeanInfo(oname);
|
||||
} catch (InstanceNotFoundException ex) {
|
||||
throw new GmbalException( "Exception in invoke", ex ) ;
|
||||
} catch (IntrospectionException ex) {
|
||||
throw new GmbalException( "Exception in invoke", ex ) ;
|
||||
} catch (ReflectionException ex) {
|
||||
throw new GmbalException( "Exception in invoke", ex ) ;
|
||||
} catch (IOException ex) {
|
||||
throw new GmbalException( "Exception in invoke", ex ) ;
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectName objectName() {
|
||||
return oname ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.util.Map;
|
||||
import com.sun.org.glassfish.external.amx.AMX;
|
||||
|
||||
|
||||
/** Base interface supported by all AMXMBeanInterface MBeans. All MBeans generated by
|
||||
* gmbal comply with this interface, which means that the attributes and
|
||||
* operations defined in this Java interface all appear in each
|
||||
* MBean generated by calling ManagedObjectManager.register.
|
||||
*
|
||||
* @author LLoyd Chambers
|
||||
* @author Ken Cavanaugh
|
||||
*
|
||||
*/
|
||||
@ManagedObject
|
||||
@Description( "Base interface for any MBean that works in the AMX framework" )
|
||||
public interface AMXMBeanInterface {
|
||||
/** Get all metadata about this MBean.
|
||||
* @return The descriptor, which will be a ModelMBeanInfoSupport instance.
|
||||
*/
|
||||
public Map<String,?> getMeta();
|
||||
|
||||
/** Usually the same as the ObjectName 'name' property, but can differ
|
||||
if the actual name contains characters that must be escaped for an ObjectName and/or
|
||||
if the MBean has a mutable name attribute.
|
||||
The type property can be obtained from the ObjectName */
|
||||
@ManagedAttribute( id=AMX.ATTR_NAME )
|
||||
@Description( "Return the name of this MBean.")
|
||||
public String getName();
|
||||
|
||||
/** "go up one level": the MBean containing this one, can be null for root
|
||||
* @return The container of this MBean (null if already at root).
|
||||
*/
|
||||
@ManagedAttribute( id=AMX.ATTR_PARENT )
|
||||
@Description( "The container that contains this MBean" )
|
||||
public AMXMBeanInterface getParent();
|
||||
|
||||
/** Containment hierarchy:
|
||||
Get all AMXMBeanInterface contained by this one, in no particular order.
|
||||
Valid only if isContainer().
|
||||
* Note that using an array sidesteps Map/Set/OpenType issues
|
||||
* @return All children of this AMXMBeanInterface MBean.
|
||||
*/
|
||||
@ManagedAttribute( id=AMX.ATTR_CHILDREN )
|
||||
@Description( "All children of this AMX MBean")
|
||||
public AMXMBeanInterface[] getChildren();
|
||||
}
|
||||
121
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/AMXMetadata.java
Normal file
121
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/AMXMetadata.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Inherited ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
import com.sun.org.glassfish.external.amx.AMX ;
|
||||
|
||||
/** Annotation to contol exactly how the type value in the ObjectName
|
||||
* is extracted from a class when registering an instance of that class.
|
||||
* The absence of this annotation is the same as the default values.
|
||||
* Note that this is simply an application of the general @DescriptorKey
|
||||
* mechanism, but these particular metadata attributes control some of the
|
||||
* behavior of the AMXMBeanInterface API.
|
||||
* <p>Note that supportsAdoption is not included here, because that attribute
|
||||
* is always false for gmbal.
|
||||
*
|
||||
* @author ken
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
public @interface AMXMetadata {
|
||||
/** True if only one MBean of this type may be created inside the same
|
||||
* parent container
|
||||
*
|
||||
* @return whether or not this MBean must be the only one of its type.
|
||||
*/
|
||||
@DescriptorKey( AMX.DESC_IS_SINGLETON )
|
||||
boolean isSingleton() default false ;
|
||||
|
||||
/** String denoting classification of MBean. Predefined values are
|
||||
* configuration, monitoring, jsr77, utility, and other.
|
||||
* @return The group type.
|
||||
*/
|
||||
@DescriptorKey( AMX.DESC_GROUP )
|
||||
String group() default "other" ;
|
||||
|
||||
/** Return the list of types that are legal as types of children of this
|
||||
* type. If unknown, must be an empty array.
|
||||
* @return Array of child types
|
||||
*/
|
||||
@DescriptorKey( AMX.DESC_SUB_TYPES )
|
||||
String[] subTypes() default {} ;
|
||||
|
||||
/** Return the generic AMXMBeanInterface interface to be used.
|
||||
* @return name of interface to use.
|
||||
*/
|
||||
@DescriptorKey( AMX.DESC_GENERIC_INTERFACE_NAME )
|
||||
String genericInterfaceName() default "com.sun.org.glassfish.admin.amx.core.AMXProxy" ;
|
||||
|
||||
/** True if the MBeanInfo is invariant, that is, has the same
|
||||
* value for the lifetime of the MBean. This may be used as a hint
|
||||
* to clients that the MBeanInfo can be cached.
|
||||
*
|
||||
* @return True if the MBeanInfo is invariant
|
||||
*/
|
||||
@DescriptorKey( AMX.DESC_STD_IMMUTABLE_INFO )
|
||||
boolean immutableInfo() default true ;
|
||||
|
||||
/** Defines the name of the interface to use when generating a proxy
|
||||
* for this class. Defaults to a generic interface.
|
||||
* @return The interface class name for a proxy.
|
||||
*/
|
||||
@DescriptorKey( AMX.DESC_STD_INTERFACE_NAME )
|
||||
String interfaceClassName() default "" ;
|
||||
|
||||
/** An explicit type to use for the MBean.
|
||||
* <p>
|
||||
* Note that this is NOT part of the AMXMBeanInterface-defined metadata, but gmbal
|
||||
* needs it here to have a place to override the type.
|
||||
* <p>
|
||||
* Gmbal determines the type name as follows:
|
||||
* <ol>
|
||||
* <li>If the class has a final static field of type String with the
|
||||
* name "AMX_TYPE", the value of the field is the type name.
|
||||
* <li>Otherwise, if the class has an @AMXMetadata annotations, and the
|
||||
* value of the type is not "", the value of the type is the type name.
|
||||
* <li>Otherwise, if the package prefix of the class name matches one of
|
||||
* the type prefixes added by an stripPrefix call to the ManagedObjectManager,
|
||||
* the type name is the full class name with the matching prefix removed.
|
||||
* <li>Otherwise, if the stripPackagePrefix method was called on the
|
||||
* ManagedObjectManager, the type name is the class name without any
|
||||
* package prefixes.
|
||||
* <li>Otherwise, the type name is the class name.
|
||||
* </ol>
|
||||
* @return The type for this MBean.
|
||||
*/
|
||||
@DescriptorKey( "type" )
|
||||
String type() default "" ;
|
||||
}
|
||||
62
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/Description.java
Normal file
62
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/Description.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation is applied to a method that takes no arguments and returns a value
|
||||
* that is converted into a String for use in the ObjectName when an instance of the enclosing
|
||||
* class is used to construct an open MBean.
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Description {
|
||||
/** The description to be applied to the annotated element.
|
||||
* This value must not be empty. It can either be the actual string that is inserted
|
||||
* into the MBean info class, or a key into a resource bundle associated with the
|
||||
* ManagedObjectManager. If there is no bundle value associated with the key, or no
|
||||
* resource bundle is specified, the value is used directly in the MBean info class.
|
||||
*/
|
||||
String value() ;
|
||||
|
||||
/** Optional key to use in a resource bundle for this description. If present,
|
||||
* a gmbal tool will generate a resource bundle that contains key=value taken
|
||||
* from the description annotation.
|
||||
* <p>
|
||||
* If this key is not present, the default key is given by the class name,
|
||||
* if this annotation appears on a class, or the class name.method name if
|
||||
* this annotation appears on a method. It is an error to use the default
|
||||
* value for more than one method of the same name, except for setters and getters.
|
||||
*
|
||||
*/
|
||||
String key() default "" ;
|
||||
}
|
||||
141
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/DescriptorFields.java
Normal file
141
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/DescriptorFields.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/** This is taken directly from JDK 7 in order to support this feature in
|
||||
* JDK 5.
|
||||
*
|
||||
* <p>Annotation that adds fields to a Descriptor. This can be the
|
||||
* Descriptor for an MBean, or for an attribute, operation, or constructor
|
||||
* in an MBean, or for a parameter of an operation or constructor.</p>
|
||||
*
|
||||
* <p>Consider this Standard MBean interface, for example:</p>
|
||||
*
|
||||
* <pre>
|
||||
* public interface CacheControlMBean {
|
||||
* <b>@DescriptorFields("units=bytes")</b>
|
||||
* public long getCacheSize();
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>When a Standard MBean is made using this interface, the usual rules
|
||||
* mean that it will have an attribute called {@code CacheSize} of type
|
||||
* {@code long}. The {@code DescriptorFields} annotation will ensure
|
||||
* that the MBeanAttributeInfo for this attribute will have a
|
||||
* {@code Descriptor} that has a field called {@code units} with
|
||||
* corresponding value {@code bytes}.</p>
|
||||
*
|
||||
* <p>Similarly, if the interface looks like this:</p>
|
||||
*
|
||||
* <pre>
|
||||
* public interface CacheControlMBean {
|
||||
* <b>@DescriptorFields({"units=bytes", "since=1.5"})</b>
|
||||
* public long getCacheSize();
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>then the resulting {@code Descriptor} will contain the following
|
||||
* fields:</p>
|
||||
*
|
||||
* <table border="2">
|
||||
* <tr><th>Name</th><th>Value</th></tr>
|
||||
* <tr><td>units</td><td>"bytes"</td></tr>
|
||||
* <tr><td>since</td><td>"1.5"</td></tr>
|
||||
* </table>
|
||||
*
|
||||
* <p>The {@code @DescriptorFields} annotation can be applied to:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>a Standard MBean or MXBean interface;
|
||||
* <li>a method in such an interface;
|
||||
* <li>a parameter of a method in a Standard MBean or MXBean interface
|
||||
* when that method is an operation (not a getter or setter for an attribute);
|
||||
* <li>a public constructor in the class that implements a Standard MBean
|
||||
* or MXBean;
|
||||
* <li>a parameter in such a constructor.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Other uses of the annotation will either fail to compile or be
|
||||
* ignored.</p>
|
||||
*
|
||||
* <p>Interface annotations are checked only on the exact interface
|
||||
* that defines the management interface of a Standard MBean or an
|
||||
* MXBean, not on its parent interfaces. Method annotations are
|
||||
* checked only in the most specific interface in which the method
|
||||
* appears; in other words, if a child interface overrides a method
|
||||
* from a parent interface, only {@code @DescriptorFields} annotations in
|
||||
* the method in the child interface are considered.
|
||||
*
|
||||
* <p>The Descriptor fields contributed in this way must be consistent
|
||||
* with each other and with any fields contributed by
|
||||
* DescriptorKey annotations. That is, two
|
||||
* different annotations, or two members of the same annotation, must
|
||||
* not define a different value for the same Descriptor field. Fields
|
||||
* from annotations on a getter method must also be consistent with
|
||||
* fields from annotations on the corresponding setter method.</p>
|
||||
*
|
||||
* <p>The Descriptor resulting from these annotations will be merged
|
||||
* with any Descriptor fields provided by the implementation, such as
|
||||
* the <a href="Descriptor.html#immutableInfo">{@code
|
||||
* immutableInfo}</a> field for an MBean. The fields from the annotations
|
||||
* must be consistent with these fields provided by the implementation.</p>
|
||||
*
|
||||
* <h4>{@literal @DescriptorFields and @DescriptorKey}</h4>
|
||||
*
|
||||
* <p>The DescriptorKey annotation provides
|
||||
* another way to use annotations to define Descriptor fields.
|
||||
* <code>@DescriptorKey</code> requires more work but is also more
|
||||
* robust, because there is less risk of mistakes such as misspelling
|
||||
* the name of the field or giving an invalid value.
|
||||
* <code>@DescriptorFields</code> is more convenient but includes
|
||||
* those risks. <code>@DescriptorFields</code> is more
|
||||
* appropriate for occasional use, but for a Descriptor field that you
|
||||
* add in many places, you should consider a purpose-built annotation
|
||||
* using <code>@DescriptorKey</code>.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
@Documented
|
||||
@Inherited // for @MBean and @MXBean classes
|
||||
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.FIELD,
|
||||
ElementType.PARAMETER, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DescriptorFields {
|
||||
/**
|
||||
* <p>The descriptor fields. Each element of the string looks like
|
||||
* {@code "name=value"}.</p>
|
||||
*/
|
||||
public String[] value();
|
||||
}
|
||||
214
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/DescriptorKey.java
Normal file
214
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/DescriptorKey.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/** This is taken directly from JDK 7 in order to support this feature in
|
||||
* JDK 5.
|
||||
*
|
||||
* <p>Meta-annotation that describes how an annotation element relates
|
||||
* to a field in a Descriptor. This can be the Descriptor for
|
||||
* an MBean, or for an attribute, operation, or constructor in an
|
||||
* MBean, or for a parameter of an operation or constructor.</p>
|
||||
*
|
||||
* <p>(The DescriptorFields annotation
|
||||
* provides another way to add fields to a {@code Descriptor}. See
|
||||
* the documentation for that annotation for a comparison of the
|
||||
* two possibilities.)</p>
|
||||
*
|
||||
* <p>Consider this annotation for example:</p>
|
||||
*
|
||||
* <pre>
|
||||
* @Documented
|
||||
* @Target(ElementType.METHOD)
|
||||
* @Retention(RetentionPolicy.RUNTIME)
|
||||
* public @interface Units {
|
||||
* <b>@DescriptorKey("units")</b>
|
||||
* String value();
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>and this use of the annotation:</p>
|
||||
*
|
||||
* <pre>
|
||||
* public interface CacheControlMBean {
|
||||
* <b>@Units("bytes")</b>
|
||||
* public long getCacheSize();
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>When a Standard MBean is made from the {@code CacheControlMBean},
|
||||
* the usual rules mean that it will have an attribute called
|
||||
* {@code CacheSize} of type {@code long}. The {@code @Units}
|
||||
* annotation, given the above definition, will ensure that the
|
||||
* MBeanAttributeInfo for this attribute will have a
|
||||
* {@code Descriptor} that has a field called {@code units} with
|
||||
* corresponding value {@code bytes}.</p>
|
||||
*
|
||||
* <p>Similarly, if the annotation looks like this:</p>
|
||||
*
|
||||
* <pre>
|
||||
* @Documented
|
||||
* @Target(ElementType.METHOD)
|
||||
* @Retention(RetentionPolicy.RUNTIME)
|
||||
* public @interface Units {
|
||||
* <b>@DescriptorKey("units")</b>
|
||||
* String value();
|
||||
*
|
||||
* <b>@DescriptorKey("descriptionResourceKey")</b>
|
||||
* String resourceKey() default "";
|
||||
*
|
||||
* <b>@DescriptorKey("descriptionResourceBundleBaseName")</b>
|
||||
* String resourceBundleBaseName() default "";
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>and it is used like this:</p>
|
||||
*
|
||||
* <pre>
|
||||
* public interface CacheControlMBean {
|
||||
* <b>@Units("bytes",
|
||||
* resourceKey="bytes.key",
|
||||
* resourceBundleBaseName="com.example.foo.MBeanResources")</b>
|
||||
* public long getCacheSize();
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>then the resulting {@code Descriptor} will contain the following
|
||||
* fields:</p>
|
||||
*
|
||||
* <table border="2">
|
||||
* <tr><th>Name</th><th>Value</th></tr>
|
||||
* <tr><td>units</td><td>"bytes"</td></tr>
|
||||
* <tr><td>descriptionResourceKey</td><td>"bytes.key"</td></tr>
|
||||
* <tr><td>descriptionResourceBundleBaseName</td>
|
||||
* <td>"com.example.foo.MBeanResources"</td></tr>
|
||||
* </table>
|
||||
*
|
||||
* <p>An annotation such as {@code @Units} can be applied to:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>a Standard MBean or MXBean interface;
|
||||
* <li>a method in such an interface;
|
||||
* <li>a parameter of a method in a Standard MBean or MXBean interface
|
||||
* when that method is an operation (not a getter or setter for an attribute);
|
||||
* <li>a public constructor in the class that implements a Standard MBean
|
||||
* or MXBean;
|
||||
* <li>a parameter in such a constructor.
|
||||
* </ul>
|
||||
*
|
||||
* <p>Other uses of the annotation are ignored.</p>
|
||||
*
|
||||
* <p>Interface annotations are checked only on the exact interface
|
||||
* that defines the management interface of a Standard MBean or an
|
||||
* MXBean, not on its parent interfaces. Method annotations are
|
||||
* checked only in the most specific interface in which the method
|
||||
* appears; in other words, if a child interface overrides a method
|
||||
* from a parent interface, only {@code @DescriptorKey} annotations in
|
||||
* the method in the child interface are considered.
|
||||
*
|
||||
* <p>The Descriptor fields contributed in this way by different
|
||||
* annotations on the same program element must be consistent with
|
||||
* each other and with any fields contributed by a
|
||||
* DescriptorFields annotation. That is, two
|
||||
* different annotations, or two members of the same annotation, must
|
||||
* not define a different value for the same Descriptor field. Fields
|
||||
* from annotations on a getter method must also be consistent with
|
||||
* fields from annotations on the corresponding setter method.</p>
|
||||
*
|
||||
* <p>The Descriptor resulting from these annotations will be merged
|
||||
* with any Descriptor fields provided by the implementation, such as
|
||||
* the <a href="Descriptor.html#immutableInfo">{@code
|
||||
* immutableInfo}</a> field for an MBean. The fields from the annotations
|
||||
* must be consistent with these fields provided by the implementation.</p>
|
||||
*
|
||||
* <p>An annotation element to be converted into a descriptor field
|
||||
* can be of any type allowed by the Java language, except an annotation
|
||||
* or an array of annotations. The value of the field is derived from
|
||||
* the value of the annotation element as follows:</p>
|
||||
*
|
||||
* <table border="2">
|
||||
* <tr><th>Annotation element</th><th>Descriptor field</th></tr>
|
||||
* <tr><td>Primitive value ({@code 5}, {@code false}, etc)</td>
|
||||
* <td>Wrapped value ({@code Integer.valueOf(5)},
|
||||
* {@code Boolean.FALSE}, etc)</td></tr>
|
||||
* <tr><td>Class constant (e.g. {@code Thread.class})</td>
|
||||
* <td>Class name from Class.getName()
|
||||
* (e.g. {@code "java.lang.Thread"})</td></tr>
|
||||
* <tr><td>Enum constant (e.g. ElementType.FIELD)</td>
|
||||
* <td>Constant name from Enum.name()
|
||||
* (e.g. {@code "FIELD"})</td></tr>
|
||||
* <tr><td>Array of class constants or enum constants</td>
|
||||
* <td>String array derived by applying these rules to each
|
||||
* element</td></tr>
|
||||
* <tr><td>Value of any other type<br>
|
||||
* ({@code String}, {@code String[]}, {@code int[]}, etc)</td>
|
||||
* <td>The same value</td></tr>
|
||||
* </table>
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.FIELD })
|
||||
public @interface DescriptorKey {
|
||||
String value();
|
||||
|
||||
/**
|
||||
* <p>Do not include this field in the Descriptor if the annotation
|
||||
* element has its default value. For example, suppose {@code @Units} is
|
||||
* defined like this:</p>
|
||||
*
|
||||
* <pre>
|
||||
* @Documented
|
||||
* @Target(ElementType.METHOD)
|
||||
* @Retention(RetentionPolicy.RUNTIME)
|
||||
* public @interface Units {
|
||||
* @DescriptorKey("units")
|
||||
* String value();
|
||||
*
|
||||
* <b>@DescriptorKey(value = "descriptionResourceKey",
|
||||
* omitIfDefault = true)</b>
|
||||
* String resourceKey() default "";
|
||||
*
|
||||
* <b>@DescriptorKey(value = "descriptionResourceBundleBaseName",
|
||||
* omitIfDefault = true)</b>
|
||||
* String resourceBundleBaseName() default "";
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>Then consider a usage such as {@code @Units("bytes")} or
|
||||
* {@code @Units(value = "bytes", resourceKey = "")}, where the
|
||||
* {@code resourceKey} and {@code resourceBundleBaseNames} elements
|
||||
* have their default values. In this case the Descriptor resulting
|
||||
* from these annotations will not include a {@code descriptionResourceKey}
|
||||
* or {@code descriptionResourceBundleBaseName} field.</p>
|
||||
*/
|
||||
boolean omitIfDefault() default false;
|
||||
}
|
||||
47
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/GmbalException.java
Normal file
47
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/GmbalException.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
/** Unchecked exception type used for all gmbal exceptions.
|
||||
*
|
||||
* @author ken
|
||||
*/
|
||||
public class GmbalException extends RuntimeException {
|
||||
private static final long serialVersionUID = -7478444176079980162L;
|
||||
public GmbalException( String msg ) {
|
||||
super( msg ) ;
|
||||
}
|
||||
|
||||
public GmbalException( String msg, Throwable thr ) {
|
||||
super( msg, thr ) ;
|
||||
}
|
||||
}
|
||||
39
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/GmbalMBean.java
Normal file
39
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/GmbalMBean.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import javax.management.DynamicMBean;
|
||||
import javax.management.NotificationEmitter;
|
||||
|
||||
/** Type returned from ManagedObjectManager createRoot and register methods.
|
||||
* Used because all Gmbal MBeans are dynamic MBeans that support attribute
|
||||
* change notification.
|
||||
*
|
||||
* @author ken
|
||||
*/
|
||||
public interface GmbalMBean extends DynamicMBean, NotificationEmitter {
|
||||
}
|
||||
101
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/GmbalMBeanNOPImpl.java
Normal file
101
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/GmbalMBeanNOPImpl.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import javax.management.Attribute;
|
||||
import javax.management.AttributeList;
|
||||
import javax.management.AttributeNotFoundException;
|
||||
import javax.management.InvalidAttributeValueException;
|
||||
import javax.management.ListenerNotFoundException;
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.MBeanNotificationInfo;
|
||||
import javax.management.NotificationFilter;
|
||||
import javax.management.NotificationListener;
|
||||
import javax.management.ReflectionException;
|
||||
|
||||
/** A simple no-op implementation of GmbalMBean for use in the no-op impl of
|
||||
* ManagedObjectManager.
|
||||
*
|
||||
* @author ken
|
||||
*/
|
||||
public class GmbalMBeanNOPImpl implements GmbalMBean {
|
||||
public Object getAttribute(String attribute)
|
||||
throws AttributeNotFoundException, MBeanException, ReflectionException {
|
||||
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attribute)
|
||||
throws AttributeNotFoundException, InvalidAttributeValueException,
|
||||
MBeanException, ReflectionException {
|
||||
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public AttributeList getAttributes(String[] attributes) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public AttributeList setAttributes(AttributeList attributes) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public Object invoke(String actionName, Object[] params, String[] signature)
|
||||
throws MBeanException, ReflectionException {
|
||||
|
||||
return null ;
|
||||
}
|
||||
|
||||
public MBeanInfo getMBeanInfo() {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void removeNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter, Object handback)
|
||||
throws ListenerNotFoundException {
|
||||
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public void addNotificationListener(NotificationListener listener,
|
||||
NotificationFilter filter, Object handback) throws IllegalArgumentException {
|
||||
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public void removeNotificationListener(NotificationListener listener)
|
||||
throws ListenerNotFoundException {
|
||||
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public MBeanNotificationInfo[] getNotificationInfo() {
|
||||
return new MBeanNotificationInfo[0] ;
|
||||
}
|
||||
|
||||
}
|
||||
60
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/Impact.java
Normal file
60
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/Impact.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ken
|
||||
*/
|
||||
public enum Impact {
|
||||
/** Indicates that an action is read-like, generally only returning
|
||||
* information without modifying any state.
|
||||
* Corresponds to MBeanOperationInfo.INFO.
|
||||
*/
|
||||
INFO,
|
||||
|
||||
/** Indicates that an action is write-like, and may modify the state
|
||||
* of an MBean in some way.
|
||||
* Corresponds to MBeanOperationInfo.ACTION.
|
||||
*/
|
||||
ACTION,
|
||||
|
||||
/** Indicates that an action is both read-like and write-like.
|
||||
* Corresponds to MBeanOperationInfo.ACTION_INFO.
|
||||
*/
|
||||
ACTION_INFO,
|
||||
|
||||
/** Indicates that an action has an unknown nature.
|
||||
* Corresponds to MBeanOperationInfo.UNKNOWN.
|
||||
*/
|
||||
UNKNOWN
|
||||
}
|
||||
51
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/IncludeSubclass.java
Normal file
51
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/IncludeSubclass.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation is applied to a class or interface representing ManagedData
|
||||
* to indicate that the
|
||||
* listed subclasses should have their attributes included in the corresponding
|
||||
* CompositeData of the superclass. Any given instance of this class will have
|
||||
* values for those attributes that are defined in the parent class
|
||||
* or the subclass for the particular type of the instance.
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface IncludeSubclass {
|
||||
/** List of subclasses that should be analyzed for attributes and operations.
|
||||
*
|
||||
* @return List of classes.
|
||||
*/
|
||||
Class[] value() ;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation defines an attribute in open MBean (ManagedObject) or
|
||||
* CompositeData (ManagedData). It is useful in cases where the parent class
|
||||
* cannot be annotated (for example, Object.toString(), or a framework class
|
||||
* that must be extended
|
||||
* but cannot be modified). The attribute id is defined in the annotation, and
|
||||
* it is implemented by the methods inherited by the Managed entity.
|
||||
* <p>
|
||||
* An example of a use of this is to handle @ManagedData that inherits from
|
||||
* Collection<X>, and it is desired to display a read-only attribute containing
|
||||
* the elements of the Collection. Simple add the annotation
|
||||
* <p>
|
||||
* @InheritedAttribute( methodName="iterator" )
|
||||
* <p>
|
||||
* to handle this case. Note that this only supports read-only attributes.
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface InheritedAttribute {
|
||||
/** The description of the attribute. Can be a key to a resource
|
||||
* bundle for I18N support. Note that this needs a description, otherwise
|
||||
* the InheritedAttributes annotation won't work. The Description
|
||||
* annotation is used in all other cases. The description cannot be
|
||||
* empty.
|
||||
* @return The description.
|
||||
*/
|
||||
String description() ;
|
||||
|
||||
/** The name of the attribute, This class must inherit a method whose name
|
||||
* corresponds to this id in one of the standard ways.
|
||||
* @return The ID.
|
||||
*/
|
||||
String id() default "" ;
|
||||
|
||||
/** The name of the method implementing this attribute. At least one of
|
||||
* id and methodName must not be empty. If only one is given, the other
|
||||
* is derived according to the extended attribute name rules.
|
||||
*/
|
||||
String methodName() default "" ;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation defines one or more attributes inherited from a superclass.
|
||||
* It is simply a way to include multiple InheritedAttribute annotations on a
|
||||
* single class.
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface InheritedAttributes {
|
||||
InheritedAttribute[] value() ;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation defines an attribute in either CompositeData (ManagedData) or
|
||||
* an open MBean (ManagedObject). An attribute may be read/write (has a setter
|
||||
* and a getter), read only (only has a getter),
|
||||
* or write only (only has a setter) depending on the declared methods in the class.
|
||||
* <p>
|
||||
* A method defines a getter if it returns a non-void type and takes no argument types.
|
||||
* Likewise a method defines a setter if it return void and takes exactly one
|
||||
* argument.
|
||||
* <p>An id is derived from a method name as follows:
|
||||
* <ol>
|
||||
* <li>If the method is a getter, and has a name of the form getXXX, the derived
|
||||
* id is xXX (note the initial lower case change).
|
||||
* <li>If the method is a getter with a boolean return type, and has a name of
|
||||
* the form isXXX, the derived id is xXX
|
||||
* <li>If the method is a setter, and has a name of the form setXXX, the
|
||||
* detived id is xXX.
|
||||
* <li>Otherwise the derived ID is the method name.
|
||||
* </ol>
|
||||
* <p>
|
||||
* In certain cases, a field annotated with @ManagedAttribute
|
||||
* may also represent a read-only attribute.
|
||||
* The field must be final, and its type must be one of:
|
||||
* <ol>
|
||||
* <li>A primitive type (boolean, byte, short, char, int, long, float, double)
|
||||
* <li>A primitive type wrapper (Boolean, Byte, Short, Character, Integer,
|
||||
* Long, Float, Double)
|
||||
* <li>A String
|
||||
* <li>A BigDecimal or BigInteger
|
||||
* <li>A java.util.Date
|
||||
* <li>An ObjectName
|
||||
* <li>An enum (which is translated to its ordinal name)
|
||||
* </ol>
|
||||
* Any such field can be accessed safely by multiple threads, because its value
|
||||
* cannot change after an instance of the containing class has completed its
|
||||
* constructor. Note that Date is not truly immutable (it should be!), but it's
|
||||
* one of the Open MBean simple types, so it is included here.
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.METHOD,ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ManagedAttribute {
|
||||
/** The id of the attribute. Defaults to value derived from method name.
|
||||
* @return The id (default "").
|
||||
*/
|
||||
String id() default "" ;
|
||||
}
|
||||
65
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/ManagedData.java
Normal file
65
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/ManagedData.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation defines CompositeData. An interface or class annotated as @ManagedData
|
||||
* has a corresponding CompositeData instance constructed according to the @ManagedAttribute
|
||||
* annotations on its methods. All inherited annotated methods are included.
|
||||
* In the case of conflicts, the most derived method is used (that is the method
|
||||
* declared in the method
|
||||
* closest to the class annotated as @ManagedData).
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ManagedData {
|
||||
/** The name of the ManagedData.
|
||||
* <P>
|
||||
* Gmbal determines the ManagedData name as follows:
|
||||
* <ol>
|
||||
* <li>If the class has a final static field of type String with the
|
||||
* name "GMBAL_TYPE", the value of the field is the ManagedData name.
|
||||
* <li>Otherwise, if the class has an @ManagedData annotation, and the
|
||||
* value of the name is not "", the value of the name is the ManagedData name.
|
||||
* <li>Otherwise, if the package prefix of the class name matches one of
|
||||
* the type prefixes added by an stripPrefix call to the ManagedObjectManager,
|
||||
* the ManagedData name is the full class name with the matching prefix removed.
|
||||
* <li>Otherwise, if the stripPackagePrefix method was called on the
|
||||
* ManagedObjectManager, the ManagedData name is the class name without any
|
||||
* package prefixes.
|
||||
* <li>Otherwise, the ManagedData name is the class name.
|
||||
* </ol>
|
||||
*
|
||||
*/
|
||||
String name() default "" ;
|
||||
}
|
||||
43
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/ManagedObject.java
Normal file
43
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/ManagedObject.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation defines a Managed Object. An interface or class annotated as ManagedObject
|
||||
* has a corresponding open MBean constructed according to the ManagedAttribute and
|
||||
* ManagedOperation annotations on its methods.
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ManagedObject {
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.util.ResourceBundle ;
|
||||
|
||||
import java.io.Closeable ;
|
||||
|
||||
import java.lang.reflect.AnnotatedElement ;
|
||||
import java.lang.annotation.Annotation ;
|
||||
|
||||
import javax.management.ObjectName ;
|
||||
import javax.management.MBeanServer ;
|
||||
|
||||
/** An interface used to managed Open MBeans created from annotated
|
||||
* objects. This is mostly a facade over MBeanServer.
|
||||
* Note that certain methods must be called in the correct order:
|
||||
* <ol>
|
||||
* <li> Methods suspendJMXRegistration, resumeJMXRegistration,
|
||||
* getDomain, getMBeanServer, getResourceBundle, setRuntimeDebug,
|
||||
* setRegistrationDebugLevel, setTypelibDebug, and close may be
|
||||
* called at any time.
|
||||
* <li> All calls to addAnnotation, stripPrefix, and
|
||||
* stripPackageName must occur before any call to a createRoot method.
|
||||
* <li>All of the register and registerAtRoot methods and unregister, getObject,
|
||||
* getObjectName, and dumpSkeleton may only be called after
|
||||
* a createRoot method is called.
|
||||
* <li>Only one call to a createRoot method is permitted on any
|
||||
* ManagedObjectManager.
|
||||
* <li>A call to close returns the MOM to the pre-createRoot state.
|
||||
* </ol>
|
||||
* If these constraints are violated, an IllegalStateException is thrown.
|
||||
*/
|
||||
|
||||
public interface ManagedObjectManager extends Closeable {
|
||||
/** If called, no MBeans created after this call will be registered with
|
||||
* the JMX MBeanServer until resumeJMXRegistration is called. Each call
|
||||
* increments a counter, so that nested and overlapping calls from multiple
|
||||
* threads work correctly.
|
||||
* May be called at any time.
|
||||
*/
|
||||
void suspendJMXRegistration() ;
|
||||
|
||||
/** Decrements the suspend counter, if the counter is greater than 0.
|
||||
* When the counter goes to zero, it causes all MBeans created since
|
||||
* a previous call to suspendJMXRegistration incremented the counter from 0 to 1
|
||||
* to be registered with the JMX MBeanServer. After this call, all new
|
||||
* MBean registration calls to the JMX MBeanServer happen within the
|
||||
* register call.
|
||||
* May be called at any time.
|
||||
*/
|
||||
void resumeJMXRegistration() ;
|
||||
|
||||
/** Return true if object is assignment compatible with a class or interface
|
||||
* that has an @ManagedObject annotation, otherwise false. Only such objects
|
||||
* may be registered to create MBeans.
|
||||
* May be called at any time.
|
||||
*/
|
||||
boolean isManagedObject( Object obj ) ;
|
||||
|
||||
/** Create a default root MBean.
|
||||
* One of the createRoot methods must be called before any of the registration
|
||||
* methods may be called.
|
||||
* Only one call to a createRoot method is permitted after an
|
||||
* ManagedObjectManager is created.
|
||||
* @exception IllegalStateException if called after a call to any
|
||||
* createRoot method.
|
||||
* @return A default root MBean which supports only the AMX attributes.
|
||||
*/
|
||||
GmbalMBean createRoot() ;
|
||||
|
||||
/** Create a root MBean from root, which much have a method with the
|
||||
* @NameValue annotation.
|
||||
* One of the createRoot methods must be called before any of the registration
|
||||
* methods may be called.
|
||||
* Only one call to createRoot is permitted after an ManagedObjectManager
|
||||
* is created.
|
||||
* @param root The Java object to be used to construct the root.
|
||||
* @exception IllegalStateException if called after a call to any
|
||||
* createRoot method.
|
||||
* @return The newly constructed MBean.
|
||||
*/
|
||||
GmbalMBean createRoot( Object root ) ;
|
||||
|
||||
/** Create a root MBean from root with the given name.
|
||||
* One of the createRoot methods must be called before any of the registration
|
||||
* methods may be called.
|
||||
* Only one call to createRoot is permitted after an ManagedObjectManager
|
||||
* is created.
|
||||
* @param root The Java object to be used to construct the root.
|
||||
* @param name The ObjectName name field to be used in the ObjectName of
|
||||
* the MBean constructed from root.
|
||||
* @exception IllegalStateException if called after a call to any
|
||||
* createRoot method.
|
||||
* @return The newly constructed MBean.
|
||||
*/
|
||||
GmbalMBean createRoot( Object root, String name ) ;
|
||||
|
||||
/** Return the root of this ManagedObjectManager.
|
||||
* May be called at any time.
|
||||
* @return the root constructed in a createRoot operation, or null if called
|
||||
* before a createRoot call.
|
||||
*/
|
||||
Object getRoot() ;
|
||||
|
||||
/** Construct an Open Mean for obj according to its annotations,
|
||||
* and register it with domain getDomain() and the appropriate
|
||||
* ObjectName. The MBeanServer from setMBeanServer (or its default) is used.
|
||||
* Here parent is considered to contain obj, and this containment is
|
||||
* represented by the construction of the ObjectName following the AMX
|
||||
* specification for ObjectNames.
|
||||
* <p>
|
||||
* The MBeanInfo for the result is actually ModelMBeanInfo, and may contain
|
||||
* extra metadata as defined using annotations defined with the
|
||||
* @DescriptorKey and @DescriptorField meta-annotations.
|
||||
* <p>
|
||||
* Must be called after a successful createRoot call.
|
||||
* <p>
|
||||
* This version of register should not be used to register singletons.
|
||||
* </ol>
|
||||
* @param parent The parent object that contains obj.
|
||||
* @param obj The managed object we are registering.
|
||||
* @param name The name to use for registering this object.
|
||||
* @return The MBean constructed from obj.
|
||||
* @exception IllegalStateException if called before a createRoot method is
|
||||
* called successfully.
|
||||
*/
|
||||
GmbalMBean register( Object parent, Object obj, String name ) ;
|
||||
|
||||
/** Same as register( parent, obj, name ), but here the name
|
||||
* is derived from an @NameValue annotation.
|
||||
* <p>
|
||||
* This version of register should also be used to register singletons.
|
||||
*
|
||||
* @param parent The parent object that contains obj.
|
||||
* @param obj The managed object we are registering.
|
||||
* @return The MBean constructed from obj.
|
||||
* @exception IllegalStateException if called before a createRoot method is
|
||||
* called successfully.
|
||||
*/
|
||||
GmbalMBean register( Object parent, Object obj ) ;
|
||||
|
||||
/** Registers the MBean for obj at the root MBean for the ObjectManager,
|
||||
* using the given name. Exactly the same as mom.register( mom.getRoot(),
|
||||
* obj, name ).
|
||||
* <p>
|
||||
* Must be called after a successful createRoot call.
|
||||
* <p>
|
||||
* This version of register should not be used to register singletons.
|
||||
* @param obj The object for which we construct and register an MBean.
|
||||
* @param name The name of the MBean.
|
||||
* @return The MBean constructed from obj.
|
||||
* @exception IllegalStateException if called before a createRoot method is
|
||||
* called successfully.
|
||||
*/
|
||||
GmbalMBean registerAtRoot( Object obj, String name ) ;
|
||||
|
||||
/** Same as registerAtRoot( Object, String ), but here the name
|
||||
* is derived from an @ObjectKeyName annotation. Exactly the same as
|
||||
* mom.register( mom.getRoot(), obj ).
|
||||
* <p>
|
||||
* This version of register should also be used to register singletons.
|
||||
* @param obj The managed object we are registering.
|
||||
* @return The MBean constructed from obj.
|
||||
* @exception IllegalStateException if called before a createRoot method is
|
||||
* called successfully.
|
||||
*/
|
||||
GmbalMBean registerAtRoot( Object obj ) ;
|
||||
|
||||
|
||||
/** Unregister the Open MBean corresponding to obj from the
|
||||
* mbean server.
|
||||
* <p>
|
||||
* Must be called after a successful createRoot call.
|
||||
* @param obj The object originally passed to a register method.
|
||||
*/
|
||||
void unregister( Object obj ) ;
|
||||
|
||||
/** Get the ObjectName for the given object (which must have
|
||||
* been registered via a register call).
|
||||
* <p>
|
||||
* Must be called after a successful createRoot call.
|
||||
* @param obj The object originally passed to a register call.
|
||||
* @return The ObjectName used to register the MBean.
|
||||
*/
|
||||
ObjectName getObjectName( Object obj ) ;
|
||||
|
||||
/** Get an AMXClient instance for the object obj, if obj is registered
|
||||
* as an MBean in this mom.
|
||||
* <p>
|
||||
* Must be called after a successful createRoot call.
|
||||
* @param obj The object corresponding to an MBean.
|
||||
* @return An AMXClient that acts as a proxy for this MBean.
|
||||
*/
|
||||
AMXClient getAMXClient( Object obj ) ;
|
||||
|
||||
/** Get the Object that was registered with the given ObjectName.
|
||||
* Note that getObject and getObjectName are inverse operations.
|
||||
* <p>
|
||||
* Must be called after a successful createRoot call.
|
||||
* @param oname The ObjectName used to register the object.
|
||||
* @return The Object passed to the register call.
|
||||
*/
|
||||
Object getObject( ObjectName oname ) ;
|
||||
|
||||
/** Add a type prefix to strip from type names, to shorten the names for
|
||||
* a better presentation to the user. This may only be called before a
|
||||
* createRot method is called.
|
||||
*
|
||||
* @param str Class package name to strip from type name.
|
||||
* @exception IllegalStateException if called after createRoot method.
|
||||
*/
|
||||
void stripPrefix( String... str ) ;
|
||||
|
||||
/** Change the default type name algorithm so that if nothing else
|
||||
* applies, the entire package prefix is stripped form the Class name.
|
||||
* Otherwise, the full Class name is the type.
|
||||
*
|
||||
* @exception IllegalStateException if called after a createRoot method.
|
||||
*/
|
||||
void stripPackagePrefix() ;
|
||||
|
||||
/** Return the domain name that was used when this ManagedObjectManager
|
||||
* was created. This is the JMX domain that will be used in all ObjectNames
|
||||
* created by this ManagedObjectManager.
|
||||
* <p>
|
||||
* May be called at any time.
|
||||
* @return Get the domain name for this ManagedObjectManager.
|
||||
*/
|
||||
String getDomain() ;
|
||||
|
||||
/** Set the MBeanServer to which all MBeans using this interface
|
||||
* are published. The default value is
|
||||
* java.lang.management.ManagementFactory.getPlatformMBeanServer().
|
||||
* <p>
|
||||
* Must be called before a successful createRoot call.
|
||||
* @param server The MBeanServer to set as the MBeanServer for this
|
||||
* ManagedObjectManager.
|
||||
*/
|
||||
void setMBeanServer( MBeanServer server ) ;
|
||||
|
||||
/** Get the current MBeanServer.
|
||||
* <p>
|
||||
* May be called at any time.
|
||||
* @return The current MBeanServer, either the default, or the value passed
|
||||
* to setMBeanServer.
|
||||
*/
|
||||
MBeanServer getMBeanServer() ;
|
||||
|
||||
/** Set the ResourceBundle to use for getting localized descriptions.
|
||||
* If not set, the description is the value in the annotation.
|
||||
* <p>
|
||||
* Must be called before a successful call to a createRoot method.
|
||||
* @param rb The resource bundle to use. May be null.
|
||||
*/
|
||||
void setResourceBundle( ResourceBundle rb ) ;
|
||||
|
||||
/** Get the resource bundle (if any) set by setResourceBundle.
|
||||
* <p>
|
||||
* May be called at any time.
|
||||
* @return The resource bundle set by setResourceBundle: may be null.
|
||||
*/
|
||||
ResourceBundle getResourceBundle() ;
|
||||
|
||||
/** Method to add an annotation to an element that cannot be modified.
|
||||
* This is typically needed when dealing with an implementation of an
|
||||
* interface that is part of a standardized API, and so the interface
|
||||
* cannot be annotated by modifiying the source code. In some cases the
|
||||
* implementation of the interface also cannot be inherited, because the
|
||||
* implementation is generated by a standardized code generator. Another
|
||||
* possibility is that there are several different implementations of the
|
||||
* standardized interface, and it is undesirable to annotate each
|
||||
* implementation with @InheritedAttributes.
|
||||
* @param element The annotated element (class or method for our purposes).
|
||||
* @param annotation The annotation we wish to add to the element.
|
||||
* @exception IllegalStateException if called after a call to a createRoot
|
||||
* method.
|
||||
*/
|
||||
void addAnnotation( AnnotatedElement element, Annotation annotation ) ;
|
||||
|
||||
/** DebugLevel used to control how much debug info is printed for
|
||||
* registration of objects.
|
||||
*/
|
||||
public enum RegistrationDebugLevel { NONE, NORMAL, FINE } ;
|
||||
|
||||
/** Print debug output to System.out.
|
||||
* <p>
|
||||
* May be called at any time.
|
||||
*
|
||||
* @param level NONE is no debugging at all, NORMAL traces high-level
|
||||
* construction of skeletons and type converters, and dumps results of new
|
||||
* skeletons and type converters, FINE traces everything in great detail.
|
||||
* The tracing is done with INFO-level logger calls. The logger name is
|
||||
* that package name (com.sun.org.glassfish.gmbal.impl).
|
||||
*/
|
||||
void setRegistrationDebug( RegistrationDebugLevel level ) ;
|
||||
|
||||
/** Enable generation of debug log at INFO level for runtime MBean operations
|
||||
* to the com.sun.org.glassfish.gmbal.impl logger.
|
||||
* <p>
|
||||
* May be called at any time.
|
||||
*
|
||||
* @param flag true to enable runtime debug, false to disable.
|
||||
*/
|
||||
void setRuntimeDebug( boolean flag ) ;
|
||||
|
||||
/** Enabled generation of debug log for type evaluator debugging. This
|
||||
* happens as part of the registration process for the first time a particular
|
||||
* class is processed.
|
||||
* <p>
|
||||
* May be called at any time.
|
||||
*
|
||||
* @param level set to 1 to just see the results of the TypeEvaluator, >1 to
|
||||
* see lots of details. WARNING: values >1 will result in a large amount
|
||||
* of output.
|
||||
*/
|
||||
void setTypelibDebug( int level ) ;
|
||||
|
||||
/** Set debugging for JMX registrations. If true, all registrations and
|
||||
* deregistrations with the MBeanServer are traced.
|
||||
*
|
||||
* @param flag True to enalbed registration tracing.
|
||||
*/
|
||||
void setJMXRegistrationDebug( boolean flag ) ;
|
||||
|
||||
/** Dump the skeleton used in the implementation of the MBean for obj.
|
||||
* Obj must be currently registered.
|
||||
* <p>
|
||||
* Must be called after a successful call to a createRoot method.
|
||||
*
|
||||
* @param obj The registered object whose skeleton should be displayed.
|
||||
* @return The string representation of the skeleton.
|
||||
*/
|
||||
String dumpSkeleton( Object obj ) ;
|
||||
|
||||
/** Suppress reporting of a duplicate root name. If this option is enabled,
|
||||
* createRoot( Object ) and createRoot( Object, String ) will return null
|
||||
* for a duplicate root name, otherwise a Gmbal error will be reported.
|
||||
* Note that this applies ONLY to createRoot: the register methods are
|
||||
* unaffected. Also note that any other errors that might occur on
|
||||
* createRoot will be reported normally.
|
||||
* <p>
|
||||
* Must be called before a successful call to a createRoot method.
|
||||
*/
|
||||
void suppressDuplicateRootReport( boolean suppressReport ) ;
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.reflect.Method ;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import com.sun.org.glassfish.gmbal.util.GenericConstructor ;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/** Factory used to create ManagedObjectManager instances.
|
||||
*/
|
||||
public final class ManagedObjectManagerFactory {
|
||||
private ManagedObjectManagerFactory() {}
|
||||
|
||||
private static GenericConstructor<ManagedObjectManager> objectNameCons =
|
||||
new GenericConstructor<ManagedObjectManager>(
|
||||
ManagedObjectManager.class,
|
||||
"com.sun.org.glassfish.gmbal.impl.ManagedObjectManagerImpl",
|
||||
ObjectName.class ) ;
|
||||
|
||||
|
||||
private static GenericConstructor<ManagedObjectManager> stringCons =
|
||||
new GenericConstructor<ManagedObjectManager>(
|
||||
ManagedObjectManager.class,
|
||||
"com.sun.org.glassfish.gmbal.impl.ManagedObjectManagerImpl",
|
||||
String.class ) ;
|
||||
|
||||
/** Convenience method for getting access to a method through reflection.
|
||||
* Same as Class.getDeclaredMethod, but only throws RuntimeExceptions.
|
||||
* @param cls The class to search for a method.
|
||||
* @param name The method name.
|
||||
* @param types The array of argument types.
|
||||
* @return The Method if found.
|
||||
* @throws GmbalException if no such method is found.
|
||||
*/
|
||||
public static Method getMethod( final Class<?> cls, final String name,
|
||||
final Class<?>... types ) {
|
||||
|
||||
try {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Method>() {
|
||||
public Method run() throws Exception {
|
||||
return cls.getDeclaredMethod(name, types);
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException ex) {
|
||||
throw new GmbalException( "Unexpected exception", ex ) ;
|
||||
} catch (SecurityException exc) {
|
||||
throw new GmbalException( "Unexpected exception", exc ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/** Create a new ManagedObjectManager. All objectnames created will share
|
||||
* the domain value passed on this call. This ManagedObjectManager is
|
||||
* at the top of the containment hierarchy: the parent of the root is null.
|
||||
* @param domain The domain to use for all ObjectNames created when
|
||||
* MBeans are registered.
|
||||
* @return A new ManagedObjectManager.
|
||||
*/
|
||||
public static ManagedObjectManager createStandalone(
|
||||
final String domain ) {
|
||||
|
||||
ManagedObjectManager result = stringCons.create( domain ) ;
|
||||
if (result == null) {
|
||||
return ManagedObjectManagerNOPImpl.self ;
|
||||
} else {
|
||||
return result ;
|
||||
}
|
||||
}
|
||||
|
||||
/** Alternative form of the create method to be used when the
|
||||
* rootName is not needed explicitly. If the root name is available
|
||||
* from an @ObjectNameKey annotation, it is used; otherwise the
|
||||
* type is used as the name, since the root is a singleton.
|
||||
*
|
||||
* @param rootParentName The JMX ObjectName of the parent of the root.
|
||||
* The parent is outside of the control of this ManagedObjectManager.
|
||||
* The ManagedObjectManager root is a child of the MBean identified
|
||||
* by the rootParentName.
|
||||
* @return The ManagedObjectManager.
|
||||
*/
|
||||
public static ManagedObjectManager createFederated(
|
||||
final ObjectName rootParentName ) {
|
||||
|
||||
ManagedObjectManager result = objectNameCons.create( rootParentName ) ;
|
||||
if (result == null) {
|
||||
return ManagedObjectManagerNOPImpl.self ;
|
||||
} else {
|
||||
return result ;
|
||||
}
|
||||
}
|
||||
|
||||
/** Return a ManagedObjectManager that performs no operations. Useful to
|
||||
* allow the same code to run with or without creating MBeans through
|
||||
* gmbal.
|
||||
* @return ManagedObjectManager that performs no operations.
|
||||
*/
|
||||
public static ManagedObjectManager createNOOP() {
|
||||
return ManagedObjectManagerNOPImpl.self ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.ResourceBundle;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/** NOP impl of ManagedObjectManager used when annotations and ManagedObjectManager
|
||||
* are needed, but MBeans are not. This allows using gmbal to optionally support
|
||||
* MBeans. This is the implementation of the ManagedObjectManager that is used when
|
||||
* the full implementation is not available.
|
||||
*
|
||||
* @author ken_admin
|
||||
*/
|
||||
class ManagedObjectManagerNOPImpl implements ManagedObjectManager {
|
||||
static final ManagedObjectManager self =
|
||||
new ManagedObjectManagerNOPImpl() ;
|
||||
private static final GmbalMBean gmb =
|
||||
new GmbalMBeanNOPImpl() ;
|
||||
|
||||
private ManagedObjectManagerNOPImpl() {}
|
||||
|
||||
public void suspendJMXRegistration() {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public void resumeJMXRegistration() {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public boolean isManagedObject( Object obj ) {
|
||||
return false ;
|
||||
}
|
||||
|
||||
public GmbalMBean createRoot() {
|
||||
return gmb ;
|
||||
}
|
||||
|
||||
public GmbalMBean createRoot(Object root) {
|
||||
return gmb ;
|
||||
}
|
||||
|
||||
public GmbalMBean createRoot(Object root, String name) {
|
||||
return gmb ;
|
||||
}
|
||||
|
||||
public Object getRoot() {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public GmbalMBean register(Object parent, Object obj, String name) {
|
||||
return gmb ;
|
||||
}
|
||||
|
||||
public GmbalMBean register(Object parent, Object obj) {
|
||||
return gmb ;
|
||||
}
|
||||
|
||||
public GmbalMBean registerAtRoot(Object obj, String name) {
|
||||
return gmb ;
|
||||
}
|
||||
|
||||
public GmbalMBean registerAtRoot(Object obj) {
|
||||
return gmb ;
|
||||
}
|
||||
|
||||
public void unregister(Object obj) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public ObjectName getObjectName(Object obj) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public Object getObject(ObjectName oname) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void stripPrefix(String... str) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void setMBeanServer(MBeanServer server) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public MBeanServer getMBeanServer() {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void setResourceBundle(ResourceBundle rb) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public ResourceBundle getResourceBundle() {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void addAnnotation(AnnotatedElement element, Annotation annotation) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public void setRegistrationDebug(RegistrationDebugLevel level) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public void setRuntimeDebug(boolean flag) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public String dumpSkeleton(Object obj) {
|
||||
return "" ;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public void setTypelibDebug(int level) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public void stripPackagePrefix() {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public void suppressDuplicateRootReport(boolean suppressReport) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
public AMXClient getAMXClient(Object obj) {
|
||||
return null ;
|
||||
}
|
||||
|
||||
public void setJMXRegistrationDebug(boolean flag) {
|
||||
// NOP
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation defines an attribute in open MBean (ManagedObject).
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ManagedOperation {
|
||||
/** The id of the operation. Defaults to the method name.
|
||||
*/
|
||||
String id() default "" ;
|
||||
|
||||
Impact impact() default Impact.UNKNOWN ;
|
||||
}
|
||||
43
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/NameValue.java
Normal file
43
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/NameValue.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation is applied to a method that takes no arguments and returns a value
|
||||
* that is converted into a String for use in the ObjectName when an instance of the enclosing
|
||||
* class is used to construct an open MBean.
|
||||
*/
|
||||
@Documented
|
||||
@Target( { ElementType.METHOD, ElementType.FIELD } )
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface NameValue {
|
||||
}
|
||||
48
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/ParameterNames.java
Normal file
48
jdkSrc/jdk8/com/sun/org/glassfish/gmbal/ParameterNames.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal;
|
||||
|
||||
import java.lang.annotation.Documented ;
|
||||
import java.lang.annotation.Target ;
|
||||
import java.lang.annotation.ElementType ;
|
||||
import java.lang.annotation.Retention ;
|
||||
import java.lang.annotation.RetentionPolicy ;
|
||||
|
||||
/** This annotation is applied to a method that represents an MBean operation.
|
||||
* It defines the names of the parameters of the operation. It must contain
|
||||
* as many arguments as there are parameters in the annotated method.
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/**
|
||||
*
|
||||
* @author ken
|
||||
*/
|
||||
public @interface ParameterNames {
|
||||
String[] value() default {} ;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.sun.org.glassfish.gmbal.util;
|
||||
|
||||
import java.lang.reflect.Constructor ;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/** Class that allows any class to be instantiated via any accessible constructor.
|
||||
* Really a short hand to avoid writing a bunch of reflective code.
|
||||
*/
|
||||
public class GenericConstructor<T> {
|
||||
private final Object lock = new Object() ;
|
||||
|
||||
private String typeName ;
|
||||
private Class<T> resultType ;
|
||||
private Class<?> type ;
|
||||
private Class<?>[] signature ;
|
||||
|
||||
// Use the raw type of the constructor here, because
|
||||
// MethodInfo can only return a raw type for a constructor.
|
||||
// It is not possible to have MethodInfo return a
|
||||
// Constructor<T> because T may not be known at compile time.
|
||||
private Constructor constructor ;
|
||||
|
||||
/** Create a generic of type T for the untyped class cls.
|
||||
* Generally cls is a class that has been generated and loaded, so
|
||||
* no compiled code can depend on the class directly. However, the
|
||||
* generated class probably implements some interface T, represented
|
||||
* here by Class<T>.
|
||||
* @param type The expected type of a create call.
|
||||
* @param className The name of the class to use for a constructor.
|
||||
* @param signature The signature of the desired constructor.
|
||||
* @throws IllegalArgumentException if cls is not a subclass of type.
|
||||
*/
|
||||
public GenericConstructor( final Class<T> type, final String className,
|
||||
final Class<?>... signature ) {
|
||||
this.resultType = type ;
|
||||
this.typeName = className ;
|
||||
this.signature = signature.clone() ;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void getConstructor() {
|
||||
synchronized( lock ) {
|
||||
if ((type == null) || (constructor == null)) {
|
||||
try {
|
||||
type = (Class<T>)Class.forName( typeName ) ;
|
||||
constructor = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Constructor>() {
|
||||
public Constructor run() throws Exception {
|
||||
synchronized( lock ) {
|
||||
return type.getDeclaredConstructor( signature ) ;
|
||||
}
|
||||
}
|
||||
} ) ;
|
||||
} catch (Exception exc) {
|
||||
// Catch all for several checked exceptions: ignore findbugs
|
||||
Logger.getLogger( "com.sun.org.glassfish.gmbal.util" ).log( Level.FINE,
|
||||
"Failure in getConstructor", exc ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Create an instance of type T using the constructor that
|
||||
* matches the given arguments if possible. The constructor
|
||||
* is cached, so an instance of GenericClass should always be
|
||||
* used for the same types of arguments. If a call fails,
|
||||
* a check is made to see if a different constructor could
|
||||
* be used.
|
||||
* @param args The constructor arguments.
|
||||
* @return A new instance of the object.
|
||||
*/
|
||||
public synchronized T create( Object... args ) {
|
||||
synchronized(lock) {
|
||||
T result = null ;
|
||||
|
||||
for (int ctr=0; ctr<=1; ctr++) {
|
||||
getConstructor() ;
|
||||
if (constructor == null) {
|
||||
break ;
|
||||
}
|
||||
|
||||
try {
|
||||
result = resultType.cast( constructor.newInstance( args ) ) ;
|
||||
break ;
|
||||
} catch (Exception exc) {
|
||||
// There are 4 checked exceptions here with identical handling.
|
||||
// Ignore FindBugs complaints.
|
||||
constructor = null ;
|
||||
Logger.getLogger("com.sun.org.glassfish.gmbal.util").
|
||||
log(Level.WARNING, "Error invoking constructor", exc );
|
||||
}
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user