if (!configuredInstruments.contains(instrumentName)) {
throw new InvalidCommandException("%s is not a configured instrument (%s). "
+ "use --print-config to see the configured instruments.",
instrumentName, configuredInstruments);
}
final InstrumentConfig instrumentConfig = config.getInstrumentConfig(instrumentName);
Injector instrumentInjector = injector.createChildInjector(new AbstractModule() {
@Override protected void configure() {
bind(InstrumentConfig.class).toInstance(instrumentConfig);
}
@Provides @InstrumentOptions ImmutableMap<String, String> provideInstrumentOptions(
InstrumentConfig config) {
return config.options();
}
@Provides @InstrumentName String provideInstrumentName() {
return instrumentName;
}
});
String className = instrumentConfig.className();
try {
builder.add(instrumentInjector.getInstance(
Util.lenientClassForName(className).asSubclass(Instrument.class)));
} catch (ClassNotFoundException e) {
throw new InvalidCommandException("Cannot find instrument class '%s'", className);