}
public static void applyModules() {
ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
CopyStrategyLibrary copyStrategyLibrary = CoreRegistry.get(CopyStrategyLibrary.class);
copyStrategyLibrary.clear();
for (Class<? extends CopyStrategy> copyStrategy : moduleManager.getEnvironment().getSubtypesOf(CopyStrategy.class)) {
if (copyStrategy.getAnnotation(RegisterCopyStrategy.class) == null) {
continue;
}
Class targetType = ReflectionUtil.getTypeParameterForSuper(copyStrategy, CopyStrategy.class, 0);
if (targetType != null) {
try {
copyStrategyLibrary.register(targetType, copyStrategy.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
logger.error("Cannot register CopyStrategy '{}' - failed to instantiate", copyStrategy, e);
}
} else {
logger.error("Cannot register CopyStrategy '{}' - unable to determine target type", copyStrategy);