/** * Creates a proxy * @param baseAddress baseAddress * @param cls resource class, if not interface then a CGLIB proxy will be created * @param configLocation classpath location of the configuration resource * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, String configLocation) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); return bean.create(cls); }
/** * Creates a proxy * @param baseAddress baseAddress * @param cls resource class, if not interface then a CGLIB proxy will be created * @param configLocation classpath location of the configuration resource * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, String configLocation) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); return bean.create(cls); }
/** * Creates a proxy * @param baseAddress baseAddress * @param cls resource class, if not interface then a CGLIB proxy will be created * @param configLocation classpath location of the configuration resource * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, String configLocation) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); return bean.create(cls); }
/** * Creates a proxy * @param baseURI baseURI * @param cls resource class, if not interface then a CGLIB proxy will be created * @param inheritHeaders if true then existing proxy headers will be inherited by * subresource proxies if any * @return typed proxy */ public static <T> T create(URI baseURI, Class<T> cls, boolean inheritHeaders) { JAXRSClientFactoryBean bean = getBean(baseURI.toString(), cls, null); bean.setInheritHeaders(inheritHeaders); return bean.create(cls); }
/** * Creates a proxy using a custom class loader * @param baseAddress baseAddress * @param loader class loader * @param cls resource class, if not interface then a CGLIB proxy will be created * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, ClassLoader loader) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setClassLoader(loader); return bean.create(cls); }
/** * Creates a proxy using a custom class loader * @param baseAddress baseAddress * @param loader class loader * @param cls resource class, if not interface then a CGLIB proxy will be created * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, ClassLoader loader) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setClassLoader(loader); return bean.create(cls); }
/** * Creates a proxy using a custom class loader * @param baseAddress baseAddress * @param loader class loader * @param cls resource class, if not interface then a CGLIB proxy will be created * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, ClassLoader loader) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setClassLoader(loader); return bean.create(cls); }
/** * Creates a proxy * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param providers list of providers * @param configLocation classpath location of the configuration resource * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, String configLocation) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); bean.setProviders(providers); return bean.create(cls); }
/** * Creates a proxy * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param providers list of providers * @param configLocation classpath location of the configuration resource * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, String configLocation) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); bean.setProviders(providers); return bean.create(cls); }
JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean(); factoryBean.setAddress("http://localhost:6061/services"); MyServiceInterface documentCapture = factoryBean.create(MyServiceInterface.class); Client client = ClientProxy.getClient(documentCapture); client.getRequestContext().put("use.async.http.conduit", Boolean.TRUE);
private BookStore createJwsBookStoreHMac(String address, boolean bufferPayload, boolean useJwsJsonSignatureFormat) throws Exception { JAXRSClientFactoryBean bean = createJAXRSClientFactoryBean(address, bufferPayload, useJwsJsonSignatureFormat); bean.getProperties(true).put("rs.security.signature.properties", "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties"); return bean.create(BookStore.class); } private BookStore createJwsBookStoreRSA(String address) throws Exception {
private BookStore createJwsBookStoreRSA(String address) throws Exception { JAXRSClientFactoryBean bean = createJAXRSClientFactoryBean(address, false, false); bean.getProperties(true).put("rs.security.signature.properties", "org/apache/cxf/systest/jaxrs/security/alice.jwk.properties"); return bean.create(BookStore.class); } private JAXRSClientFactoryBean createJAXRSClientFactoryBean(String address,
protected BookStore getBookStore(String address, FailoverFeature feature) throws Exception { JAXRSClientFactoryBean bean = createBean(address, feature); bean.setServiceClass(BookStore.class); return bean.create(BookStore.class); }
protected BookStore getBookStore(String address, FailoverFeature feature) throws Exception { JAXRSClientFactoryBean bean = createBean(address, feature); bean.setServiceClass(BookStore.class); return bean.create(BookStore.class); }
ProxyClassLoader classLoader = new ProxyClassLoader(); classLoader.addLoader(resourceApiClass.getClassLoader()); classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader()); JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(baseUrl); bean.setServiceClass(resourceApiClass); bean.setClassLoader(classLoader); return bean.create(resourceApiClass);
@Test public void testGetStringList() throws Exception { String address = "http://localhost:" + PORT; JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.StringListBodyReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store = bean.create(BookStore.class); List<String> str = store.getBookListArray(); assertEquals("Good book", str.get(0)); }
@Test public void testEmptyPostProxy2() throws Exception { String address = "http://localhost:" + PORT; JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store = bean.create(BookStore.class); store.emptypostNoPath(); assertEquals(204, WebClient.client(store).getResponse().getStatus()); }
@Test public void testBookWithSpaceProxyPathUrlEncodedSemicolonOnly() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setServiceClass(BookStore.class); bean.setAddress("http://localhost:" + PORT); bean.getProperties(true).put("url.encode.client.parameters", "true"); bean.getProperties(true).put("url.encode.client.parameters.list", ";"); BookStore store = bean.create(BookStore.class); Book book = store.getBookWithSemicolon("123;:", "custom;:header"); assertEquals(123L, book.getId()); assertEquals("CXF in Action%3B:", book.getName()); }
@Test public void testBookWithSpaceProxyPathUrlEncoded() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setServiceClass(BookStore.class); bean.setAddress("http://localhost:" + PORT); bean.setProperties(Collections.<String, Object>singletonMap("url.encode.client.parameters", Boolean.TRUE)); BookStore store = bean.create(BookStore.class); Book book = store.getBookWithSemicolon("123;:", "custom;:header"); assertEquals(123L, book.getId()); assertEquals("CXF in Action%3B%3A", book.getName()); }
@Test public void testGetStringArray() throws Exception { String address = "http://localhost:" + PORT; JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.StringArrayBodyReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store = bean.create(BookStore.class); String[] str = store.getBookStringArray(); assertEquals("Good book", str[0]); }