use of io.muoncore.newton.AggregateRoot in project newton by muoncore.
the class MuonLookupUtils method init.
static void init(String[] packages) {
List<URL> urls = new ArrayList<>();
urls.addAll(ClasspathHelper.forPackage("io.muoncore.newton", MuonLookupUtils.class.getClassLoader()));
for (String aPackage : packages) {
log.info("Adding package {}", aPackage);
Collection<URL> urls1 = ClasspathHelper.forPackage(aPackage, MuonLookupUtils.class.getClassLoader());
log.info("Got {}", urls1);
urls.addAll(urls1);
}
log.info("Booting Reflections with urls {}", urls);
Reflections reflections = new Reflections(new ConfigurationBuilder().addScanners(new SubTypesScanner()).addScanners(new TypeAnnotationsScanner()).setUrls(urls));
final Set<Class<? extends NewtonEvent>> eventTypes = reflections.getSubTypesOf(NewtonEvent.class);
eventTypeMappings = new HashMap<>();
for (Class<? extends NewtonEvent> newtonEvent : eventTypes) {
eventTypeMappings.put(newtonEvent.getSimpleName(), newtonEvent);
}
final Set<Class<? extends AggregateRoot>> aggregateRootTypes = reflections.getSubTypesOf(AggregateRoot.class);
aggregateRootMappings = new HashMap<>();
for (Class<? extends AggregateRoot> root : aggregateRootTypes) {
aggregateRootMappings.put(root.getSimpleName(), root);
}
final Set<Class<? extends Saga>> sagaTypes = reflections.getSubTypesOf(Saga.class);
sagaTypeMappings = new HashMap<>();
for (Class<? extends Saga> root : sagaTypes) {
sagaTypeMappings.put(root.getSimpleName(), root);
}
ready.countDown();
}
Aggregations