Class ManagedObjectManagerImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,ManagedObjectManagerInternal,ManagedObjectManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interfaceNested classes/interfaces inherited from interface org.glassfish.gmbal.ManagedObjectManager
ManagedObjectManager.RegistrationDebugLevelNested classes/interfaces inherited from interface org.glassfish.gmbal.impl.ManagedObjectManagerInternal
ManagedObjectManagerInternal.AttributeDescriptorType -
Constructor Summary
ConstructorsConstructorDescriptionManagedObjectManagerImpl(String domain) ManagedObjectManagerImpl(ObjectName rootParentName) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(AnnotatedElement element, Annotation annotation) Method to add an annotation to an element that cannot be modified.voidaddInheritedAnnotations(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).voidclose()constructMBean(MBeanImpl parentEntity, Object obj, String name) Create a default root MBean.createRoot(Object root) Create a root MBean from root, which much have a method with the @NameValue annotation.createRoot(Object root, String name) Create a root MBean from root with the given name.dumpSkeleton(Object obj) Dump the skeleton used in the implementation of the MBean for obj.<T extends EvaluatedDeclaration>
UnaryPredicate<T>forAnnotation(Class<? extends Annotation> annotation, Class<T> cls) getAMXClient(Object obj) Get an AMXClient instance for the object obj, if obj is registered as an MBean in this mom.<T extends Annotation>
TgetAnnotation(AnnotatedElement element, Class<T> type) getClassAnalyzer(EvaluatedClassDeclaration cls, Class<? extends Annotation> annotationClass) Find the superclass or superinterface of cls (which may be cls itself) that has the given annotationClass as an annotation.getDescription(EvaluatedDeclaration element) Return the domain name that was used when this ManagedObjectManager was created.getFacetAccessor(Object obj) <T extends Annotation>
TgetFirstAnnotationOnClass(EvaluatedClassDeclaration element, Class<T> type) Get the inherited attributes from the EvaluatedClassAnalyzer.Get the current MBeanServer.getObject(ObjectName oname) Get the Object that was registered with the given ObjectName.getObjectName(Object obj) Get the ObjectName for the given object (which must have been registered via a register call).Return an ObjectRegistrationManager as required in the pfl timer services.Get the resource bundle (if any) set by setResourceBundle.getRoot()Return the root of this ManagedObjectManager.Construct or lookup the TypeConverter for the given type.getTypeName(Class<?> cls, String fieldName, String nameFromAnnotation) booleanisAMXAttributeName(String name) booleanisManagedObject(Object obj) Return true if object is assignment compatible with a class or interface that has an @ManagedObject annotation, otherwise false.boolean<K,V> void putIfNotPresent(Map<K, V> map, K key, V value) Same as register( parent, obj, name ), but here the name is derived from an @NameValue annotation.Construct an Open Mean for obj according to its annotations, and register it with domain getDomain() and the appropriate ObjectName.registerAtRoot(Object obj) Same as registerAtRoot( Object, String ), but here the name is derived from an @ObjectKeyName annotation.registerAtRoot(Object obj, String name) Registers the MBean for obj at the root MBean for the ObjectManager, using the given name.booleanbooleanvoidDecrements the suspend counter, if the counter is greater than 0.booleanvoidsetJMXRegistrationDebug(boolean flag) Set debugging for JMX registrations.voidsetMBeanServer(MBeanServer server) Set the MBeanServer to which all MBeans using this interface are published.voidPrint debug output to System.out.voidSet the ResourceBundle to use for getting localized descriptions.voidsetRuntimeDebug(boolean flag) Enable generation of debug log at INFO level for runtime MBean operations to the org.glassfish.gmbal.impl logger.voidsetTypelibDebug(int level) Enabled generation of debug log for type evaluator debugging.voidChange the default type name algorithm so that if nothing else applies, the entire package prefix is stripped form the Class name.voidstripPrefix(String... args) Add a type prefix to strip from type names, to shorten the names for a better presentation to the user.voidsuppressDuplicateRootReport(boolean suppressReport) Suppress reporting of a duplicate root name.voidIf called, no MBeans created after this call will be registered with the JMX MBeanServer until resumeJMXRegistration is called.toString()voidunregister(Object obj) Unregister the Open MBean corresponding to obj from the mbean server.
-
Constructor Details
-
ManagedObjectManagerImpl
-
ManagedObjectManagerImpl
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
suspendJMXRegistration
public void suspendJMXRegistration()Description copied from interface:ManagedObjectManagerIf 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:
suspendJMXRegistrationin interfaceManagedObjectManager
-
resumeJMXRegistration
public void resumeJMXRegistration()Description copied from interface:ManagedObjectManagerDecrements 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:
resumeJMXRegistrationin interfaceManagedObjectManager
-
stripPackagePrefix
public void stripPackagePrefix()Description copied from interface:ManagedObjectManagerChange 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:
stripPackagePrefixin interfaceManagedObjectManager
-
toString
-
getRootParentName
- Specified by:
getRootParentNamein interfaceManagedObjectManagerInternal
-
createRoot
Description copied from interface:ManagedObjectManagerCreate 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:
createRootin interfaceManagedObjectManager- Returns:
- A default root MBean which supports only the AMX attributes.
-
createRoot
Description copied from interface:ManagedObjectManagerCreate 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:
createRootin interfaceManagedObjectManager- Parameters:
root- The Java object to be used to construct the root.- Returns:
- The newly constructed MBean.
-
createRoot
Description copied from interface:ManagedObjectManagerCreate 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:
createRootin 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
Description copied from interface:ManagedObjectManagerReturn the root of this ManagedObjectManager. May be called at any time.- Specified by:
getRootin interfaceManagedObjectManager- Returns:
- the root constructed in a createRoot operation, or null if called before a createRoot call.
-
getTypeConverter
Description copied from interface:ManagedObjectManagerInternalConstruct or lookup the TypeConverter for the given type.- Specified by:
getTypeConverterin interfaceManagedObjectManagerInternal- Parameters:
type- The type for which we need a TypeConverter.- Returns:
- The type converter.
-
getTypeName
- Specified by:
getTypeNamein interfaceManagedObjectManagerInternal
-
isManagedObject
Description copied from interface:ManagedObjectManagerReturn 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:
isManagedObjectin interfaceManagedObjectManager
-
constructMBean
- Specified by:
constructMBeanin interfaceManagedObjectManagerInternal
-
register
Description copied from interface:ManagedObjectManagerConstruct 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:
registerin 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
Description copied from interface:ManagedObjectManagerSame 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:
registerin interfaceManagedObjectManager- Parameters:
parent- The parent object that contains obj.obj- The managed object we are registering.- Returns:
- The MBean constructed from obj.
-
registerAtRoot
Description copied from interface:ManagedObjectManagerRegisters 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:
registerAtRootin 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
Description copied from interface:ManagedObjectManagerSame 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:
registerAtRootin interfaceManagedObjectManager- Parameters:
obj- The managed object we are registering.- Returns:
- The MBean constructed from obj.
-
unregister
Description copied from interface:ManagedObjectManagerUnregister the Open MBean corresponding to obj from the mbean server.Must be called after a successful createRoot call.
- Specified by:
unregisterin interfaceManagedObjectManager- Parameters:
obj- The object originally passed to a register method.
-
getObjectName
Description copied from interface:ManagedObjectManagerGet 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:
getObjectNamein interfaceManagedObjectManager- Parameters:
obj- The object originally passed to a register call.- Returns:
- The ObjectName used to register the MBean.
-
getAMXClient
Description copied from interface:ManagedObjectManagerGet 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:
getAMXClientin interfaceManagedObjectManager- Parameters:
obj- The object corresponding to an MBean.- Returns:
- An AMXClient that acts as a proxy for this MBean.
-
getObject
Description copied from interface:ManagedObjectManagerGet 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:
getObjectin interfaceManagedObjectManager- Parameters:
oname- The ObjectName used to register the object.- Returns:
- The Object passed to the register call.
-
getFacetAccessor
- Specified by:
getFacetAccessorin interfaceManagedObjectManagerInternal
-
getDomain
Description copied from interface:ManagedObjectManagerReturn 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:
getDomainin interfaceManagedObjectManager- Returns:
- Get the domain name for this ManagedObjectManager.
-
setMBeanServer
Description copied from interface:ManagedObjectManagerSet 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:
setMBeanServerin interfaceManagedObjectManager- Parameters:
server- The MBeanServer to set as the MBeanServer for this ManagedObjectManager.
-
getMBeanServer
Description copied from interface:ManagedObjectManagerGet the current MBeanServer.May be called at any time.
- Specified by:
getMBeanServerin interfaceManagedObjectManager- Returns:
- The current MBeanServer, either the default, or the value passed to setMBeanServer.
-
setResourceBundle
Description copied from interface:ManagedObjectManagerSet 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:
setResourceBundlein interfaceManagedObjectManager- Parameters:
rb- The resource bundle to use. May be null.
-
getResourceBundle
Description copied from interface:ManagedObjectManagerGet the resource bundle (if any) set by setResourceBundle.May be called at any time.
- Specified by:
getResourceBundlein interfaceManagedObjectManager- Returns:
- The resource bundle set by setResourceBundle: may be null.
-
getDescription
- Specified by:
getDescriptionin interfaceManagedObjectManagerInternal
-
addAnnotation
Description copied from interface:ManagedObjectManagerMethod 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:
addAnnotationin interfaceManagedObjectManager- Parameters:
element- The annotated element (class or method for our purposes).annotation- The annotation we wish to add to the element.
-
addInheritedAnnotations
Description copied from interface:ManagedObjectManagerAdd 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:
addInheritedAnnotationsin interfaceManagedObjectManager- Parameters:
cls- Class to analyze for inherited annotations.
-
getFirstAnnotationOnClass
public <T extends Annotation> T getFirstAnnotationOnClass(EvaluatedClassDeclaration element, Class<T> type) - Specified by:
getFirstAnnotationOnClassin interfaceManagedObjectManagerInternal
-
getAnnotation
- Specified by:
getAnnotationin interfaceManagedObjectManagerInternal
-
getAnnotations
- Specified by:
getAnnotationsin interfaceManagedObjectManagerInternal
-
getClassAnalyzer
public Pair<EvaluatedClassDeclaration,EvaluatedClassAnalyzer> getClassAnalyzer(EvaluatedClassDeclaration cls, Class<? extends Annotation> annotationClass) Description copied from interface:ManagedObjectManagerInternalFind 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:
getClassAnalyzerin 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
Description copied from interface:ManagedObjectManagerInternalGet the inherited attributes from the EvaluatedClassAnalyzer.- Specified by:
getInheritedAttributesin interfaceManagedObjectManagerInternal- Parameters:
ca- The ClassAnalyzer to check for InheritedAttribute(s).- Returns:
- The inherited attributes.
-
putIfNotPresent
- Specified by:
putIfNotPresentin interfaceManagedObjectManagerInternal
-
getAttributes
public Pair<Map<String,AttributeDescriptor>, getAttributesMap<String, AttributeDescriptor>> (EvaluatedClassAnalyzer ca, ManagedObjectManagerInternal.AttributeDescriptorType adt) - Specified by:
getAttributesin interfaceManagedObjectManagerInternal
-
setRegistrationDebug
Description copied from interface:ManagedObjectManagerPrint debug output to System.out.May be called at any time.
- Specified by:
setRegistrationDebugin 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:ManagedObjectManagerSet debugging for JMX registrations. If true, all registrations and deregistrations with the MBeanServer are traced.- Specified by:
setJMXRegistrationDebugin interfaceManagedObjectManager- Parameters:
flag- True to enalbed registration tracing.
-
setRuntimeDebug
public void setRuntimeDebug(boolean flag) Description copied from interface:ManagedObjectManagerEnable 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:
setRuntimeDebugin interfaceManagedObjectManager- Parameters:
flag- true to enable runtime debug, false to disable.
-
setTypelibDebug
public void setTypelibDebug(int level) Description copied from interface:ManagedObjectManagerEnabled 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:
setTypelibDebugin 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
Description copied from interface:ManagedObjectManagerDump 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:
dumpSkeletonin interfaceManagedObjectManager- Parameters:
obj- The registered object whose skeleton should be displayed.- Returns:
- The string representation of the skeleton.
-
registrationDebug
public boolean registrationDebug()- Specified by:
registrationDebugin interfaceManagedObjectManagerInternal
-
registrationFineDebug
public boolean registrationFineDebug()- Specified by:
registrationFineDebugin interfaceManagedObjectManagerInternal
-
runtimeDebug
public boolean runtimeDebug()- Specified by:
runtimeDebugin interfaceManagedObjectManagerInternal
-
jmxRegistrationDebug
public boolean jmxRegistrationDebug()- Specified by:
jmxRegistrationDebugin interfaceManagedObjectManagerInternal
-
stripPrefix
Description copied from interface:ManagedObjectManagerAdd 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:
stripPrefixin interfaceManagedObjectManager- Parameters:
args- Class package name to strip from type name.
-
forAnnotation
public <T extends EvaluatedDeclaration> UnaryPredicate<T> forAnnotation(Class<? extends Annotation> annotation, Class<T> cls) - Specified by:
forAnnotationin interfaceManagedObjectManagerInternal
-
getDefaultAMXMetadata
- Specified by:
getDefaultAMXMetadatain interfaceManagedObjectManagerInternal
-
isAMXAttributeName
- Specified by:
isAMXAttributeNamein interfaceManagedObjectManagerInternal
-
suppressDuplicateRootReport
public void suppressDuplicateRootReport(boolean suppressReport) Description copied from interface:ManagedObjectManagerSuppress 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:
suppressDuplicateRootReportin interfaceManagedObjectManager
-
getObjectRegistrationManager
Description copied from interface:ManagedObjectManagerReturn an ObjectRegistrationManager as required in the pfl timer services.Can be called at any time.
- Specified by:
getObjectRegistrationManagerin interfaceManagedObjectManager
-