@Override public void safeReleaseResource(ResteasyWebTarget client, URL url) { String ipPort = url.getServerPortStr(); String protocolKey = MotanFrameworkUtil.getProtocolKey(url); synchronized (ipPort2ClientShareChannel) { if (client != ipPort2ClientShareChannel.get(ipPort)) { client.getResteasyClient().close(); return; } Set<String> urls = client2UrlsShareChannel.get(client); urls.remove(protocolKey); if (urls.isEmpty()) { client.getResteasyClient().close(); ipPort2ClientShareChannel.remove(ipPort); client2UrlsShareChannel.remove(client); } } }
protected Object invokeAsync(final Object[] args) { ClientInvocationBuilder builder = (ClientInvocationBuilder) webTarget.request(); ClientInvocation request = createRequest(args); builder.setClientInvocation(request); ExecutorService executor = webTarget.getResteasyClient().getScheduledExecutor(); if (executor == null) { executor = webTarget.getResteasyClient().asyncInvocationExecutor(); } RxInvoker<?> rxInvoker = (RxInvoker<?>) rxInvokerProvider.getRxInvoker(builder, executor); Type type = method.getGenericReturnType(); if (type instanceof ParameterizedType) { type = ((ParameterizedType) type).getActualTypeArguments()[0]; } GenericType<?> gt = new GenericType(type); Object e = request.getEntity(); Object o = null; if (e != null) { o = rxInvoker.method(getHttpMethod(), Entity.entity(e, request.getHeaders().getMediaType()), gt); } else { o = rxInvoker.method(getHttpMethod(), gt); } return o; }
if (target instanceof ResteasyWebTarget) scheduledExecutor = ((ResteasyWebTarget) target).getResteasyClient().getScheduledExecutor();
protected ClientInvocation createRequest(Object[] args) { WebTarget target = this.webTarget; for (int i = 0; i < processors.length; i++) { if (processors != null && processors[i] instanceof WebTargetProcessor) { WebTargetProcessor processor = (WebTargetProcessor)processors[i]; target = processor.build(target, args[i]); } } ClientConfiguration parentConfiguration=(ClientConfiguration) target.getConfiguration(); ClientInvocation clientInvocation = new ClientInvocation(this.webTarget.getResteasyClient(), target.getUri(), new ClientRequestHeaders(parentConfiguration), parentConfiguration); clientInvocation.setClientInvoker(this); if (accepts != null) { clientInvocation.getHeaders().accept(accepts); } for (int i = 0; i < processors.length; i++) { if (processors != null && processors[i] instanceof InvocationProcessor) { InvocationProcessor processor = (InvocationProcessor)processors[i]; processor.process(clientInvocation, args[i]); } } clientInvocation.setMethod(httpMethod); return clientInvocation; }
if (target instanceof ResteasyWebTarget) scheduledExecutor = ((ResteasyWebTarget) target).getResteasyClient().getScheduledExecutor();
protected Object invokeAsync(final Object[] args) { ClientInvocationBuilder builder = (ClientInvocationBuilder) webTarget.request(); ClientInvocation request = createRequest(args); builder.setInvocation(request); ExecutorService executor = webTarget.getResteasyClient().getScheduledExecutor(); if (executor == null) { executor = webTarget.getResteasyClient().asyncInvocationExecutor(); } RxInvoker<?> rxInvoker = (RxInvoker<?>) rxInvokerProvider.getRxInvoker(builder, executor); Type type = method.getGenericReturnType(); if (type instanceof ParameterizedType) { type = ((ParameterizedType) type).getActualTypeArguments()[0]; } GenericType<?> gt = new GenericType(type); Object e = request.getEntity(); Object o = null; if (e != null) { o = rxInvoker.method(getHttpMethod(), Entity.entity(e, request.getHeaders().getMediaType()), gt); } else { o = rxInvoker.method(getHttpMethod(), gt); } return o; }