/** * Sets the resource class * @param cls the resource class */ public void setResourceClass(Class<?> cls) { setServiceClass(cls); }
/** * Sets the resource class * @param cls the resource class */ public void setResourceClass(Class<?> cls) { setServiceClass(cls); }
/** * Sets the resource class * @param cls the resource class */ public void setResourceClass(Class<?> cls) { setServiceClass(cls); }
private static JAXRSClientFactoryBean getBean(String baseAddress, Class<?> cls, String configLocation) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation); bean.setServiceClass(cls); return bean; }
private static JAXRSClientFactoryBean getBean(String baseAddress, Class<?> cls, String configLocation) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation); bean.setServiceClass(cls); return bean; }
private static JAXRSClientFactoryBean getBean(String baseAddress, Class<?> cls, String configLocation) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation); bean.setServiceClass(cls); return bean; }
public void runCodeProxyClient() throws Exception { System.out.println("*** Running Proxy client initialized from the code ***"); JAXRSClientFactoryBean factoryBean = prepareFactoryBean(); factoryBean.setServiceClass(OrderService.class); OrderService client = factoryBean.create(OrderService.class); useOrderService(client); }
@Override protected void setJaxrsResources(JAXRSClientFactoryBean factory) { factory.setServiceClass(WebClient.class); if (!StringUtils.isEmpty(scanPackages)) { try { final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes = ClasspathScanner.findClasses(scanPackages, Provider.class); factory.setProviders( JAXRSClientFactoryBeanDefinitionParser.getProviders(context, classes.get(Provider.class))); } catch (Exception ex) { throw new ServiceConstructionException(ex); } } }
@Override protected void setJaxrsResources(JAXRSClientFactoryBean factory) { factory.setServiceClass(WebClient.class); if (!StringUtils.isEmpty(scanPackages)) { try { final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes = ClasspathScanner.findClasses(scanPackages, Provider.class); factory.setProviders( JAXRSClientFactoryBeanDefinitionParser.getProviders(context, classes.get(Provider.class))); } catch (Exception ex) { throw new ServiceConstructionException(ex); } } }
/** * Creates a proxy using user resource model * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param modelRef model location * @param providers list of providers * @param configLocation classpath location of the configuration resource * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, String modelRef, List<?> providers, String configLocation) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); return bean.create(cls); }
/** * Creates a proxy using user resource model * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param modelBeans model beans * @param providers list of providers * @param configLocation classpath location of the configuration resource * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, List<UserResource> modelBeans, List<?> providers, String configLocation) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation); bean.setProviders(providers); bean.setModelBeans(modelBeans); bean.setServiceClass(cls); return bean.create(cls); }
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);
private BookStore createBookStoreTwoRecipients(String address) throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); SpringBusFactory bf = new SpringBusFactory(); URL busFile = JAXRSJweJsonTest.class.getResource("client.xml"); Bus springBus = bf.createBus(busFile.toString()); bean.setBus(springBus); bean.setServiceClass(BookStore.class); bean.setAddress(address); bean.setProvider(new JweJsonWriterInterceptor()); List<String> properties = new ArrayList<>(); properties.add("org/apache/cxf/systest/jaxrs/security/jwejson1.properties"); properties.add("org/apache/cxf/systest/jaxrs/security/jwejson2.properties"); bean.getProperties(true).put(JoseConstants.RSSEC_ENCRYPTION_PROPS, properties); return bean.create(BookStore.class); }
private BookStore createBookStore(String address, String propLoc) throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); SpringBusFactory bf = new SpringBusFactory(); URL busFile = JAXRSJweJsonTest.class.getResource("client.xml"); Bus springBus = bf.createBus(busFile.toString()); bean.setBus(springBus); bean.setServiceClass(BookStore.class); bean.setAddress(address); List<Object> providers = new LinkedList<>(); JweJsonWriterInterceptor writer = new JweJsonWriterInterceptor(); providers.add(writer); providers.add(new JweJsonClientResponseFilter()); bean.setProviders(providers); bean.getProperties(true).put(JoseConstants.RSSEC_ENCRYPTION_PROPS, propLoc); return bean.create(BookStore.class); }
private Object createJaxrsProxy(String address, Class<?> iClass, ClassLoader loader, EndpointDescription endpoint, List<Object> intents) { JAXRSClientFactoryBean factory = new JAXRSClientFactoryBean(); factory.setAddress(address); if (loader != null) { factory.setClassLoader(loader); } addContextProperties(factory, endpoint.getProperties(), RsConstants.RS_CONTEXT_PROPS_PROP_KEY); factory.setServiceClass(iClass); applyIntents(intents, factory); return ProxyFactory.create(factory.create(), iClass); }
@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 testHelloRestValidationFailsIfNameIsNullClient() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/bwrest"); bean.setServiceClass(BookWorld.class); bean.setFeatures(Arrays.asList(new JAXRSClientBeanValidationFeature())); BookWorld service = bean.create(BookWorld.class); BookWithValidation bw = service.echoBook(new BookWithValidation("RS", "123")); assertEquals("123", bw.getId()); try { service.echoBook(new BookWithValidation(null, "123")); fail("Validation failure expected"); } catch (ConstraintViolationException ex) { // complete } } @Test