/** * Retieves ClientConfiguration * @param client proxy or http-centric Client * @return underlying ClientConfiguration instance */ public static ClientConfiguration getConfig(Object client) { if (client instanceof Client) { if (client instanceof WebClient) { return ((AbstractClient)client).getConfiguration(); } else if (client instanceof InvocationHandlerAware) { Object handler = ((InvocationHandlerAware)client).getInvocationHandler(); return ((AbstractClient)handler).getConfiguration(); } } throw new IllegalArgumentException("Not a valid Client"); }
/** * Retrieves ClientConfiguration * @param client proxy or http-centric Client * @return underlying ClientConfiguration instance */ public static ClientConfiguration getConfig(Object client) { if (client instanceof WebTargetImpl) { client = ((WebTargetImpl)client).getWebClient(); } else if (client instanceof InvocationBuilderImpl) { client = ((InvocationBuilderImpl)client).getWebClient(); } if (client instanceof Client) { if (client instanceof WebClient) { return ((AbstractClient)client).getConfiguration(); } else if (client instanceof InvocationHandlerAware) { Object handler = ((InvocationHandlerAware)client).getInvocationHandler(); return ((AbstractClient)handler).getConfiguration(); } } throw new IllegalArgumentException("Not a valid Client"); }
/** * Retrieves ClientConfiguration * @param client proxy or http-centric Client * @return underlying ClientConfiguration instance */ public static ClientConfiguration getConfig(Object client) { if (client instanceof WebTargetImpl) { client = ((WebTargetImpl)client).getWebClient(); } else if (client instanceof InvocationBuilderImpl) { client = ((InvocationBuilderImpl)client).getWebClient(); } if (client instanceof Client) { if (client instanceof WebClient) { return ((AbstractClient)client).getConfiguration(); } else if (client instanceof InvocationHandlerAware) { Object handler = ((InvocationHandlerAware)client).getInvocationHandler(); return ((AbstractClient)handler).getConfiguration(); } } throw new IllegalArgumentException("Not a valid Client"); }
static void copyProperties(Client toClient, Client fromClient) { AbstractClient newClient = toAbstractClient(toClient); AbstractClient oldClient = toAbstractClient(fromClient); newClient.setConfiguration(oldClient.getConfiguration()); }
static void copyProperties(Client toClient, Client fromClient) { AbstractClient newClient = toAbstractClient(toClient); AbstractClient oldClient = toAbstractClient(fromClient); newClient.setConfiguration(oldClient.getConfiguration()); }
protected void applyFeatures(AbstractClient client) { if (getFeatures() != null) { getFeatures().forEach(feature -> { feature.initialize(client.getConfiguration(), getBus()); }); } }
static void copyProperties(Client toClient, Client fromClient) { AbstractClient newClient = toAbstractClient(toClient); AbstractClient oldClient = toAbstractClient(fromClient); newClient.setConfiguration(oldClient.getConfiguration()); }
protected void applyFeatures(AbstractClient client) { if (getFeatures() != null) { getFeatures().forEach(feature -> { feature.initialize(client.getConfiguration(), getBus()); }); } }
protected void applyFeatures(AbstractClient client) { if (getFeatures() != null) { for (Feature feature : getFeatures()) { feature.initialize(client.getConfiguration(), getBus()); } } }
protected void completeExchange(Object response, Exchange exchange, boolean proxy) { // higher level conduits such as FailoverTargetSelector need to // clear the request state but a fair number of response objects // depend on InputStream being still open thus lower-level conduits // operating on InputStream don't have to close streams pro-actively exchange.put(KEEP_CONDUIT_ALIVE, true); getConfiguration().getConduitSelector().complete(exchange); String s = (String)exchange.getOutMessage().get(Message.BASE_PATH); if (s != null && !state.getBaseURI().toString().equals(s)) { // usually the (failover) conduit change will result in a retry call // which in turn will reset the base and current request URI. // In some cases, such as the "upfront" load-balancing, etc, the retries // won't be executed so it is necessary to reset the base address calculateNewRequestURI(URI.create(s), getCurrentURI(), proxy); } }
return r; if (PropertyUtils.isTrue(super.getConfiguration().getResponseContext().get(BUFFER_PROXY_RESPONSE))) { r.bufferEntity();
client.getConfiguration().setConduitSelector(getConduitSelector(ep)); client.getConfiguration().setBus(getBus()); client.getConfiguration().getOutInterceptors().addAll(getOutInterceptors()); client.getConfiguration().getOutInterceptors().addAll(ep.getOutInterceptors()); client.getConfiguration().getInInterceptors().addAll(getInInterceptors()); client.getConfiguration().getInInterceptors().addAll(ep.getInInterceptors()); client.getConfiguration().getInFaultInterceptors().addAll(getInFaultInterceptors());
protected void completeExchange(Exchange exchange, boolean proxy) { // higher level conduits such as FailoverTargetSelector need to // clear the request state but a fair number of response objects // depend on InputStream being still open thus lower-level conduits // operating on InputStream don't have to close streams pro-actively exchange.put(KEEP_CONDUIT_ALIVE, true); getConfiguration().getConduitSelector().complete(exchange); String s = (String)exchange.getOutMessage().get(Message.BASE_PATH); if (s != null && !state.getBaseURI().toString().equals(s)) { // usually the (failover) conduit change will result in a retry call // which in turn will reset the base and current request URI. // In some cases, such as the "upfront" load-balancing, etc, the retries // won't be executed so it is necessary to reset the base address calculateNewRequestURI(URI.create(s), getCurrentURI(), proxy); return; } s = (String)exchange.getOutMessage().get("transport.retransmit.url"); if (s != null && !state.getBaseURI().toString().equals(s)) { calculateNewRequestURI(URI.create(s), getCurrentURI(), proxy); } }
protected void completeExchange(Exchange exchange, boolean proxy) { // higher level conduits such as FailoverTargetSelector need to // clear the request state but a fair number of response objects // depend on InputStream being still open thus lower-level conduits // operating on InputStream don't have to close streams pro-actively exchange.put(KEEP_CONDUIT_ALIVE, true); getConfiguration().getConduitSelector().complete(exchange); String s = (String)exchange.getOutMessage().get(Message.BASE_PATH); if (s != null && !state.getBaseURI().toString().equals(s)) { // usually the (failover) conduit change will result in a retry call // which in turn will reset the base and current request URI. // In some cases, such as the "upfront" load-balancing, etc, the retries // won't be executed so it is necessary to reset the base address calculateNewRequestURI(URI.create(s), getCurrentURI(), proxy); return; } s = (String)exchange.getOutMessage().get("transport.retransmit.url"); if (s != null && !state.getBaseURI().toString().equals(s)) { calculateNewRequestURI(URI.create(s), getCurrentURI(), proxy); } }
ClientLifeCycleManager mgr = cfg.getBus().getExtension(ClientLifeCycleManager.class); if (null != mgr) { mgr.clientDestroyed(new FrontendClientAdapter(getConfiguration()));
public void close() { if (cfg.getBus() == null) { return; } ClientLifeCycleManager mgr = cfg.getBus().getExtension(ClientLifeCycleManager.class); if (null != mgr) { mgr.clientDestroyed(new FrontendClientAdapter(getConfiguration())); } if (cfg.getConduitSelector() instanceof Closeable) { try { ((Closeable)cfg.getConduitSelector()).close(); } catch (IOException e) { //ignore, we're destroying anyway } } else { cfg.getConduit().close(); } state.reset(); state = null; cfg = null; }
protected Object[] preProcessResult(Message message) throws Exception { Exchange exchange = message.getExchange(); Exception ex = message.getContent(Exception.class); if (ex != null || PropertyUtils.isTrue(exchange.get(SERVICE_NOT_AVAIL_PROPERTY)) && PropertyUtils.isTrue(exchange.get(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY))) { getConfiguration().getConduitSelector().complete(exchange); } if (ex != null) { checkClientException(message, ex); } checkClientException(message, exchange.get(Exception.class)); List<?> result = exchange.get(List.class); return result != null ? result.toArray() : null; }
protected Object[] preProcessResult(Message message) throws Exception { Exchange exchange = message.getExchange(); Exception ex = message.getContent(Exception.class); if (ex == null) { ex = message.getExchange().get(Exception.class); } if (ex == null && !exchange.isOneWay()) { synchronized (exchange) { while (exchange.get("IN_CHAIN_COMPLETE") == null) { exchange.wait(cfg.getSynchronousTimeout()); } } } if (ex == null) { ex = message.getContent(Exception.class); } if (ex != null || PropertyUtils.isTrue(exchange.get(SERVICE_NOT_AVAIL_PROPERTY)) && PropertyUtils.isTrue(exchange.get(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY))) { getConfiguration().getConduitSelector().complete(exchange); } if (ex != null) { checkClientException(message, ex); } checkClientException(message, exchange.get(Exception.class)); List<?> result = exchange.get(List.class); return result != null ? result.toArray() : null; }
protected Object[] preProcessResult(Message message) throws Exception { Exchange exchange = message.getExchange(); Exception ex = message.getContent(Exception.class); if (ex == null) { ex = message.getExchange().get(Exception.class); } if (ex == null && !exchange.isOneWay()) { synchronized (exchange) { while (exchange.get("IN_CHAIN_COMPLETE") == null) { exchange.wait(cfg.getSynchronousTimeout()); } } } if (ex == null) { ex = message.getContent(Exception.class); } if (ex != null || PropertyUtils.isTrue(exchange.get(SERVICE_NOT_AVAIL_PROPERTY)) && PropertyUtils.isTrue(exchange.get(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY))) { getConfiguration().getConduitSelector().complete(exchange); } if (ex != null) { checkClientException(message, ex); } checkClientException(message, exchange.get(Exception.class)); List<?> result = exchange.get(List.class); return result != null ? result.toArray() : null; }
final PathParam pp = AnnotationUtils.getAnnotation(anns, PathParam.class); if (null != pp) { Object allowEmptyProp = getConfiguration().getBus().getProperty(ALLOW_EMPTY_PATH_VALUES); if (!PropertyUtils.isTrue(allowEmptyProp)) { throw new IllegalArgumentException("Value for " + pp.value() + " is not specified");