FileDocCategorySizeDatePackage
DottedNameGetSetForConfig.javaAPI DocGlassfish v2 API8906Fri May 04 22:24:10 BST 2007com.sun.enterprise.admin.mbeans

DottedNameGetSetForConfig

public class DottedNameGetSetForConfig extends DottedNameGetSetMBeanBase
This was originally an inner class within DottedNameGetSetMBeanImpl. For extensibility reasons this was moved out as a separate class.
author
Lloyd Chambers
author
Shreedhar Ganapathy Date: Jun 9, 2004
version
$Revision: 1.4 $

Fields Summary
final DottedNameResolverForAliases
mResolver
final DottedNameQuery
mQuery
Constructors Summary
public DottedNameGetSetForConfig(MBeanServerConnection conn, DottedNameRegistry registry, DottedNameServerInfo serverInfo)

        super( conn, registry, serverInfo );

        // DottedNameResolver for regular dotted names needs to account for aliases.
        mResolver	= new DottedNameResolverForAliases( registry, serverInfo );

        mQuery		= new DottedNameAliasedQuery( registry, serverInfo );
    
Methods Summary
protected DottedNameQuerycreateQuery()

        return( mQuery );
    
public javax.management.AttributedoSet(java.lang.String pair)

        final int		delimIndex	= pair.indexOf( ASSIGNMENT_DELIM );
        final boolean	delete		= delimIndex < 0;

        // if there is no value delimiter ('='), this means to delete the property
        // this is only supported for properties however
        final String	dottedNameString	= delete ? pair : pair.substring( 0, delimIndex );
        final String	valueString			= delete ? null : pair.substring( delimIndex + 1, pair.length() );

        final Attribute attr	= doSet( dottedNameString, valueString );

        return( attr );
    
public javax.management.AttributedoSet(java.lang.String dottedNameString, java.lang.String value)

        // NOTE: this name includes the value-name
        final DottedName	dn	= getDottedName( dottedNameString );

        if ( dn.isWildcardName() )
        {
            final String	msg	= DottedNameStrings.getString(
                    DottedNameStrings.WILDCARD_DISALLOWED_FOR_SET_KEY,
                    dottedNameString );

            throw new IllegalArgumentException( msg );
        }

        ObjectName	target	= null;
        final DottedNameForValue	dnv	= new DottedNameForValue( dn );
        if ( isDottedNameForServerName( dnv.getPrefix(), dnv.getValueName() ) )
        {
            // YUCK special case "server.name" or otherwise the attribute will
            // be set on the config
            target	= getRegistry().dottedNameToObjectName( dnv.getPrefix().toString() );
        }
        else
        {
            target	= getTarget( dnv, getResolver( ) );
        }

        final Attribute	inAttr	= new Attribute( dnv.getValueName(), value );

        Attribute resultAttr	= mValueAccessor.setValue( target, inAttr );

        // special meaning of result with null value is that it has been deleted (yuck)
        // in this case, it is not added to the output list
        if ( resultAttr != null && resultAttr.getValue() != null )
        {
            final String	fullName	= dnv.getPrefix() + "." + inAttr.getName();

            resultAttr	= new Attribute( fullName, resultAttr.getValue() );
        }

        return( resultAttr );
    
public java.lang.Object[]dottedNameSet(java.lang.String[] nameValuePairs)

        final int	numItems	= nameValuePairs.length;

        // make a new array of sorted input pairs
        // do this first, because resulting output may contain a mix of type--
        // Attribute or Exception making it hard to sort properly.
        final String []		sortedPairs	= new String [ numItems ];
        for( int i = 0; i < numItems; ++i )
        {
            sortedPairs[ i ]	= nameValuePairs[ i ];
        }
        Arrays.sort( sortedPairs );


        final Object []		results	= new Object [ sortedPairs.length ];
        for( int i = 0; i < numItems; ++i )
        {
            results[ i ]	= dottedNameSet( sortedPairs[ i ] );
        }

        return( results );
    
protected java.lang.ObjectdottedNameSet(java.lang.String nameValuePair)

        Object	result	= null;

        try
        {
            result	= doSet( nameValuePair );
        }
        catch( Exception e )
        {
            // the result will be the exception itself
            logException( e );
            result	= e;
        }

        assert( result != null );
        return( result );
    
protected javax.management.AttributeformAttribute(DottedName prefix, java.lang.String valueName, java.lang.Object value)

        // default behavior
        Attribute	attr	= super.formAttribute( prefix, valueName, value );

        try
        {
            // Is it a special case for server.xxx which is into 'server' itself?
            if ( isDottedNameForServerName( prefix, valueName ) )
            {
                // <server>.name value has been set to <config>.name value
                // skip the aliasing and get the name from the server object
                final ObjectName	objectName	= getRegistry().dottedNameToObjectName( prefix.getScope() );

                final Attribute	newAttr	= mValueAccessor.getValue( objectName, valueName );
                assert( newAttr != null );
                attr	= super.formAttribute( prefix, valueName, newAttr.getValue() );
            }
        }
        catch( Exception e)
        {
            logException( e );
        }

        return( attr );
    
protected DottedNameResolvergetResolver()

        return( mResolver );
    
protected booleanisDottedNameForServerName(DottedName prefix, java.lang.String valueName)

        return( valueName.equals( "name" ) &&
            isServerName( prefix.getScope() ) &&	// these tests make sure it's just "<server>.name"
            prefix.getParts().size() == 0 );
    
booleanisServerName(java.lang.String name)

        boolean	isServerName	= false;

        isServerName	= mServerInfo.getServerNames().contains( name );

        return( isServerName );