private static JAXRSClientFactoryBean cleanFactory(JAXRSClientFactoryBean bean) { bean.setUsername(null); bean.setPassword(null); bean.setInitialState(null); bean.setFeatures(Arrays.<AbstractFeature>asList()); return bean; }
/** * Creates a thread safe WebClient * @param baseAddress baseURI * @param providers list of providers * @param timeToKeepState time to keep this thread safe state. */ public static WebClient create(String baseAddress, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.createWebClient(); }
/** * Creates a thread safe WebClient * @param baseAddress baseURI * @param providers list of providers * @param timeToKeepState time to keep this thread safe state. */ public static WebClient create(String baseAddress, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.createWebClient(); }
/** * Creates WebClient * @param baseURI baseURI * @param providers list of providers */ public static WebClient create(String baseAddress, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.createWebClient(); }
/** * Creates a thread safe WebClient * @param baseURI baseURI * @param providers list of providers * @param timeToKeepState time to keep this thread safe state. */ public static WebClient create(String baseAddress, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.createWebClient(); }
/** * Creates a thread safe proxy 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 providers list of providers * @param timeToKeepState how long to keep this state * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.create(cls); }
/** * Creates WebClient * @param baseAddress baseURI * @param providers list of providers * @param threadSafe if true ThreadLocalClientState is used */ public static WebClient create(String baseAddress, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.createWebClient(); }
/** * Creates WebClient * @param baseAddress baseURI * @param providers list of providers * @param threadSafe if true ThreadLocalClientState is used */ public static WebClient create(String baseAddress, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = getBean(baseAddress, null); bean.setProviders(providers); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.createWebClient(); }
/** * Creates a thread safe proxy 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 providers list of providers * @param timeToKeepState how long to keep this state * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.create(cls); }
/** * Creates a thread safe proxy * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param providers list of providers * @param threadSafe if true then a thread-safe proxy will be created * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setProviders(providers); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.create(cls); }
/** * Creates a thread safe proxy * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param providers list of providers * @param threadSafe if true then a thread-safe proxy will be created * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setProviders(providers); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } return bean.create(cls); }
/** * Creates a thread safe proxy 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 providers list of providers * @param timeToKeepState how long to keep this state * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, long timeToKeepState) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setProviders(providers); bean.setInitialState(new ThreadLocalClientState(baseAddress, timeToKeepState)); return bean.create(cls); }
/** * Creates a thread safe proxy * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param providers list of providers * @param threadSafe if true then a thread-safe proxy will be created * @return typed proxy */ public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, boolean threadSafe) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setProviders(providers); 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 * @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); }
/** * 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); }
/** * Creates a proxy, baseURI will be set to Client currentURI * @param client Client instance * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param inheritHeaders if true then existing Client headers will be inherited by new proxy * and subresource proxies if any * @return typed proxy */ public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) { JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null); bean.setInheritHeaders(inheritHeaders); ClientState clientState = WebClient.getClientState(client); T proxy = null; if (clientState == null) { proxy = bean.create(cls); if (inheritHeaders) { WebClient.client(proxy).headers(client.getHeaders()); } } else { MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null; bean.setInitialState(clientState.newState(client.getCurrentURI(), headers, null)); proxy = bean.create(cls); } WebClient.copyProperties(WebClient.client(proxy), client); return proxy; }