use of com.b2international.commons.CompositeClassLoader in project snow-owl by b2ihealthcare.
the class AsyncRequest method execute.
/**
* Executes the asynchronous request using the event bus passed in.
* @param bus
* @return {@link Promise}
*/
public Promise<R> execute(IEventBus bus) {
final Promise<R> promise = new Promise<>();
final Class<R> responseType = request.getReturnType();
final CompositeClassLoader classLoader = new CompositeClassLoader();
classLoader.add(request.getClassLoader());
request.getNestedRequests().stream().map(Request::getClassLoader).forEach(classLoader::add);
request.getNestedRequests().stream().map(r -> r.getClass().getClassLoader()).forEach(classLoader::add);
bus.send(Request.ADDRESS, request, Request.TAG, Collections.emptyMap(), new IHandler<IMessage>() {
@Override
public void handle(IMessage message) {
try {
if (message.isSucceeded()) {
promise.resolve(message.body(responseType, classLoader), message.headers());
} else {
promise.reject(message.body(Throwable.class, AsyncRequest.class.getClassLoader()));
}
} catch (Throwable e) {
promise.reject(e);
}
}
});
return promise;
}
use of com.b2international.commons.CompositeClassLoader in project snow-owl by b2ihealthcare.
the class BulkRequest method getClassLoader.
@Override
public ClassLoader getClassLoader() {
final CompositeClassLoader classLoader = new CompositeClassLoader();
classLoader.add(Request.super.getClassLoader());
for (Request<C, ?> req : requests) {
classLoader.add(req.getClassLoader());
}
return classLoader;
}
Aggregations