FileDocCategorySizeDatePackage
QueryMgrImpl.javaAPI DocGlassfish v2 API14003Fri May 04 22:23:42 BST 2007com.sun.enterprise.management.support

QueryMgrImpl

public class QueryMgrImpl extends AMXNonConfigImplBase

Fields Summary
private static com.sun.appserv.management.j2ee.J2EETypesMapper
sJ2EETypesMapper
Constructors Summary
public QueryMgrImpl()

	
		
	
	
	
Methods Summary
private static java.util.Setchecked(java.util.Set s)

	    return Collections.checkedSet(s, ObjectName.class);
	
private static java.lang.String[]convertToRegex(java.lang.String[] wildExprs)

		String[]	regexExprs	= null;
		
		if ( wildExprs != null )
		{
			regexExprs	= new String[ wildExprs.length ];
								
			for( int i = 0; i < wildExprs.length; ++i )
			{
				final String	expr	= wildExprs[ i ];
				
				final String	regex	= expr == null ? 
									null : RegexUtil.wildcardToJavaRegex( expr );
				
				regexExprs[ i ]	= regex;
			}
		}
		return( regexExprs );
	
public final java.lang.StringgetGroup()

		return( AMX.GROUP_UTILITY );
	
private static synchronized java.lang.ClassinterfaceForJ2EEType(java.lang.String j2eeType)
Return the Class associated with a given type or null if none.

		Class theClass	= XTypesMapper.getInstance().getInterfaceForType( j2eeType );
		
		if ( theClass == null )
		{
			theClass	= J2EETypesMapper.getInstance().getInterfaceForType( j2eeType );
		}
		
		return( theClass );
	
private java.util.SetmatchWild(java.util.Set candidates, java.lang.String[] wildKeys, java.lang.String[] wildValues)

		final String[]	regexNames	= convertToRegex( wildKeys );
		final String[]	regexValues	= convertToRegex( wildValues );
		
		final ObjectNameQueryImpl	query	= new ObjectNameQueryImpl();
		final Set<ObjectName>	resultSet	= query.matchAll( candidates, regexNames, regexValues );
		
		return( resultSet );
	
public java.util.SetqueryAllObjectNameSet()
Return a Set containing all AMX ObjectNames.

return
a Set of all ObjectNames

		final ObjectName	pat	= Util.newObjectNamePattern( getJMXDomain(), "" );
		
		return( queryPatternObjectNameSet( pat ) );
	
private java.util.SetqueryInterfaceObjectNameSet(java.util.Set objectNames, java.lang.String interfaceName, java.lang.String attributeName)
Match an interface classname against the value of an Attribute.

param
objectNames the set to search
param
interfaceName the name of the interface to find
param
attributeName the name of the Attribute to search

		final Set<ObjectName>	result		= new HashSet<ObjectName>();
		
		final MBeanServer	server	= getMBeanServer();
		for( final ObjectName objectName : objectNames )
		{
			try
			{
				if ( server.getAttribute( objectName, attributeName ).equals( interfaceName ) )
				{
					result.add( objectName );
				}
			}
			catch( JMException e )
			{
				// ignore
			}
		}
		
		return checked(result);
	
public java.util.SetqueryInterfaceObjectNameSet(java.lang.String searchInterfaceName, java.util.Set candidates)

		final Set<ObjectName>	result = new HashSet<ObjectName>();
		final Set<ObjectName>   iter   = candidates == null ?
			                        queryAllObjectNameSet() : candidates;
		
		final Class<?>	searchInterface	= ClassUtil.getClassFromName( searchInterfaceName );
		
		final MBeanServer	server	= getMBeanServer();
		for( final ObjectName objectName : iter )
		{
			try
			{
				final String interfaceName	= (String)
					server.getAttribute( objectName, AMXAttributes.ATTR_INTERFACE_NAME );
				
				final Class	c	=
					ClassUtil.getClassFromName( interfaceName );
					
				if (  searchInterface.isAssignableFrom( c ) )
				{
					result.add( objectName );
				}
			}
			catch( JMException e )
			{
				// ignore
			}
		}
		
		return( checked(result) );
	
public java.util.SetqueryJ2EENameObjectNameSet(java.lang.String nameValue)
Get all MBeans having the specified name.

param
nameValue the value of the "name" property to match

		final String	prop	= Util.makeNameProp( nameValue );
		final Set<ObjectName>   names	= queryPropsObjectNameSet( getMBeanServer(),
									getJMXDomain(), prop );
													
		return( names );
	
public java.util.SetqueryJ2EETypeNameObjectNameSet(java.lang.String j2eeType, java.lang.String name)

return
Set containing all items that have the matching j2eeType and name

	    final String    props   = Util.makeRequiredProps( j2eeType, name );
	    return queryPatternObjectNameSet( Util.newObjectNamePattern( getObjectName().getDomain(), props ) );
	
public java.lang.String[]queryJ2EETypeNames(java.lang.String j2eeType)

		final String	prop	= Util.makeJ2EETypeProp( j2eeType );
		
		final Set<ObjectName> objectNameSet	= queryPropsObjectNameSet( prop );
		final ObjectName[]	objectNames	= JMXUtil.objectNameSetToArray( objectNameSet );
		
		final String[]	nameKeyValues	=
			JMXUtil.getKeyProperty( NAME_KEY, objectNames );
		
		return( nameKeyValues );
	
