{
proxy.setType( InstrumentManagerClient.INSTRUMENT_TYPE_VALUE );
}
else
{
throw new ServiceException( fullInstrumentName, "Encountered an unknown "
+ "Instrument type for the Instrument with key, "
+ fullInstrumentName + ": " + instrument.getClass().getName() );
}
// Mark the instrument proxy as registered.
proxy.setRegistered();
// Store a reference to the proxy in the Instrument.
( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
instrumentableProxy.addInstrumentProxy( proxy );
}
else
{
// Register the existing proxy with the Instrument. Make sure that the
// type didn't change on us.
if( instrument instanceof CounterInstrument )
{
switch( proxy.getType() )
{
case InstrumentManagerClient.INSTRUMENT_TYPE_COUNTER:
// Type is the same.
// Store a reference to the proxy in the Instrument.
( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
break;
case InstrumentManagerClient.INSTRUMENT_TYPE_NONE:
// Not yet set. Created in configuration.
proxy.setType( InstrumentManagerClient.INSTRUMENT_TYPE_COUNTER );
// Store a reference to the proxy in the Instrument.
( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
break;
default:
throw new ServiceException( instrumentName,
"Instruments of more than one type are assigned to name: "
+ instrumentName );
}
}
else if( instrument instanceof ValueInstrument )
{
switch( proxy.getType() )
{
case InstrumentManagerClient.INSTRUMENT_TYPE_VALUE:
// Type is the same.
// Store a reference to the proxy in the Instrument.
( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
break;
case InstrumentManagerClient.INSTRUMENT_TYPE_NONE:
// Not yet set. Created in configuration.
proxy.setType( InstrumentManagerClient.INSTRUMENT_TYPE_VALUE );
// Store a reference to the proxy in the Instrument.
( (AbstractInstrument)instrument ).setInstrumentProxy( proxy );
break;
default:
throw new ServiceException( instrumentName,
"Instruments of more than one type are assigned to name: "
+ instrumentName );
}
}
else
{
throw new ServiceException( instrumentName, "Encountered an unknown Instrument "
+ "type for the Instrument with name, " + instrumentName + ": "
+ instrument.getClass().getName() );
}
// Mark the instrument proxy as registered.
proxy.setRegistered();
}
}
// Loop over the child Instrumentables published by this Instrumentable
Instrumentable[] children = instrumentable.getChildInstrumentables();
for ( int i = 0; i < children.length; i++ )
{
Instrumentable child = children[i];
// Make sure that the child instrumentable name is set.
String childName = child.getInstrumentableName();
if( childName == null )
{
String msg = "The getInstrumentableName() method of a child Instrumentable of " +
instrumentableName + " returned null. Child class: " +
child.getClass().getName();
getLogger().debug( msg );
throw new ServiceException( instrumentable.getClass().getName(), msg );
}
String fullChildName = instrumentableName + "." + childName;
getLogger().debug( "Registering Child Instrumentable: " + fullChildName );