Top Description Inners Fields Constructors Methods
com.sun.jmx.mbeanserver

public Class Repository

extends Object
Class Inheritance
Imports
com.sun.jmx.defaults.ServiceName, java.util.ArrayList, .Collections, .HashMap, .HashSet, .List, .Map, .Set, java.util.concurrent.locks.ReentrantReadWriteLock, java.lang.System.Logger.Level, javax.management.DynamicMBean, .InstanceAlreadyExistsException, .InstanceNotFoundException, .ObjectName, .QueryExp, .RuntimeOperationsException

This repository does not support persistency.
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Repository.RegistrationContext

An interface that allows the caller to get some control over the registration.

Field Summary

Modifier and TypeField and Description
private final String
domain

Domain name of the server the repository is attached to.

private final Map<String, Map<String, NamedObject>>
domainTb

The structure for storing the objects is very basic.

private final ReentrantReadWriteLock
lock

We use a global reentrant read write lock to protect the repository.

private volatile int
nbElements

Number of elements contained in the Repository

Constructor Summary

AccessConstructor and Description
public
Repository(String domain)

Construct a new repository with the given default domain.

public
Repository(String domain, boolean fairLock)

Construct a new repository with the given default domain.

Method Summary

Modifier and TypeMethod and Description
private void
addAllMatching(final Map<String, NamedObject> moiTb, final Set<NamedObject> result, final ObjectName pattern)

Add all the matching objects from the given hashtable in the result set for the given pattern

public void
addMBean(final DynamicMBean
MBean to be stored in the repository.
object
,
ObjectName
MBean object name.
name
,
final Repository.RegistrationContext
A registration context. If non null, the repository will call context.registering() from within the repository lock, when it has determined that the object can be stored in the repository with that name. If context.registering() throws an exception, the operation is abandoned, the MBean is not added to the repository, and a RuntimeOperationsException is thrown.
context
)

Stores an MBean associated with its object name in the repository.

private void
addMoiToTb(final DynamicMBean object, final ObjectName name, final String key, final Map<String, NamedObject> moiTb, final Repository.RegistrationContext context)

private void
addNewDomMoi(final DynamicMBean object, final String dom, final ObjectName name, final Repository.RegistrationContext context)

public boolean

Returns:

true if the MBean is stored in the repository, false otherwise.
contains
(ObjectName
name of the MBean to find.
name
)

Checks whether an MBean of the name specified is already stored in the repository.

public Integer

Returns:

Number of MBeans.
getCount
()

Gets the number of MBeans stored in the repository.

public String

Returns:

A string giving the name of the default domain name.
getDefaultDomain
()

Gets the name of the domain currently used by default in the repository.

public String[]
getDomains()

Returns the list of domains in which any MBean is currently registered.

public Set<NamedObject>

Returns:

The list of MBeans selected. There may be zero, one or many MBeans returned in the set.
query
(ObjectName
The name of the MBean(s) to retrieve - may be a specific object or a name pattern allowing multiple MBeans to be selected.
pattern
,
QueryExp
query expression to apply when selecting objects - this parameter will be ignored when the Repository Service does not support filtering.
query
)

Selects and retrieves the list of MBeans whose names match the specified object name pattern and which match the specified query expression (optionally).

private void
public void
remove(final ObjectName
name of the MBean to remove.
name
,
final Repository.RegistrationContext
A registration context. If non null, the repository will call context.unregistered() from within the repository lock, just after the mbean associated with name is removed from the repository. If context.unregistered() is not expected to throw any exception. If it does, the exception is logged and swallowed.
context
)

Removes an MBean from the repository.

public DynamicMBean

Returns:

The retrieved MBean if it is contained in the repository, null otherwise.
retrieve
(ObjectName
name of the MBean to retrieve.
name
)

Retrieves the MBean of the name specified from the repository.

private NamedObject
retrieveNamedObject(ObjectName name)

Retrieves the named object contained in repository from the given objectname.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

domainback to summary
private final String domain

Domain name of the server the repository is attached to. It is quicker to store the information in the repository rather than querying the framework each time the info is required.

domainTbback to summary
private final Map<String, Map<String, NamedObject>> domainTb

The structure for storing the objects is very basic. A Hashtable is used for storing the different domains For each domain, a hashtable contains the instances with canonical key property list string as key and named object aggregated from given object name and mbean instance as value.

lockback to summary
private final ReentrantReadWriteLock lock

We use a global reentrant read write lock to protect the repository. This seems safer and more efficient: we are using Maps of Maps, Guaranteing consistency while using Concurrent objects at each level may be more difficult.

