Class ManagedObjectManagerImpl
- java.lang.Object
-
- org.glassfish.gmbal.impl.ManagedObjectManagerImpl
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ManagedObjectManagerInternal
,ManagedObjectManager
public class ManagedObjectManagerImpl extends java.lang.Object implements ManagedObjectManagerInternal
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ManagedObjectManagerImpl.ADHolder
(package private) static class
ManagedObjectManagerImpl.DefaultAMXMetadataHolder
static interface
ManagedObjectManagerImpl.DummyAverageRangeStatistic
static interface
ManagedObjectManagerImpl.DummyBoundaryStatistic
static interface
ManagedObjectManagerImpl.DummyBoundedRangeStatistic
static interface
ManagedObjectManagerImpl.DummyCountStatistic
static interface
ManagedObjectManagerImpl.DummyRangeStatistic
static interface
ManagedObjectManagerImpl.DummyStatistic
static interface
ManagedObjectManagerImpl.DummyStringStatistic
static interface
ManagedObjectManagerImpl.DummyTimeStatistic
private static class
ManagedObjectManagerImpl.Root
private static class
ManagedObjectManagerImpl.StringComparator
-
Nested classes/interfaces inherited from interface org.glassfish.gmbal.ManagedObjectManager
ManagedObjectManager.RegistrationDebugLevel
-
Nested classes/interfaces inherited from interface org.glassfish.gmbal.impl.ManagedObjectManagerInternal
ManagedObjectManagerInternal.AttributeDescriptorType
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.reflect.AnnotatedElement,java.util.Map<java.lang.Class,java.lang.annotation.Annotation>>
addedAnnotations
private java.util.Set<java.lang.String>
amxAttributeNames
private MBeanSkeleton
amxSkeleton
private java.util.Map<java.lang.reflect.AnnotatedElement,java.util.Map<java.lang.Class,java.lang.annotation.Annotation>>
annotationCache
private static AMXMetadata
DEFAULT_AMX_METADATA
private java.lang.String
domain
private boolean
jmxRegistrationDebugFlag
private static org.glassfish.pfl.basic.algorithm.ObjectUtility
myObjectUtil
private ObjectRegistrationManager
orm
private ManagedObjectManager.RegistrationDebugLevel
regDebugLevel
private java.util.ResourceBundle
resourceBundle
private static java.util.Comparator<java.lang.String>
REV_COMP
private boolean
rootCreated
private boolean
runDebugFlag
private javax.management.MBeanServer
server
private java.util.Map<EvaluatedClassDeclaration,MBeanSkeleton>
skeletonMap
(package private) java.util.List<org.glassfish.pfl.basic.contain.Pair<java.lang.Class,java.lang.Class>>
statsData
private boolean
stripPackagePrefix
private MBeanTree
tree
private java.util.Map<EvaluatedType,TypeConverter>
typeConverterMap
private java.util.SortedSet<java.lang.String>
typePrefixes
-
Constructor Summary
Constructors Modifier Constructor Description ManagedObjectManagerImpl(java.lang.String domain)
private
ManagedObjectManagerImpl(java.lang.String domain, javax.management.ObjectName rootParentName)
ManagedObjectManagerImpl(javax.management.ObjectName rootParentName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation annotation)
Method to add an annotation to an element that cannot be modified.private void
addAnnotationIfNotNull(java.lang.reflect.AnnotatedElement elemement, java.lang.annotation.Annotation annotation)
void
addInheritedAnnotations(java.lang.Class<?> cls)
Add all annotations for this class as if they were declared on the inheritance parent(s) of the class (immediate superclass for a class, all immediate superinterfaces for an interface).(package private) static void
checkFieldType(EvaluatedFieldDeclaration field)
private void
checkRootCreated(java.lang.String methodName)
private void
checkRootNotCreated(java.lang.String methodName)
void
close()
MBeanImpl
constructMBean(MBeanImpl parentEntity, java.lang.Object obj, java.lang.String name)
GmbalMBean
createRoot()
Create a default root MBean.GmbalMBean
createRoot(java.lang.Object root)
Create a root MBean from root, which much have a method with the @NameValue annotation.GmbalMBean
createRoot(java.lang.Object root, java.lang.String name)
Create a root MBean from root with the given name.private void
describe(java.lang.String msg, java.lang.Object data)
java.lang.String
dumpSkeleton(java.lang.Object obj)
Dump the skeleton used in the implementation of the MBean for obj.<T extends EvaluatedDeclaration>
org.glassfish.pfl.basic.func.UnaryPredicate<T>forAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.Class<T> cls)
private java.util.Map<java.lang.Class,java.lang.annotation.Annotation>
getAllAnnotations(java.lang.Class cls)
AMXClient
getAMXClient(java.lang.Object obj)
Get an AMXClient instance for the object obj, if obj is registered as an MBean in this mom.private java.lang.String
getAMXTypeFromField(java.lang.Class<?> cls, java.lang.String fieldName)
<T extends java.lang.annotation.Annotation>
TgetAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.Class<T> type)
java.util.Collection<java.lang.annotation.Annotation>
getAnnotations(java.lang.reflect.AnnotatedElement elem)
private AttributeDescriptor
getAttributeDescriptorIfInherited(EvaluatedMethodDeclaration method, java.util.List<InheritedAttribute> ias, ManagedObjectManagerInternal.AttributeDescriptorType adt)
org.glassfish.pfl.basic.contain.Pair<java.util.Map<java.lang.String,AttributeDescriptor>,java.util.Map<java.lang.String,AttributeDescriptor>>
getAttributes(EvaluatedClassAnalyzer ca, ManagedObjectManagerInternal.AttributeDescriptorType adt)
org.glassfish.pfl.basic.contain.Pair<EvaluatedClassDeclaration,EvaluatedClassAnalyzer>
getClassAnalyzer(EvaluatedClassDeclaration cls, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Find the superclass or superinterface of cls (which may be cls itself) that has the given annotationClass as an annotation.private static java.lang.reflect.Field
getDeclaredField(java.lang.Class<?> cls, java.lang.String name)
AMXMetadata
getDefaultAMXMetadata()
java.lang.String
getDescription(EvaluatedDeclaration element)
java.lang.String
getDomain()
Return the domain name that was used when this ManagedObjectManager was created.org.glassfish.pfl.basic.facet.FacetAccessor
getFacetAccessor(java.lang.Object obj)
<T extends java.lang.annotation.Annotation>
TgetFirstAnnotationOnClass(EvaluatedClassDeclaration element, java.lang.Class<T> type)
java.util.List<InheritedAttribute>
getInheritedAttributes(EvaluatedClassAnalyzer ca)
Get the inherited attributes from the EvaluatedClassAnalyzer.javax.management.MBeanServer
getMBeanServer()
Get the current MBeanServer.java.lang.Object
getObject(javax.management.ObjectName oname)
Get the Object that was registered with the given ObjectName.javax.management.ObjectName
getObjectName(java.lang.Object obj)
Get the ObjectName for the given object (which must have been registered via a register call).ObjectRegistrationManager
getObjectRegistrationManager()
Return an ObjectRegistrationManager as required in the pfl timer services.java.util.ResourceBundle
getResourceBundle()
Get the resource bundle (if any) set by setResourceBundle.java.lang.Object
getRoot()
Return the root of this ManagedObjectManager.javax.management.ObjectName
getRootParentName()
private MBeanSkeleton
getSkeleton(EvaluatedClassDeclaration cls)
TypeConverter
getTypeConverter(EvaluatedType type)
Construct or lookup the TypeConverter for the given type.java.lang.String
getTypeName(java.lang.Class<?> cls, java.lang.String fieldName, java.lang.String nameFromAnnotation)
private boolean
goodResult(java.lang.String str)
private void
init()
private void
initializeStatisticsSupport()
boolean
isAMXAttributeName(java.lang.String name)
boolean
isManagedObject(java.lang.Object obj)
Return true if object is assignment compatible with a class or interface that has an @ManagedObject annotation, otherwise false.boolean
jmxRegistrationDebug()
private void
message(java.lang.String msg)
<K,V>
voidputIfNotPresent(java.util.Map<K,V> map, K key, V value)
GmbalMBean
register(java.lang.Object parent, java.lang.Object obj)
Same as register( parent, obj, name ), but here the name is derived from an @NameValue annotation.GmbalMBean
register(java.lang.Object parent, java.lang.Object obj, java.lang.String name)
Construct an Open Mean for obj according to its annotations, and register it with domain getDomain() and the appropriate ObjectName.GmbalMBean
registerAtRoot(java.lang.Object obj)
Same as registerAtRoot( Object, String ), but here the name is derived from an @ObjectKeyName annotation.GmbalMBean
registerAtRoot(java.lang.Object obj, java.lang.String name)
Registers the MBean for obj at the root MBean for the ObjectManager, using the given name.boolean
registrationDebug()
boolean
registrationFineDebug()
void
resumeJMXRegistration()
Decrements the suspend counter, if the counter is greater than 0.boolean
runtimeDebug()
void
setJMXRegistrationDebug(boolean flag)
Set debugging for JMX registrations.void
setMBeanServer(javax.management.MBeanServer server)
Set the MBeanServer to which all MBeans using this interface are published.void
setRegistrationDebug(ManagedObjectManager.RegistrationDebugLevel level)
Print debug output to System.out.void
setResourceBundle(java.util.ResourceBundle rb)
Set the ResourceBundle to use for getting localized descriptions.void
setRuntimeDebug(boolean flag)
Enable generation of debug log at INFO level for runtime MBean operations to the org.glassfish.gmbal.impl logger.void
setTypelibDebug(int level)
Enabled generation of debug log for type evaluator debugging.void
stripPackagePrefix()
Change the default type name algorithm so that if nothing else applies, the entire package prefix is stripped form the Class name.void
stripPrefix(java.lang.String... args)
Add a type prefix to strip from type names, to shorten the names for a better presentation to the user.void
suppressDuplicateRootReport(boolean suppressReport)
Suppress reporting of a duplicate root name.void
suspendJMXRegistration()
If called, no MBeans created after this call will be registered with the JMX MBeanServer until resumeJMXRegistration is called.java.lang.String
toString()
void
unregister(java.lang.Object obj)
Unregister the Open MBean corresponding to obj from the mbean server.
-
-
-
Field Detail
-
DEFAULT_AMX_METADATA
private static final AMXMetadata DEFAULT_AMX_METADATA
-
myObjectUtil
private static org.glassfish.pfl.basic.algorithm.ObjectUtility myObjectUtil
-
REV_COMP
private static java.util.Comparator<java.lang.String> REV_COMP
-
domain
@DumpIgnore private final java.lang.String domain
-
tree
private final MBeanTree tree
-
skeletonMap
private final java.util.Map<EvaluatedClassDeclaration,MBeanSkeleton> skeletonMap
-
typeConverterMap
private final java.util.Map<EvaluatedType,TypeConverter> typeConverterMap
-
addedAnnotations
private final java.util.Map<java.lang.reflect.AnnotatedElement,java.util.Map<java.lang.Class,java.lang.annotation.Annotation>> addedAnnotations
-
amxSkeleton
private final MBeanSkeleton amxSkeleton
-
amxAttributeNames
private final java.util.Set<java.lang.String> amxAttributeNames
-
orm
private final ObjectRegistrationManager orm
-
rootCreated
private boolean rootCreated
-
resourceBundle
private java.util.ResourceBundle resourceBundle
-
server
private javax.management.MBeanServer server
-
regDebugLevel
private ManagedObjectManager.RegistrationDebugLevel regDebugLevel
-
runDebugFlag
private boolean runDebugFlag
-
jmxRegistrationDebugFlag
private boolean jmxRegistrationDebugFlag
-
typePrefixes
private final java.util.SortedSet<java.lang.String> typePrefixes
-
stripPackagePrefix
private boolean stripPackagePrefix
-
statsData
java.util.List<org.glassfish.pfl.basic.contain.Pair<java.lang.Class,java.lang.Class>> statsData
-
annotationCache
private java.util.Map<java.lang.reflect.AnnotatedElement,java.util.Map<java.lang.Class,java.lang.annotation.Annotation>> annotationCache
-
-
Constructor Detail
-
ManagedObjectManagerImpl
private ManagedObjectManagerImpl(java.lang.String domain, javax.management.ObjectName rootParentName)
-
ManagedObjectManagerImpl
public ManagedObjectManagerImpl(java.lang.String domain)
-
ManagedObjectManagerImpl
public ManagedObjectManagerImpl(javax.management.ObjectName rootParentName)
-
-
Method Detail
-
addAnnotationIfNotNull
private void addAnnotationIfNotNull(java.lang.reflect.AnnotatedElement elemement, java.lang.annotation.Annotation annotation)
-
initializeStatisticsSupport
private void initializeStatisticsSupport()
-
init
private void init()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
checkRootNotCreated
private void checkRootNotCreated(java.lang.String methodName)
-
checkRootCreated
private void checkRootCreated(java.lang.String methodName)
-
suspendJMXRegistration
public void suspendJMXRegistration()
Description copied from interface:ManagedObjectManager
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.- Specified by:
suspendJMXRegistration
in interfaceManagedObjectManager
-
resumeJMXRegistration
public void resumeJMXRegistration()
Description copied from interface:ManagedObjectManager
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.- Specified by:
resumeJMXRegistration
in interfaceManagedObjectManager
-
stripPackagePrefix
public void stripPackagePrefix()
Description copied from interface:ManagedObjectManager
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.- Specified by:
stripPackagePrefix
in interfaceManagedObjectManager
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getRootParentName
public javax.management.ObjectName getRootParentName()
- Specified by:
getRootParentName
in interfaceManagedObjectManagerInternal
-
createRoot
public GmbalMBean createRoot()
Description copied from interface:ManagedObjectManager
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.- Specified by:
createRoot
in interfaceManagedObjectManager
- Returns:
- A default root MBean which supports only the AMX attributes.
-
createRoot
public GmbalMBean createRoot(java.lang.Object root)
Description copied from interface:ManagedObjectManager
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.- Specified by:
createRoot
in interfaceManagedObjectManager
- Parameters:
root
- The Java object to be used to construct the root.- Returns:
- The newly constructed MBean.
-
createRoot
public GmbalMBean createRoot(java.lang.Object root, java.lang.String name)
Description copied from interface:ManagedObjectManager
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.- Specified by:
createRoot
in interfaceManagedObjectManager
- Parameters:
root
- The Java object to be used to construct the root.name
- The ObjectName name field to be used in the ObjectName of the MBean constructed from root.- Returns:
- The newly constructed MBean.
-
getRoot
public java.lang.Object getRoot()
Description copied from interface:ManagedObjectManager
Return the root of this ManagedObjectManager. May be called at any time.- Specified by:
getRoot
in interfaceManagedObjectManager
- Returns:
- the root constructed in a createRoot operation, or null if called before a createRoot call.
-
message
@InfoMethod private void message(java.lang.String msg)
-
describe
@InfoMethod private void describe(java.lang.String msg, java.lang.Object data)
-
getSkeleton
private MBeanSkeleton getSkeleton(EvaluatedClassDeclaration cls)
-
getTypeConverter
public TypeConverter getTypeConverter(EvaluatedType type)
Description copied from interface:ManagedObjectManagerInternal
Construct or lookup the TypeConverter for the given type.- Specified by:
getTypeConverter
in interfaceManagedObjectManagerInternal
- Parameters:
type
- The type for which we need a TypeConverter.- Returns:
- The type converter.
-
getDeclaredField
private static java.lang.reflect.Field getDeclaredField(java.lang.Class<?> cls, java.lang.String name) throws java.security.PrivilegedActionException, java.lang.NoSuchFieldException
- Throws:
java.security.PrivilegedActionException
java.lang.NoSuchFieldException
-
getAMXTypeFromField
private java.lang.String getAMXTypeFromField(java.lang.Class<?> cls, java.lang.String fieldName)
-
goodResult
private boolean goodResult(java.lang.String str)
-
getTypeName
public java.lang.String getTypeName(java.lang.Class<?> cls, java.lang.String fieldName, java.lang.String nameFromAnnotation)
- Specified by:
getTypeName
in interfaceManagedObjectManagerInternal
-
isManagedObject
public boolean isManagedObject(java.lang.Object obj)
Description copied from interface:ManagedObjectManager
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.- Specified by:
isManagedObject
in interfaceManagedObjectManager
-
constructMBean
public MBeanImpl constructMBean(MBeanImpl parentEntity, java.lang.Object obj, java.lang.String name)
- Specified by:
constructMBean
in interfaceManagedObjectManagerInternal
-
register
public GmbalMBean register(java.lang.Object parent, java.lang.Object obj, java.lang.String name)
Description copied from interface:ManagedObjectManager
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.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.
Must be called after a successful createRoot call.
This version of register should not be used to register singletons.
- Specified by:
register
in interfaceManagedObjectManager
- Parameters:
parent
- The parent object that contains obj.obj
- The managed object we are registering.name
- The name to use for registering this object.- Returns:
- The MBean constructed from obj.
-
register
public GmbalMBean register(java.lang.Object parent, java.lang.Object obj)
Description copied from interface:ManagedObjectManager
Same as register( parent, obj, name ), but here the name is derived from an @NameValue annotation.This version of register should also be used to register singletons.
- Specified by:
register
in interfaceManagedObjectManager
- Parameters:
parent
- The parent object that contains obj.obj
- The managed object we are registering.- Returns:
- The MBean constructed from obj.
-
registerAtRoot
public GmbalMBean registerAtRoot(java.lang.Object obj, java.lang.String name)
Description copied from interface:ManagedObjectManager
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 ).Must be called after a successful createRoot call.
This version of register should not be used to register singletons.
- Specified by:
registerAtRoot
in interfaceManagedObjectManager
- Parameters:
obj
- The object for which we construct and register an MBean.name
- The name of the MBean.- Returns:
- The MBean constructed from obj.
-
registerAtRoot
public GmbalMBean registerAtRoot(java.lang.Object obj)
Description copied from interface:ManagedObjectManager
Same as registerAtRoot( Object, String ), but here the name is derived from an @ObjectKeyName annotation. Exactly the same as mom.register( mom.getRoot(), obj ).This version of register should also be used to register singletons.
- Specified by:
registerAtRoot
in interfaceManagedObjectManager
- Parameters:
obj
- The managed object we are registering.- Returns:
- The MBean constructed from obj.
-
unregister
public void unregister(java.lang.Object obj)
Description copied from interface:ManagedObjectManager
Unregister the Open MBean corresponding to obj from the mbean server.Must be called after a successful createRoot call.
- Specified by:
unregister
in interfaceManagedObjectManager
- Parameters:
obj
- The object originally passed to a register method.
-
getObjectName
public javax.management.ObjectName getObjectName(java.lang.Object obj)
Description copied from interface:ManagedObjectManager
Get the ObjectName for the given object (which must have been registered via a register call).Must be called after a successful createRoot call.
- Specified by:
getObjectName
in interfaceManagedObjectManager
- Parameters:
obj
- The object originally passed to a register call.- Returns:
- The ObjectName used to register the MBean.
-
getAMXClient
public AMXClient getAMXClient(java.lang.Object obj)
Description copied from interface:ManagedObjectManager
Get an AMXClient instance for the object obj, if obj is registered as an MBean in this mom.Must be called after a successful createRoot call.
- Specified by:
getAMXClient
in interfaceManagedObjectManager
- Parameters:
obj
- The object corresponding to an MBean.- Returns:
- An AMXClient that acts as a proxy for this MBean.
-
getObject
public java.lang.Object getObject(javax.management.ObjectName oname)
Description copied from interface:ManagedObjectManager
Get the Object that was registered with the given ObjectName. Note that getObject and getObjectName are inverse operations.Must be called after a successful createRoot call.
- Specified by:
getObject
in interfaceManagedObjectManager
- Parameters:
oname
- The ObjectName used to register the object.- Returns:
- The Object passed to the register call.
-
getFacetAccessor
public org.glassfish.pfl.basic.facet.FacetAccessor getFacetAccessor(java.lang.Object obj)
- Specified by:
getFacetAccessor
in interfaceManagedObjectManagerInternal
-
getDomain
public java.lang.String getDomain()
Description copied from interface:ManagedObjectManager
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.May be called at any time.
- Specified by:
getDomain
in interfaceManagedObjectManager
- Returns:
- Get the domain name for this ManagedObjectManager.
-
setMBeanServer
public void setMBeanServer(javax.management.MBeanServer server)
Description copied from interface:ManagedObjectManager
Set the MBeanServer to which all MBeans using this interface are published. The default value is java.lang.management.ManagementFactory.getPlatformMBeanServer().Must be called before a successful createRoot call.
- Specified by:
setMBeanServer
in interfaceManagedObjectManager
- Parameters:
server
- The MBeanServer to set as the MBeanServer for this ManagedObjectManager.
-
getMBeanServer
public javax.management.MBeanServer getMBeanServer()
Description copied from interface:ManagedObjectManager
Get the current MBeanServer.May be called at any time.
- Specified by:
getMBeanServer
in interfaceManagedObjectManager
- Returns:
- The current MBeanServer, either the default, or the value passed to setMBeanServer.
-
setResourceBundle
public void setResourceBundle(java.util.ResourceBundle rb)
Description copied from interface:ManagedObjectManager
Set the ResourceBundle to use for getting localized descriptions. If not set, the description is the value in the annotation.Must be called before a successful call to a createRoot method.
- Specified by:
setResourceBundle
in interfaceManagedObjectManager
- Parameters:
rb
- The resource bundle to use. May be null.
-
getResourceBundle
public java.util.ResourceBundle getResourceBundle()
Description copied from interface:ManagedObjectManager
Get the resource bundle (if any) set by setResourceBundle.May be called at any time.
- Specified by:
getResourceBundle
in interfaceManagedObjectManager
- Returns:
- The resource bundle set by setResourceBundle: may be null.
-
getDescription
public java.lang.String getDescription(EvaluatedDeclaration element)
- Specified by:
getDescription
in interfaceManagedObjectManagerInternal
-
addAnnotation
public void addAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation annotation)
Description copied from interface:ManagedObjectManager
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.- Specified by:
addAnnotation
in interfaceManagedObjectManager
- Parameters:
element
- The annotated element (class or method for our purposes).annotation
- The annotation we wish to add to the element.
-
addInheritedAnnotations
public void addInheritedAnnotations(java.lang.Class<?> cls)
Description copied from interface:ManagedObjectManager
Add all annotations for this class as if they were declared on the inheritance parent(s) of the class (immediate superclass for a class, all immediate superinterfaces for an interface). Also add all method annotations for methods that override an inherited method. This acts as if all annotations on cls were actually applied to the immediate super class or interface.- Specified by:
addInheritedAnnotations
in interfaceManagedObjectManager
- Parameters:
cls
- Class to analyze for inherited annotations.
-
getFirstAnnotationOnClass
public <T extends java.lang.annotation.Annotation> T getFirstAnnotationOnClass(EvaluatedClassDeclaration element, java.lang.Class<T> type)
- Specified by:
getFirstAnnotationOnClass
in interfaceManagedObjectManagerInternal
-
getAllAnnotations
private java.util.Map<java.lang.Class,java.lang.annotation.Annotation> getAllAnnotations(java.lang.Class cls)
-
getAnnotation
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.Class<T> type)
- Specified by:
getAnnotation
in interfaceManagedObjectManagerInternal
-
getAnnotations
public java.util.Collection<java.lang.annotation.Annotation> getAnnotations(java.lang.reflect.AnnotatedElement elem)
- Specified by:
getAnnotations
in interfaceManagedObjectManagerInternal
-
getClassAnalyzer
public org.glassfish.pfl.basic.contain.Pair<EvaluatedClassDeclaration,EvaluatedClassAnalyzer> getClassAnalyzer(EvaluatedClassDeclaration cls, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Description copied from interface:ManagedObjectManagerInternal
Find the superclass or superinterface of cls (which may be cls itself) that has the given annotationClass as an annotation. If the annotated Class has an IncludeSubclass annotation, add those classes into the EvaluatedClassAnalyzer for the annotated class.- Specified by:
getClassAnalyzer
in interfaceManagedObjectManagerInternal
- Parameters:
cls
- The class for which we need a EvaluatedClassAnalyzer.annotationClass
- The annotation that must be present on cls or a superclass or superinterface.- Returns:
- A Pair of the parent class of cls, and the EvaluatedClassAnalyzer.
-
getInheritedAttributes
public java.util.List<InheritedAttribute> getInheritedAttributes(EvaluatedClassAnalyzer ca)
Description copied from interface:ManagedObjectManagerInternal
Get the inherited attributes from the EvaluatedClassAnalyzer.- Specified by:
getInheritedAttributes
in interfaceManagedObjectManagerInternal
- Parameters:
ca
- The ClassAnalyzer to check for InheritedAttribute(s).- Returns:
- The inherited attributes.
-
getAttributeDescriptorIfInherited
private AttributeDescriptor getAttributeDescriptorIfInherited(EvaluatedMethodDeclaration method, java.util.List<InheritedAttribute> ias, ManagedObjectManagerInternal.AttributeDescriptorType adt)
-
putIfNotPresent
public <K,V> void putIfNotPresent(java.util.Map<K,V> map, K key, V value)
- Specified by:
putIfNotPresent
in interfaceManagedObjectManagerInternal
-
checkFieldType
static void checkFieldType(EvaluatedFieldDeclaration field)
-
getAttributes
public org.glassfish.pfl.basic.contain.Pair<java.util.Map<java.lang.String,AttributeDescriptor>,java.util.Map<java.lang.String,AttributeDescriptor>> getAttributes(EvaluatedClassAnalyzer ca, ManagedObjectManagerInternal.AttributeDescriptorType adt)
- Specified by:
getAttributes
in interfaceManagedObjectManagerInternal
-
setRegistrationDebug
public void setRegistrationDebug(ManagedObjectManager.RegistrationDebugLevel level)
Description copied from interface:ManagedObjectManager
Print debug output to System.out.May be called at any time.
- Specified by:
setRegistrationDebug
in interfaceManagedObjectManager
- Parameters:
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 (org.glassfish.gmbal.impl).
-
setJMXRegistrationDebug
public void setJMXRegistrationDebug(boolean flag)
Description copied from interface:ManagedObjectManager
Set debugging for JMX registrations. If true, all registrations and deregistrations with the MBeanServer are traced.- Specified by:
setJMXRegistrationDebug
in interfaceManagedObjectManager
- Parameters:
flag
- True to enalbed registration tracing.
-
setRuntimeDebug
public void setRuntimeDebug(boolean flag)
Description copied from interface:ManagedObjectManager
Enable generation of debug log at INFO level for runtime MBean operations to the org.glassfish.gmbal.impl logger.May be called at any time.
- Specified by:
setRuntimeDebug
in interfaceManagedObjectManager
- Parameters:
flag
- true to enable runtime debug, false to disable.
-
setTypelibDebug
public void setTypelibDebug(int level)
Description copied from interface:ManagedObjectManager
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.May be called at any time.
- Specified by:
setTypelibDebug
in interfaceManagedObjectManager
- Parameters:
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.
-
dumpSkeleton
public java.lang.String dumpSkeleton(java.lang.Object obj)
Description copied from interface:ManagedObjectManager
Dump the skeleton used in the implementation of the MBean for obj. Obj must be currently registered.Must be called after a successful call to a createRoot method.
- Specified by:
dumpSkeleton
in interfaceManagedObjectManager
- Parameters:
obj
- The registered object whose skeleton should be displayed.- Returns:
- The string representation of the skeleton.
-
registrationDebug
public boolean registrationDebug()
- Specified by:
registrationDebug
in interfaceManagedObjectManagerInternal
-
registrationFineDebug
public boolean registrationFineDebug()
- Specified by:
registrationFineDebug
in interfaceManagedObjectManagerInternal
-
runtimeDebug
public boolean runtimeDebug()
- Specified by:
runtimeDebug
in interfaceManagedObjectManagerInternal
-
jmxRegistrationDebug
public boolean jmxRegistrationDebug()
- Specified by:
jmxRegistrationDebug
in interfaceManagedObjectManagerInternal
-
stripPrefix
public void stripPrefix(java.lang.String... args)
Description copied from interface:ManagedObjectManager
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.- Specified by:
stripPrefix
in interfaceManagedObjectManager
- Parameters:
args
- Class package name to strip from type name.
-
forAnnotation
public <T extends EvaluatedDeclaration> org.glassfish.pfl.basic.func.UnaryPredicate<T> forAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.Class<T> cls)
- Specified by:
forAnnotation
in interfaceManagedObjectManagerInternal
-
getDefaultAMXMetadata
public AMXMetadata getDefaultAMXMetadata()
- Specified by:
getDefaultAMXMetadata
in interfaceManagedObjectManagerInternal
-
isAMXAttributeName
public boolean isAMXAttributeName(java.lang.String name)
- Specified by:
isAMXAttributeName
in interfaceManagedObjectManagerInternal
-
suppressDuplicateRootReport
public void suppressDuplicateRootReport(boolean suppressReport)
Description copied from interface:ManagedObjectManager
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.Must be called before a successful call to a createRoot method.
- Specified by:
suppressDuplicateRootReport
in interfaceManagedObjectManager
-
getObjectRegistrationManager
public ObjectRegistrationManager getObjectRegistrationManager()
Description copied from interface:ManagedObjectManager
Return an ObjectRegistrationManager as required in the pfl timer services.Can be called at any time.
- Specified by:
getObjectRegistrationManager
in interfaceManagedObjectManager
-
-