/** * Indicates if Response may still be expected for oneway requests. * For example, 202 in case of HTTP * @return true if the response can be expected */ public boolean isResponseExpectedForOneway() { return getConduit() instanceof HTTPConduit ? true : false; }
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; }
/** * Gets the HTTP conduit responsible for a transport-level * communication with the remote service. * @return the HTTP conduit */ public HTTPConduit getHttpConduit() { Conduit conduit = getConduit(); return conduit instanceof HTTPConduit ? (HTTPConduit)conduit : null; }
@Override public Conduit getConduit() { return config.getConduit(); }
@Override public Conduit getConduit() { return config.getConduit(); }
@Override public Conduit getConduit() { return config.getConduit(); }
/** * Indicates if Response may still be expected for oneway requests. * For example, 202 in case of HTTP * @return true if the response can be expected */ public boolean isResponseExpectedForOneway() { return getConduit() instanceof HTTPConduit ? true : false; }
/** * Gets the HTTP conduit responsible for a transport-level * communication with the remote service. * @return the HTTP conduit */ public HTTPConduit getHttpConduit() { Conduit conduit = getConduit(); return conduit instanceof HTTPConduit ? (HTTPConduit)conduit : null; }
/** * Indicates if Response may still be expected for oneway requests. * For example, 202 in case of HTTP * @return true if the response can be expected */ public boolean isResponseExpectedForOneway() { return getConduit() instanceof HTTPConduit ? true : false; }
/** * Gets the HTTP conduit responsible for a transport-level * communication with the remote service. * @return the HTTP conduit */ public HTTPConduit getHttpConduit() { Conduit conduit = getConduit(); return conduit instanceof HTTPConduit ? (HTTPConduit)conduit : null; }
YourService proxy = JAXRSClientFactory.create(YourService.class); ClientConfiguration config = WebClient.getConfig(proxy); HTTPConduit conduit1 = (HTTPConduit)config.getConduit(); System.out.println(conduit1.getClient().getProxyServer());
public long getSynchronousTimeout() { Conduit conduit = getConduit(); if (conduit instanceof HTTPConduit) { return ((HTTPConduit)conduit).getClient().getReceiveTimeout(); } return synchronousTimeout; }
@Override public void configureClient(Client client) { HTTPConduit httpConduit = (HTTPConduit) WebClient.getConfig(client).getConduit(); setupHttpConduit(httpConduit); }
public long getSynchronousTimeout() { Conduit conduit = getConduit(); if (conduit instanceof HTTPConduit) { return ((HTTPConduit)conduit).getClient().getReceiveTimeout(); } else { return synchronousTimeout; } }
public long getSynchronousTimeout() { Conduit conduit = getConduit(); if (conduit instanceof HTTPConduit) { return ((HTTPConduit)conduit).getClient().getReceiveTimeout(); } return synchronousTimeout; }
@Override public void configureClient(Client client) { HTTPConduit httpConduit = (HTTPConduit) WebClient.getConfig(client).getConduit(); setupHttpConduit(httpConduit); }
private WebClient configureTLS(WebClient client) throws Exception { if (client.getBaseURI().getScheme().startsWith(HTTPS_SCHEME) && !(trustStorePath == null || trustStorePassword ==null)) { HTTPConduit conduit = (HTTPConduit)WebClient.getConfig(client).getConduit(); TLSClientParameters tlsParameters = new TLSClientParameters(); KeyStore trustStore = KeyStore.getInstance("JKS"); trustStore.load(new FileInputStream(trustStorePath), trustStorePassword.toCharArray()); TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); trustFactory.init(trustStore); tlsParameters.setTrustManagers(trustFactory.getTrustManagers()); // allow a hostname mismatch tlsParameters.setDisableCNCheck(true); conduit.setTlsClientParameters(tlsParameters); } return client; }
ClientConfiguration config = WebClient.getConfig(proxy); HTTPConduit conduit = (HTTPConduit) config.getConduit(); AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy(); authorizationPolicy.setUserName(USERNAME); authorizationPolicy.setPassword(PASSWORD); conduit.setAuthorization(authorizationPolicy);
/** * Creates an instance of the given service class, with configured content type and authentication. * * @param <T> any service class * @param serviceClass service class reference * @return service instance of the given reference class */ public <T> T getService(final Class<T> serviceClass) { synchronized (restClientFactory) { restClientFactory.setServiceClass(serviceClass); T serviceInstance = restClientFactory.create(serviceClass); Client client = WebClient.client(serviceInstance); client.type(mediaType).accept(mediaType); if (serviceInstance instanceof AnyService || serviceInstance instanceof ExecutableService) { client.accept(RESTHeaders.MULTIPART_MIXED); } ClientConfiguration config = WebClient.getConfig(client); config.getRequestContext().put(HEADER_SPLIT_PROPERTY, true); config.getRequestContext().put(URLConnectionHTTPConduit.HTTPURL_CONNECTION_METHOD_REFLECTION, true); if (useCompression) { config.getInInterceptors().add(new GZIPInInterceptor()); config.getOutInterceptors().add(new GZIPOutInterceptor()); } if (tlsClientParameters != null) { HTTPConduit httpConduit = (HTTPConduit) config.getConduit(); httpConduit.setTlsClientParameters(tlsClientParameters); } return serviceInstance; } }
@Test public void testGetBook123Client() throws Exception { String baseAddress = "http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress, BookStoreJaxrsJaxws.class); HTTPConduit conduit = (HTTPConduit)WebClient.getConfig(proxy).getConduit(); Book b = proxy.getBook(Long.valueOf("123")); assertEquals(123, b.getId()); assertEquals("CXF in Action", b.getName()); HTTPConduit conduit2 = (HTTPConduit)WebClient.getConfig(proxy).getConduit(); assertSame(conduit, conduit2); conduit.getClient().setAutoRedirect(true); b = proxy.getBook(Long.valueOf("123")); assertEquals(123, b.getId()); assertEquals("CXF in Action", b.getName()); }