use of com.continuuity.weave.api.EventHandler in project weave by continuuity.
the class ApplicationMasterService method createEventHandler.
private EventHandler createEventHandler(WeaveSpecification weaveSpec) {
try {
// Should be able to load by this class ClassLoader, as they packaged in the same jar.
EventHandlerSpecification handlerSpec = weaveSpec.getEventHandler();
Class<?> handlerClass = getClass().getClassLoader().loadClass(handlerSpec.getClassName());
Preconditions.checkArgument(EventHandler.class.isAssignableFrom(handlerClass), "Class {} does not implements {}", handlerClass, EventHandler.class.getName());
return Instances.newInstance((Class<? extends EventHandler>) handlerClass);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations