FileDocCategorySizeDatePackage
OldProps.javaAPI DocGlassfish v2 API8229Fri May 04 22:23:50 BST 2007com.sun.enterprise.management.support.oldconfig

OldProps

public final class OldProps extends Object
Extracts relevant properties from "old" ObjectNames.

Fields Summary
private final ObjectName
mObjectName
private final Map
mValues
private static final String
SERVER_CONFIG_KEY
private static final List
POSSIBLE_NAME_KEYS
These are the possible key values in an old ObjectName that contain the name of the config element.
Constructors Summary
public OldProps(ObjectName oldObjectName, com.sun.enterprise.management.support.OldTypeToJ2EETypeMapper mapper)

		mObjectName	= oldObjectName;
		mValues	= new HashMap<String,String>();
		
		// determine the new type from the old
		final String	j2eeType	= mapper.oldObjectNameToJ2EEType( oldObjectName );
		if ( j2eeType == null )
		{
		    throw new IllegalArgumentException( "" + oldObjectName );
		}
		mValues.put( AMX.J2EE_TYPE_KEY, j2eeType );
		
		// determine the name
		final String	oldName	= getOldName( oldObjectName );
		final String	name	= oldName != null ?
			oldName : ObjectNames.getSingletonName( j2eeType );
		mValues.put( AMX.NAME_KEY, name );
		
		final Set<String>   keys    = TypeCast.asSet(oldObjectName.getKeyPropertyList().keySet());
		for( final String prop : keys )
		{
			final String	newType	= mapper.oldTypeToJ2EEType( prop, oldObjectName );
			
			if ( newType != null )
			{
				mValues.put( newType, oldObjectName.getKeyProperty( prop ) );
			}
		}
		
		// special-cases
		
		if ( j2eeType.equals( XTypes.JMX_CONNECTOR_CONFIG ) )
		{
			/*
				JMX_CONNECTOR_CONFIG MBean has two possible parents,
				but neither is present in the old "jmx-connector" mbean, 
				which screws things up for itself and its children (SSL_CONFIG).
			 */
			if ( mValues.containsKey( XTypes.CONFIG_CONFIG )  )
			{
				mValues.put( XTypes.ADMIN_SERVICE_CONFIG,
					ObjectNames.getSingletonName( XTypes.ADMIN_SERVICE_CONFIG ) );
			}
			else if ( mValues.containsKey( XTypes.NODE_AGENT_CONFIG ) )
			{
				// OK
			}
			else
			{
				throw new IllegalArgumentException( "unrecognized ObjectName for jmx-connector" );
			}
		}
		else if ( j2eeType.equals( XTypes.SSL_CONFIG ) )
		{
			if ( mValues.containsKey( XTypes.NODE_AGENT_CONFIG ) )
			{
				/**
					Old object name for "node-agent/jmx-connector/ssl" doesnot 
					have jmx-connector property.
				 */
				mValues.put( XTypes.JMX_CONNECTOR_CONFIG,
					ObjectNames.getSingletonName( XTypes.JMX_CONNECTOR_CONFIG ) );
			}
			else if ( mValues.containsKey( XTypes.JMX_CONNECTOR_CONFIG )  )
			{
				mValues.put( XTypes.ADMIN_SERVICE_CONFIG,
					ObjectNames.getSingletonName( XTypes.ADMIN_SERVICE_CONFIG ) );
			}
			else if (	mValues.containsKey( XTypes.CONFIG_CONFIG )  && 
						!mValues.containsKey( XTypes.HTTP_LISTENER_CONFIG ) && 
						!mValues.containsKey( XTypes.IIOP_LISTENER_CONFIG ) )
			{
				mValues.put( XTypes.IIOP_SERVICE_CONFIG,
					ObjectNames.getSingletonName( XTypes.IIOP_SERVICE_CONFIG ) );
			}
		}
		else if ( j2eeType.equals( XTypes.AUTH_REALM_CONFIG ) )
		{
			/*
				AUTH_REALM_CONFIG MBean has two possible parents,
				but neither is present in the old "auth-realm" mbean when it
				is a child of security service.
			 */
			if ( mValues.containsKey( XTypes.CONFIG_CONFIG )  )
			{
				mValues.put( XTypes.SECURITY_SERVICE_CONFIG,
					ObjectNames.getSingletonName( XTypes.SECURITY_SERVICE_CONFIG ) );
			}
			else if ( mValues.containsKey( XTypes.NODE_AGENT_CONFIG ) )
			{
				// OK
			}
			else
			{
				throw new IllegalArgumentException( "unrecognized ObjectName for ssl or jmx-connector" );
			}
		 }
	
Methods Summary
private static voiddebug(java.lang.Object o)

	
	      
	    
	
	    AMXDebug.getInstance().getOutput( "OldProps" ).println( o );
	
public java.lang.StringgetNewProps()
Get a String consisting of all new properties suitable for use in creating a new ObjectName.

		return( JMXUtil.mapToProps( mValues ) );
	
private java.lang.StringgetOldName(javax.management.ObjectName oldObjectName)
Determine the name of an item from the old ObjectName.

		String	oldName	= null;
		
		for( final String key : getPossibleNameKeys() )
		{
			oldName	= oldObjectName.getKeyProperty( key );
			if ( oldName != null )
			{
				break;
			}
		}
		
		// special case for 'root' mbean, which is monitoring root
		if ( oldName == null && oldObjectName.getKeyProperty( "type" ).equals( "root" ) )
		{
			oldName	= oldObjectName.getKeyProperty( "server" );
		}
		
		return( oldName );
	
public javax.management.ObjectNamegetOldObjectName()

		return( mObjectName );
	
public static java.util.ListgetPossibleNameKeys()

	
	      
	
	
	    return POSSIBLE_NAME_KEYS;
	
public static java.util.Setj2eeTypesToOldTypes(java.util.Set j2eeTypes, com.sun.enterprise.management.support.OldTypeToJ2EETypeMapper mapper)
Find the first key that is present in the ObjectName

return
first key present in the ObjectName

		final Set<String>		old		= new HashSet<String>();
		
		String	match	= null;
		for ( final String j2eeType : j2eeTypes )
		{
			final String	oldType	= mapper.j2eeTypeToOldType( j2eeType );
			if ( oldType != null )
			{
				old.add( oldType );
			}
		}
		
		return( old );
	
private static java.lang.StringtoString(java.lang.Object o)

		return( SmartStringifier.toString( o ) );