nbElementsback to summary
private volatile int nbElements

Number of elements contained in the Repository

Constructor Detail

Repositoryback to summary
public Repository(String domain)

Construct a new repository with the given default domain.

Repositoryback to summary
public Repository(String domain, boolean fairLock)

Construct a new repository with the given default domain.

Method Detail

addAllMatchingback to summary
private void addAllMatching(final Map<String, NamedObject> moiTb, final Set<NamedObject> result, final ObjectName pattern)

Add all the matching objects from the given hashtable in the result set for the given pattern

addMBeanback to summary
public void addMBean(final DynamicMBean object, ObjectName name, final Repository.RegistrationContext context) throws InstanceAlreadyExistsException

Stores an MBean associated with its object name in the repository.

Parameters
object:DynamicMBean

MBean to be stored in the repository.

name:ObjectName

MBean object name.

context:Repository.RegistrationContext

A registration context. If non null, the repository will call context.registering() from within the repository lock, when it has determined that the object can be stored in the repository with that name. If context.registering() throws an exception, the operation is abandoned, the MBean is not added to the repository, and a RuntimeOperationsException is thrown.

addMoiToTbback to summary
private void addMoiToTb(final DynamicMBean object, final ObjectName name, final String key, final Map<String, NamedObject> moiTb, final Repository.RegistrationContext context)
addNewDomMoiback to summary
private void addNewDomMoi(final DynamicMBean object, final String dom, final ObjectName name, final Repository.RegistrationContext context)
containsback to summary
public boolean contains(ObjectName name)

Checks whether an MBean of the name specified is already stored in the repository.

Parameters
name:ObjectName

name of the MBean to find.

Returns:boolean

true if the MBean is stored in the repository, false otherwise.

getCountback to summary
public Integer getCount()

Gets the number of MBeans stored in the repository.

Returns:Integer

Number of MBeans.

getDefaultDomainback to summary
public String getDefaultDomain()

Gets the name of the domain currently used by default in the repository.

Returns:String

A string giving the name of the default domain name.

getDomainsback to summary
public String[] getDomains()

Returns the list of domains in which any MBean is currently registered.

queryback to summary
public Set<NamedObject> query(ObjectName pattern, QueryExp query)

Selects and retrieves the list of MBeans whose names match the specified object name pattern and which match the specified query expression (optionally).

Parameters
pattern:ObjectName

The name of the MBean(s) to retrieve - may be a specific object or a name pattern allowing multiple MBeans to be selected.

query:QueryExp

query expression to apply when selecting objects - this parameter will be ignored when the Repository Service does not support filtering.

Returns:Set<NamedObject>

The list of MBeans selected. There may be zero, one or many MBeans returned in the set.

registeringback to summary
private void registering(Repository.RegistrationContext context)
removeback to summary
public void remove(final ObjectName name, final Repository.RegistrationContext context) throws InstanceNotFoundException

Removes an MBean from the repository.

Parameters
name:ObjectName

name of the MBean to remove.

context:Repository.RegistrationContext

A registration context. If non null, the repository will call context.unregistered() from within the repository lock, just after the mbean associated with name is removed from the repository. If context.unregistered() is not expected to throw any exception. If it does, the exception is logged and swallowed.

Exceptions
InstanceNotFoundException:
The MBean does not exist in the repository.
retrieveback to summary
public DynamicMBean retrieve(ObjectName name)

Retrieves the MBean of the name specified from the repository. The object name must match exactly.

Parameters
name:ObjectName

name of the MBean to retrieve.

Returns:DynamicMBean

The retrieved MBean if it is contained in the repository, null otherwise.

retrieveNamedObjectback to summary
private NamedObject retrieveNamedObject(ObjectName name)

Retrieves the named object contained in repository from the given objectname.

unregisteringback to summary
private void unregistering(Repository.RegistrationContext context, ObjectName name)
com.sun.jmx.mbeanserver back to summary

public Interface Repository.RegistrationContext

Known Direct Subinterfaces
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.ResourceContext

An interface that allows the caller to get some control over the registration.
See Also
addMBean, remove

Method Summary

Modifier and TypeMethod and Description
public void
registering()

Called by addMBean.

public void
unregistered()

Called by remove.

Method Detail

registeringback to summary
public void registering()

Called by addMBean. Can throw a RuntimeOperationsException to cancel the registration.

unregisteredback to summary
public void unregistered()

Called by remove. Any exception thrown by this method will be ignored.