// In the default case do an auto-detection ...
final Class<? extends Plugin> typeOfField = (Class<? extends Plugin>) field.getType();
this.logger.fine("Injecting plugin by autodetection (" + typeOfField.getName() + ") into " + spawnedPlugin.getClass().getName());
field.set(spawnedPlugin, this.pluginManagerImpl.getPlugin(typeOfField, new OptionCapabilities(capabilities)));
}
}
// And setter methods as well (aka Scala hack)
for (Method method : methods) {
final InjectPlugin ipannotation = method.getAnnotation(InjectPlugin.class);
if (ipannotation != null) {
// Obtain capabilities
final String[] capabilities = ipannotation.requiredCapabilities();
// Handle the plugin-parameter part
// In the default case do an auto-detection ...
final Class<? extends Plugin> typeOfMethod = (Class<? extends Plugin>) method.getParameterTypes()[0];
this.logger.fine("Injecting plugin by autodetection (" + typeOfMethod.getName() + ") into " + spawnedPlugin.getClass().getName());
try {
method.invoke(spawnedPlugin, this.pluginManagerImpl.getPlugin(typeOfMethod, new OptionCapabilities(capabilities)));
} catch (IllegalArgumentException e) {
this.logger.warning("Unable to inject plugin " + typeOfMethod + " into method " + method);
e.printStackTrace();
} catch (InvocationTargetException e) {
this.logger.warning("Unable to inject plugin " + typeOfMethod + " into method " + method);