Search in sources :

Example 1 with EventHandler

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);
    }
}
Also used : EventHandler(com.continuuity.weave.api.EventHandler) EventHandlerSpecification(com.continuuity.weave.api.EventHandlerSpecification) IOException(java.io.IOException)

Aggregations

EventHandler (com.continuuity.weave.api.EventHandler)1 EventHandlerSpecification (com.continuuity.weave.api.EventHandlerSpecification)1 IOException (java.io.IOException)1