public static java.util.SetqueryJ2EETypeObjectNameSet(javax.management.MBeanServerConnection conn, java.lang.String domainName, java.lang.String j2eeTypeValue)

		final String		prop	= Util.makeJ2EETypeProp( j2eeTypeValue ) ;
		final ObjectName	pat		= Util.newObjectNamePattern( domainName, prop );
		
		final Set<ObjectName>	names	= queryPatternObjectNameSet( conn, pat );
		
		return( checked(names) );
	
public java.util.SetqueryJ2EETypeObjectNameSet(java.lang.String j2eeTypeValue)

		final String		prop	= Util.makeJ2EETypeProp( j2eeTypeValue ) ;
		final ObjectName	pat		= Util.newObjectNamePattern( getJMXDomain(), prop );
		
		final Set<ObjectName>	names	= queryPropsObjectNameSet( getMBeanServer(),
								getJMXDomain(), prop );
		
		return( names );
	
public java.util.SetqueryJ2EETypesObjectNameSet(java.util.Set j2eeTypes)

        final Set<ObjectName> result    = new HashSet<ObjectName>();
        
        for( final String j2eeType : j2eeTypes )
        {
            result.addAll( queryJ2EETypeObjectNameSet( j2eeType ) );
        }
		
		return result;
	
public static java.util.SetqueryPatternObjectNameSet(javax.management.MBeanServerConnection conn, javax.management.ObjectName pattern)

		final Set<ObjectName>	names	= JMXUtil.queryNames( conn, pattern, null );
		
		return checked(names);
	
public static java.util.SetqueryPatternObjectNameSet(javax.management.MBeanServer server, javax.management.ObjectName pattern)

		final Set<ObjectName>	names	= JMXUtil.queryNames( server, pattern, null );
		
		return checked(names);
	
public java.util.SetqueryPatternObjectNameSet(javax.management.ObjectName pattern)

		return( queryPatternObjectNameSet( getMBeanServer(), pattern ) );
	
public java.util.SetqueryPatternObjectNameSet(java.lang.String domain, java.lang.String props)

	    final String myDomain   = getObjectName().getDomain();
	    
		final ObjectName	pattern	= Util.newObjectNamePattern(
		    domain == null ? myDomain : domain, props );
		return( queryPatternObjectNameSet( getMBeanServer(), pattern ) );
	
public static java.util.SetqueryPropsObjectNameSet(javax.management.MBeanServerConnection conn, java.lang.String jmxDomainName, java.lang.String props)

		final ObjectName	pattern		=
				Util.newObjectNamePattern( jmxDomainName, props );
		
		final Set<ObjectName>	names	= JMXUtil.queryNames( conn, pattern, null );
		
		return( checked(names) );
	
public static java.util.SetqueryPropsObjectNameSet(javax.management.MBeanServer server, java.lang.String jmxDomainName, java.lang.String props)

		final ObjectName	pattern		=
				Util.newObjectNamePattern( jmxDomainName, props );
		
		final Set<ObjectName>	names	= JMXUtil.queryNames( server, pattern, null );
		
		return( checked(names) );
	
public java.util.SetqueryPropsObjectNameSet(java.lang.String props)

		final String	myDomain	= getObjectName().getDomain();
		
		final Set<ObjectName>	names	=
			queryPropsObjectNameSet( getMBeanServer(), myDomain, props );
		
		return( checked(names) );
	
public javax.management.ObjectNamequerySingletonJ2EEType(java.lang.String j2eeTypeValue)
Get the ObjectName of an MBean having the specified J2EEType. If there is more than one such MBean, an IllegalArgumentException is thrown. If no object is found, then null is returned.

throws
IllegalArgumentException if more than one object is found or null if none found

		final Set<ObjectName>	names	= queryJ2EETypeObjectNameSet( j2eeTypeValue );
		if ( names.size() > 1 )
		{
			trace( "QueryMgrImpl.getJ2EETypeObjectName: expected 1, got " + names.size() );
			throw new IllegalArgumentException( j2eeTypeValue );
		}
		
		final ObjectName	objectName	= names.size() == 0 ?
							null :GSetUtil.getSingleton( names );
		
		return( objectName );
	
public javax.management.ObjectNamequerySingletonJ2EETypeObjectName(java.lang.String j2eeType)

		return( querySingletonJ2EETypeObjectName( getMBeanServer(), getObjectName().getDomain(), j2eeType ) );
	
public static javax.management.ObjectNamequerySingletonJ2EETypeObjectName(javax.management.MBeanServer server, java.lang.String domainName, java.lang.String j2eeTypeValue)

		try
		{
			final ObjectName	objectName	=
								querySingletonJ2EETypeObjectName(
									(MBeanServerConnection)server,
									domainName,
									j2eeTypeValue );
			return( objectName );
		}
		catch( IOException e )
		{
			assert( false );
			throw new RuntimeException( e );
		}
	
public static javax.management.ObjectNamequerySingletonJ2EETypeObjectName(javax.management.MBeanServerConnection conn, java.lang.String domainName, java.lang.String j2eeTypeValue)

		final Set<ObjectName>	names	=
		    queryJ2EETypeObjectNameSet( conn, domainName, j2eeTypeValue );
		if ( names.size() != 1 )
		{
			throw new IllegalArgumentException(
				"request was for a single Object name of type: " + j2eeTypeValue +
				" but found several: " + SmartStringifier.toString( names ) );
		}
		
		final ObjectName	objectName	= (ObjectName)GSetUtil.getSingleton( names );
		
		return( objectName );
	
public java.util.SetqueryWildObjectNameSet(java.lang.String[] wildKeys, java.lang.String[] wildValues)

		final Set<ObjectName>	candidates	= queryAllObjectNameSet();
		
		return( matchWild( candidates, wildKeys, wildValues ) );