use of com.codecademy.eventhub.web.commands.Path in project EventHub by Codecademy.
the class Module method getEventHubHandler.
@Provides
private EventHubHandler getEventHubHandler(Injector injector, EventHub eventHub) throws ClassNotFoundException {
Map<String, Provider<Command>> commandsMap = Maps.newHashMap();
Reflections reflections = new Reflections(PACKAGE_NAME);
Set<Class<? extends Command>> commandClasses = reflections.getSubTypesOf(Command.class);
for (Class<? extends Command> commandClass : commandClasses) {
String path = commandClass.getAnnotation(Path.class).value();
//noinspection unchecked
commandsMap.put(path, (Provider<Command>) injector.getProvider(commandClass));
}
return new EventHubHandler(eventHub, commandsMap);
}
Aggregations