/** * 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 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 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 thread safe 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 threadSafe if true then thread-safe proxy will be created * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, String modelRef, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.create(cls); }
/** * Creates a thread safe 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 threadSafe if true then thread-safe proxy will be created * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, String modelRef, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.create(cls); }
/** * Creates a thread safe proxy using user resource model and allows to * specify time to keep state. * @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 timeToKeepState how long to keep this state * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, String modelRef, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.create(cls); }
/** * Creates a thread safe proxy using user resource model and allows to * specify time to keep state. * @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 timeToKeepState how long to keep this state * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, String modelRef, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.create(cls); }
protected void setupJAXRSClientFactoryBean(JAXRSClientFactoryBean cfb, String address) { if (modelRef != null) { cfb.setModelRef(modelRef); } if (getResourceClasses() != null && !getResourceClasses().isEmpty()) { cfb.setResourceClass(getResourceClasses().get(0)); cfb.getServiceFactory().setResourceClasses(getResourceClasses()); } setupCommonFactoryProperties(cfb); cfb.setThreadSafe(true); getNullSafeCxfRsEndpointConfigurer().configure(cfb); // Add the address could be override by message header if (address != null) { cfb.setAddress(address); } }
/** * Creates a thread safe proxy using user resource model and allows to * specify time to keep state. * @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 timeToKeepState how long to keep this state * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, String modelRef, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.create(cls); }
/** * Creates a thread safe 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 threadSafe if true then thread-safe proxy will be created * @return typed proxy */ public static <T> T createFromModel(String baseAddress, Class<T> cls, String modelRef, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.create(cls); }
@Test public void testGetBook123UserModelAuthorize() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/usermodel/bookstore/books"); bean.setUsername("Barry"); bean.setPassword("password"); bean.setModelRef("classpath:org/apache/cxf/systest/jaxrs/resources/resources.xml"); WebClient proxy = bean.createWebClient(); proxy.path("{id}/authorize", 123); Book book = proxy.get(Book.class); assertEquals(123L, book.getId()); }