FileDocCategorySizeDatePackage
AttributeValueAccessor.javaAPI DocGlassfish v2 API5748Fri May 04 22:24:08 BST 2007com.sun.enterprise.admin.dottedname.valueaccessor

AttributeValueAccessor

public class AttributeValueAccessor extends ValueAccessorBase

Fields Summary
Constructors Summary
public AttributeValueAccessor(MBeanServerConnection conn)

		super( conn );
	
Methods Summary
public static java.util.SetgetAllAttributeNames(javax.management.MBeanServerConnection conn, javax.management.ObjectName objectName)

		final Set		allNames	= new HashSet();
	
		// add the Attribute names
		final MBeanInfo					info		= conn.getMBeanInfo( objectName );
		final MBeanAttributeInfo []		attrsInfo	= info.getAttributes();
		if ( attrsInfo != null )
		{
			for( int i = 0; i < attrsInfo.length; ++i )
			{
				allNames.add( attrsInfo[ i ].getName() );
			}
		}
		
		return( allNames );
	
java.lang.ClassgetAttributeClass(javax.management.ObjectName objectName, java.lang.String attributeName)

		final MBeanInfo				info	= getMBS().getMBeanInfo( objectName );
		final MBeanAttributeInfo []	attrsInfo	= info.getAttributes();
		Class	theClass	= null;
		
		for( int i = 0; i < attrsInfo.length; ++i )
		{
			final String	testName	= attrsInfo[ i ].getName();
			
			if ( testName.equals( attributeName ) )
			{
				theClass	= ClassUtil.getClassFromName( attrsInfo[ i ].getType() );
				break;
			}
		}
		return( theClass );
	
public javax.management.AttributegetValue(javax.management.ObjectName objectName, java.lang.String valueName)

		final Object value	= getMBS().getAttribute( objectName, valueName);
		
		return( new Attribute( valueName, value ) );
	
public javax.management.AttributesetValue(javax.management.ObjectName objectName, javax.management.Attribute attr)

		if ( attr.getValue() == null )
		{
			final String	msg	= DottedNameStrings.getString(
					DottedNameStrings.ILLEGAL_TO_SET_NULL_KEY,
					attr.getName( ) );
					
			throw new IllegalArgumentException( msg );
		}

		Attribute	actualAttr	= null;
		
		Object	value	= attr.getValue();
		if ( value instanceof String )
		{
			final Class	attrClass	= getAttributeClass( objectName, attr.getName() );
			if ( attrClass == null )
			{
				final String	msg	= DottedNameStrings.getString(
						DottedNameStrings.ATTRIBUTE_NOT_FOUND_KEY,
						attr.getName( ) );
					
				throw new AttributeNotFoundException( attr.getName() );
			}
			
			value	= coerceToClass( attrClass, (String)value );
			
			actualAttr	= new Attribute( attr.getName(), value );
		}
		else
		{
			// if not a String, then pass on through
			actualAttr	= attr;
		}
		
		getMBS().setAttribute( objectName, actualAttr);
		
		return( actualAttr );