public void requestHandlerRemoved(ServiceReference<RequestHandler> ref) { RequestHandler handler = registeredHandlers.remove(ref); System.out.println("Un-Registering Request Handler: " + handler.getClass().getName()); handler .getHandles() .forEach( (k, v) -> { handlerMapping.remove(k); }); registeredHandlers.remove(ref); }
@ServiceDependency(removed = "requestHandlerRemoved", required = false) public void requestHandlerAdded(ServiceReference<RequestHandler> ref, RequestHandler handler) { System.out.println("Registering Request Handler: " + handler.getClass().getName()); registeredHandlers.put(ref, handler); handler .getHandles() .forEach( (k, v) -> { handlerMapping.put( k.getName(), new HandlerMapping() .setRequestClassName(k.getName()) .setRequestHandlerInstance(handler) .setAuthorizationHandlerClassName(v.getName())); }); }
@Override public Response handle(RequestAsync request) throws HandlerNotFoundException { log.debug("handling async request:"); RequestHandler handler = getHandler(request.getClass()); return handler.handle(request); }
@Override public Response handle(Request request) throws HandlerNotFoundException { RequestHandler handler = getHandler(request.getClass()); return handler.handle(request); }