FileDocCategorySizeDatePackage
MonitoredObjectType.javaAPI DocGlassfish v2 API18033Fri May 04 22:33:44 BST 2007com.sun.enterprise.admin.monitor

MonitoredObjectType

public class MonitoredObjectType extends Object
MonitoredObjectType represents the type of a monitored object. Many of monitored objects have same properties, even while they monitor different user objects. For example - application and standalone ejb module are both nothing more than containers of other objects -- application contains web module and ejb modules, whereas standalone ejb module contains beans of various types. This object facilitates use of same GenericMonitorMBean as MBean for both of them, but still distinguishes them.
see
com.sun.enterprise.admin.monitor.GenericMonitorMBean

Fields Summary
private static final HashMap
objectMap
A map to store all objects of type MonitoredObjectType using their string representation as key.
public static final MonitoredObjectType
ROOT
A root monitored object type
public static final MonitoredObjectType
APPLICATION
A monitored object type of Application
public static final MonitoredObjectType
EJBMODULE
A monitored object type of EJB Module. This denotes ejb modules within an application. For stand alone ejb modules, please use the type MonitoredObjectType.STANDALONE_EJBMODULE
public static final MonitoredObjectType
STANDALONE_EJBMODULE
A monitored object type of standalone EJB Module. This denotes ejb modules not deployed as part of any application. For ejb modules deployed as part of applications, please use the type MonitoredObjectType.EJBMODULE
public static final MonitoredObjectType
WEBMODULE
A monitored object type of Web Module. This denotes web module within an application. For stand alone web modules, please use the type MonitoredObjectType.STANDALONE_WEBMODULE
public static final MonitoredObjectType
STANDALONE_WEBMODULE
A monitored object type of standalone Web Module. This denotes web modules not deployed as part of any application. For web modules deployed as part of applications, please use the type MonitoredObjectType.WEBMODULE
public static final MonitoredObjectType
STATELESS_BEAN
A monitored object type of stateless session bean
public static final MonitoredObjectType
STATEFUL_BEAN
A monitored object type of stateful session bean
public static final MonitoredObjectType
ENTITY_BEAN
A monitored object type of entity bean
public static final MonitoredObjectType
MESSAGE_DRIVEN_BEAN
A monitored object type of message driven bean
public static final MonitoredObjectType
BEAN_POOL
A monitored object type of bean pool. For every bean, there can be atmost one object of type bean pool monitor.
public static final MonitoredObjectType
BEAN_CACHE
A monitored object type of bean cache. For every bean, there can be atmost one object of type bean cache monitor.
public static final MonitoredObjectType
BEAN_METHOD
A monitored object type of bean method
public static final MonitoredObjectType
HTTP_SERVER
A monitored object type of http-server (core)
public static final MonitoredObjectType
VIRTUAL_SERVER
A monitored object type of virtual-server
public static final MonitoredObjectType
PROCESS
A monitored object type of process
public static final MonitoredObjectType
TXNMGR
A monitored object type of jts monitor. There is only one instance of jts monitor object.
public static final MonitoredObjectType
IIOP_SERVICE
A monitored object type of iiop service
public static final MonitoredObjectType
ORB
A monitored object type of orb.
public static final MonitoredObjectType
ORB_CONNECTION
A monitored object type of orb connection
public static final MonitoredObjectType
ORB_THREAD_POOL
A monitored object type of orb thread pool
public static final MonitoredObjectType
RESOURCES
A monitored object type of resources
public static final MonitoredObjectType
JDBC_CONN_POOL
A monitored object type of jdbc-connection-pool
private String
typeName
value of this object as a string
private boolean
isSingleton
Denotes whether this type allows more than one instance at any level.
private int
enableCount
Number of components that need this type to be enabled. If the number is more than zero then monitoring is started on MBeans of this type.
public static final MonitoredObjectType[]
EJB_TYPES
List of monitored object types for ejb container
public static final MonitoredObjectType[]
MDB_TYPES
List of monitored object types for mdb container
public static final MonitoredObjectType[]
ORB_TYPES
List of monitored object types for orb
public static final MonitoredObjectType[]
JTS_TYPES
List of monitored object types for JTS
private static boolean
ejbMonitoringEnabled
Tracks whether monitoring is enabled on ejb container
private static boolean
mdbMonitoringEnabled
Tracks whether monitoring is enabled on mdb container
private static boolean
orbMonitoringEnabled
Tracks whether monitoring is enabled on orb
private static boolean
jtsMonitoringEnabled
Tracks whether monitoring is enabled on JTS
private static com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
private MonitoredObjectType(String type)
Creates a new instance of MonitoredObjectType using specified string type

param
type string representing the name of monitored object type


                              
       
        this(type, false);
    
private MonitoredObjectType(String type, boolean isSingleton)
Creates a new instance of MonitoredObjectType using specified string type and specified flag for singleton

param
type string representing the name of monitored object type
param
isSingleton denotes whether this type of monitored object has only one instance (in its context)

        this.typeName = type;
        this.isSingleton = isSingleton;
        objectMap.put(this.typeName, this);
    
