@Test(expected = IllegalArgumentException.class) public void shouldBlowUpIfClientTypeContainsSyncMethods() { final ClientBuilder<WithSync> clientBuilder = new ClientBuilder<>(WithSync.class); clientBuilder.build(); }
public T build() { if (!type.isInterface()) { throw new IllegalArgumentException("Type " + type.getCanonicalName() + " must be an interface as client uses JDK proxy"); } final ClassLoader loader = ClientBuilder.class.getClassLoader(); final HttpClient httpClient = httpClientBuilder.build(); final Map<Method, AbstractClientEndpoint> endpoints = extractEndpointsFromType(httpClient); final HttpInvocationHandler handler = new HttpInvocationHandler(targetProvider, httpClient, endpoints, dispatchStrategy); @SuppressWarnings("unchecked") final T proxy = (T) Proxy.newProxyInstance(loader, new Class[]{type, Closeable.class}, handler); return proxy; }
ClientBuilder { public T build() { if (!type.isInterface()) { throw new IllegalArgumentException("Type " + type.getCanonicalName() + " must be an interface as client uses JDK proxy"); } final ClassLoader loader = ClientBuilder.class.getClassLoader(); final HttpClient httpClient = httpClientBuilder.build(); final Map<Method, AbstractClientEndpoint> endpoints = extractEndpointsFromType(httpClient); final HttpInvocationHandler handler = new HttpInvocationHandler(targetProvider, httpClient, endpoints, dispatchStrategy); @SuppressWarnings("unchecked") final T proxy = (T) Proxy.newProxyInstance(loader, new Class[]{type, Closeable.class}, handler); return proxy; } }
ClientBuilder { public T build() { if (!type.isInterface()) { throw new IllegalArgumentException("Type " + type.getCanonicalName() + " must be an interface as client uses JDK proxy"); } final ClassLoader loader = ClientBuilder.class.getClassLoader(); final HttpClient httpClient = httpClientBuilder.build(); final Map<Method, AbstractClientEndpoint> endpoints = extractEndpointsFromType(httpClient); final HttpInvocationHandler handler = new HttpInvocationHandler(targetProvider, httpClient, endpoints, dispatchStrategy); @SuppressWarnings("unchecked") final T proxy = (T) Proxy.newProxyInstance(loader, new Class[]{type, Closeable.class}, handler); return proxy; } ClientBuilder(final Class<T> type); }
ClientBuilder { public T build() { if (!type.isInterface()) { throw new IllegalArgumentException("Type " + type.getCanonicalName() + " must be an interface as client uses JDK proxy"); } final ClassLoader loader = ClientBuilder.class.getClassLoader(); final HttpClient httpClient = httpClientBuilder.build(); final Map<Method, AbstractClientEndpoint> endpoints = extractEndpointsFromType(httpClient); final HttpInvocationHandler handler = new HttpInvocationHandler(targetProvider, httpClient, endpoints, dispatchStrategy); @SuppressWarnings("unchecked") final T proxy = (T) Proxy.newProxyInstance(loader, new Class[]{type, Closeable.class}, handler); return proxy; } ClientBuilder(final Class<T> type); ClientBuilder<T> addFilter(final ServiceFilter filter); ClientBuilder<T> setJsonModules(final Module... modules); ClientBuilder<T> setProtocol(final ContentType clientType); ClientBuilder<T> followRedirect(final boolean followRedirect); ClientBuilder<T> setMetricFactory(final MetricFactory metricFactory); ClientBuilder<T> setCompression(final boolean compression); ClientBuilder<T> setMaxConnectionsPerHost(final int maxConnectionsPerHost); ClientBuilder<T> setTotalMaxConnections(final int maxConnections); ClientBuilder<T> setResponseMaxSize(final long responseMaxSize); ClientBuilder<T> setRetries(final int retries); ClientBuilder<T> setConnectionTimeout(final int timeout); ClientBuilder<T> setRequestTimeout(final int timeout); ClientBuilder<T> setReadTimeout(final int timeout); ClientBuilder<T> setTargetProvider(final TargetProvider targetProvider); ClientBuilder<T> bindEndpoint(final String methodName, final String path, final ServiceFilter... filters); ClientBuilder<T> bindEndpoint(final String methodName, final HttpRequestMethodType requestMethodType); ClientBuilder<T> bindEndpoint(final String methodName, final HttpRequestMethodType requestMethodType,
                                       final ServiceFilter... filters); ClientBuilder<T> bindEndpoint(final String methodName, final ServiceFilter... filters); ClientBuilder<T> setDispatchStrategy(final DispatchStrategy dispatchStrategy); ClientBuilder<T> bindEndpoint(final String methodName, final HttpRequestMethodType requestMethodType,
                                       final String path, final ServiceFilter... filters); T build(); }
ClientBuilder { public T build() { if (!type.isInterface()) { throw new IllegalArgumentException("Type " + type.getCanonicalName() + " must be an interface as client uses JDK proxy"); } final ClassLoader loader = ClientBuilder.class.getClassLoader(); final HttpClient httpClient = httpClientBuilder.build(); final Map<Method, AbstractClientEndpoint> endpoints = extractEndpointsFromType(httpClient); final HttpInvocationHandler handler = new HttpInvocationHandler(targetProvider, httpClient, endpoints, dispatchStrategy); @SuppressWarnings("unchecked") final T proxy = (T) Proxy.newProxyInstance(loader, new Class[]{type, Closeable.class}, handler); return proxy; } ClientBuilder(final Class<T> type); ClientBuilder<T> addFilter(final ServiceFilter filter); ClientBuilder<T> setJsonModules(final Module... modules); ClientBuilder<T> setProtocol(final ContentType clientType); ClientBuilder<T> followRedirect(final boolean followRedirect); ClientBuilder<T> setMetricFactory(final MetricFactory metricFactory); ClientBuilder<T> setCompression(final boolean compression); ClientBuilder<T> setMaxConnectionsPerHost(final int maxConnectionsPerHost); ClientBuilder<T> setTotalMaxConnections(final int maxConnections); ClientBuilder<T> setResponseMaxSize(final long responseMaxSize); ClientBuilder<T> setRetries(final int retries); ClientBuilder<T> setConnectionTimeout(final int timeout); ClientBuilder<T> setRequestTimeout(final int timeout); ClientBuilder<T> setReadTimeout(final int timeout); ClientBuilder<T> setTargetProvider(final TargetProvider targetProvider); ClientBuilder<T> bindEndpoint(final String methodName, final String path, final ServiceFilter... filters); ClientBuilder<T> bindEndpoint(final String methodName, final HttpRequestMethodType requestMethodType); ClientBuilder<T> bindEndpoint(final String methodName, final HttpRequestMethodType requestMethodType,
                                       final ServiceFilter... filters); ClientBuilder<T> bindEndpoint(final String methodName, final ServiceFilter... filters); ClientBuilder<T> setDispatchStrategy(final DispatchStrategy dispatchStrategy); ClientBuilder<T> bindEndpoint(final String methodName, final HttpRequestMethodType requestMethodType,
                                       final String path, final ServiceFilter... filters); T build();  }