FileDocCategorySizeDatePackage
MBeanServerConnection_Pattern.javaAPI DocGlassfish v2 API4242Fri May 04 22:31:04 BST 2007com.sun.appserv.management.util.jmx

MBeanServerConnection_Pattern

public class MBeanServerConnection_Pattern extends MBeanServerConnection_Hook
This class allows use of MBeanServerConnection methods with ObjectName patterns that resolve to a single MBean. This is useful to avoid hard-coupling to specific ObjectNames; instead an ObjectName pattern may be used which resolves to a single MBean. For example, if you know the 'name' property is unique (at least for your MBean), you could use the ObjectName "*:name=myname,*" instead of a possibly much longer and complicated name (which potentially could change each time the MBean is registered).

Fields Summary
final MBeanServerConnection_Hook.Hook
mHook
Constructors Summary
public MBeanServerConnection_Pattern(MBeanServerConnection impl)

		super( impl );
		
		mHook	= new NameResolverHook();
	
Methods Summary
HookgetHook()

		return( mHook );
	
public javax.management.ObjectNameresolve(javax.management.ObjectName input)

		ObjectName	resolvedName	= input;
		
		if ( input.isPattern() )
		{
			final Set<ObjectName>	resolvedNames	= JMXUtil.queryNames( getConn(), input, null );
			final int	numNames	= resolvedNames.size();
			
			if ( numNames == 1 )
			{
				resolvedName	= GSetUtil.getSingleton( resolvedNames );
			}
			else if ( numNames > 1 )
			{
				throw new InstanceNotFoundException( input.toString() );
			}
			else
			{
				throw new InstanceNotFoundException( input.toString() );
			}
		}
		return( resolvedName );