Methods Summary
private static synchronized voiddisableTypes(com.sun.enterprise.admin.monitor.MonitoredObjectType[] types)
Disble monitoring for specified types. Note that a type can be disbled more than once as it can be used by different monitorable components.

        int size = types.length;
        for (int i = 0; i < size; i++) {
            if (types[i].enableCount > 0) {
                types[i].enableCount--;
            } else {
				String msg = localStrings.getString( "admin.monitor.monitored_object_type_already_disabled", types[i].toString() );
                throw new IllegalStateException( msg );
            }
        }
    
private static synchronized voidenableTypes(com.sun.enterprise.admin.monitor.MonitoredObjectType[] types)
Enable monitoring for specified types. Note that a type can be enabled more than once as it can be used by different monitorable components.


                                 
          
        int size = types.length;
        for (int i = 0; i < size; i++) {
            types[i].enableCount++;
        }
    
public static com.sun.enterprise.admin.monitor.MonitoredObjectTypegetMonitoredObjectType(java.lang.String typeName)
Get a MonitoredObjectType instance for the specified string type.

param
typeName string representing MonitoredObjectType
throws
IllegalArgumentException if the specified type name is not known.

        MonitoredObjectType type = getMonitoredObjectTypeOrNull(typeName);
        if (type == null) {
			String msg = localStrings.getString( "admin.monitor.unknown_type_name", typeName );
            throw new IllegalArgumentException( msg );
        }
        return type;
    
static com.sun.enterprise.admin.monitor.MonitoredObjectTypegetMonitoredObjectTypeOrNull(java.lang.String typeName)
Get a MonitoredObjectType instance for the specified string type. If the specified type is not known, the method returns null.

param
typeName string representing MonitoredObjectType

        MonitoredObjectType type = null;
        if (objectMap != null && typeName != null) {
            type = (MonitoredObjectType)objectMap.get(typeName);
        }
        return type;
    
public java.lang.StringgetTypeName()
Get type of this "MonitoredObjectType" as string

return
Monitored object type as string

        return typeName;
    
public booleanisMonitoringEnabled()
Is monitoring enabled for this type.

        return (enableCount > 0);
    
public booleanisSingleton()
Is instance of this type of MonitorMBean singleton. For example, there can only be one pool for every stateless session bean, so a MonitoredObjectType of type MonitoredObjectType.BEAN_POOL is a singleton.

return
true if this type of object can have atmost one instance within its context, false otherwise.

        return isSingleton;
    
public static voidsetEjbMonitoringEnabled(boolean enable)
Set monitoring enabled or disabled for ejb container

param
enable if true monitoring is enabled, otherwise it is disabled


                            
         
        ejbMonitoringEnabled = setMonitoringEnabled(EJB_TYPES,
                ejbMonitoringEnabled, enable);
    
public static voidsetJtsMonitoringEnabled(boolean enable)
Set monitoring enabled or disabled for jts

param
enable if true monitoring is enabled, otherwise it is disabled

        jtsMonitoringEnabled = setMonitoringEnabled(JTS_TYPES,
                jtsMonitoringEnabled, enable);
    
public static voidsetMdbMonitoringEnabled(boolean enable)
Set monitoring enabled or disabled for mdb container

param
enable if true monitoring is enabled, otherwise it is disabled

        mdbMonitoringEnabled = setMonitoringEnabled(MDB_TYPES,
                mdbMonitoringEnabled, enable);
    
static voidsetMonitoringEnabled(java.lang.String comp, boolean enable)
Set monitoring enabled or disabled on specified component.

param
comp the component name - this is the xpath of the component that has monitoring enabled.
param
enable turn monitoring on (if true) or off (if false)

        if (ServerTags.EJB_CONTAINER.equals(comp)) {
            setEjbMonitoringEnabled(enable);
        } else if (ServerTags.MDB_CONTAINER.equals(comp)) {
            setMdbMonitoringEnabled(enable);
        } else if (ServerTags.ORB.equals(comp)) {
            setOrbMonitoringEnabled(enable);
        } else if (ServerTags.TRANSACTION_SERVICE.equals(comp)) {
            setJtsMonitoringEnabled(enable);
        }
    
private static booleansetMonitoringEnabled(com.sun.enterprise.admin.monitor.MonitoredObjectType[] types, boolean oldEnabled, boolean newEnabled)
Enable or Disable monitoring for specified monitored object types. If oldEnabled and newEnabled are same then this method is a NO-OP.

param
types list of monitored object types
param
oldEnabled old value of monitoring enabled
param
newEnabled new value of monitoring enabled
return
new value of monitoring enabled.

        if (newEnabled != oldEnabled) {
            oldEnabled = newEnabled;
            if (oldEnabled) {
                enableTypes(types);
            } else {
                disableTypes(types);
            }
        }
        return newEnabled;
    
public static voidsetOrbMonitoringEnabled(boolean enable)
Set monitoring enabled or disabled for orb

param
enable if true monitoring is enabled, otherwise it is disabled

        orbMonitoringEnabled = setMonitoringEnabled(ORB_TYPES,
                orbMonitoringEnabled, enable);
    
public java.lang.StringtoString()
A string representation. The return value of this method is same as that of method getTypeName.

return
A string representation of this MonitoredObjectType

        return typeName;