@Override public R invoke(Object proxy, Method invokedMethod, Object[] args) throws Throwable { try { return delegate.invoke(proxy, invokedMethod, args); } catch (TimeoutException timeout) { return null; } }
@Override public R invoke(Object proxy, Method invokedMethod, Object[] args) throws Throwable { try { return delegate.invoke(proxy, invokedMethod, args); } catch (InterruptedException timeout) { Thread.currentThread().interrupt(); return null; } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Object.class.equals(method.getDeclaringClass())) { return method.invoke(this, args); } else { final InvocationHandler invocationHandler = dispatchers.get(method); return invocationHandler.invoke(proxy, method, args); } }
@Override public R invoke(Object proxy, Method invokedMethod, Object[] args) throws Throwable { try { return delegate.invoke(proxy, invokedMethod, args); } catch (ExecutionException e) { Throwable cause = e.getCause(); for (Class<?> exception : declaredExceptions) { if (exception.isInstance(cause)) { throw cause; } } throw new CommandExecutionException( "Command execution resulted in a checked exception that was " + "not declared on the gateway", cause); } }
private void process(HttpServletRequest request, HttpServletResponse resp) { AsyncContext asyncContext = request.startAsync(); if (request.getRequestURL().toString().endsWith("/CORS")) { resp.addHeader("Access-Control-Allow-Origin", "*"); resp.addHeader("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE"); resp.addHeader( "Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); } // Just ACCEPT and REPLY OK if OPTIONS if (request.getMethod().equals("OPTIONS")) { resp.setStatus(HttpServletResponse.SC_OK); } String fullPath = request.getRequestURI(); fullPath = (fullPath.substring(fullPath.indexOf("/service/") + 9)); String parts[] = fullPath.split("/"); String beanName = parts[0]; String method = parts[1]; String params = request.getParameter("params"); if (request.getMethod().equals("POST")) { try { StringBuilder buffer = new StringBuilder(); BufferedReader reader; reader = request.getReader(); String line; while ((line = reader.readLine()) != null) { buffer.append(line); } params = buffer.toString(); } catch (Exception e) { // TODO: handle exception } } JsonObject paramsObj = CommonUtils.parse(params).getAsJsonObject(); String UID = session.getId(); // (paramsObj.get("sessionUID")).getAsString(); NGSessionScopeContext.setCurrentContext(UID); receiveEvents.fire(new HalfDuplexDataReceivedEvent(paramsObj)); Object result = remoteInvoker.invoke(locator.lookup(beanName, UID), method, paramsObj, UID); try { PrintWriter writer = asyncContext.getResponse().getWriter(); writer.write(util.getJson(result)); writer.flush(); asyncContext.complete(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }