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" );
}
}