Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a new WebProxyConfig file

  • Loading branch information...
commit 2d332dfa10797b991f4745101127dd09c91b44f0 1 parent 9097ccb
@jfarcand jfarcand authored
View
65 restsimple-client/src/main/java/org/sonatype/restsimple/client/WebProxy.java
@@ -109,7 +109,7 @@
* @return an instance of T
*/
public static final <T> T createProxy(Class<T> clazz, URI uri) {
- return createProxy(clazz, uri, Collections.<String, String>emptyMap());
+ return createProxy(clazz, uri, new WebProxyConfig.Builder().build());
}
/**
@@ -117,72 +117,15 @@
*
* @param clazz A class an interface annotated with RestSimple annotations.
* @param uri the based uri.
+ * @param config a {@link WebProxyConfig}
* @param <T>
* @return an instance of T
*/
public static final <T> T createProxy(Class<T> clazz,
URI uri,
- Map<String,String> bindings) {
-
- return createProxy(new ObjectMapper(), clazz, uri, bindings);
- }
-
- /**
- * Generate a HTTP client proxy based on an interface annotated with RestSimple annotations.
- *
- * @param clazz A class an interface annotated with RestSimple annotations.
- * @param uri the based uri.
- * @param <T>
- * @return an instance of T
- */
- public static final <T> T createProxy(Class<T> clazz,
- URI uri,
- Map<String,String> bindings,
- Map<String,String> properties) {
-
- return createProxy(new ObjectMapper(), clazz, uri, bindings, properties);
- }
- /**
- * Generate a HTTP client proxy based on an interface annotated with RestSimple annotations.
- *
- * @param objectMapper The Jackson's {@link ObjectMapper}
- * @param clazz A class an interface annotated with RestSimple annotations.
- * @param uri the based uri.
- * @param <T>
- * @return an instance of T
- */
- public static final <T> T createProxy(ObjectMapper objectMapper,
- Class<T> clazz,
- URI uri) {
-
- return createProxy(objectMapper, clazz, uri, Collections.<String, String>emptyMap());
-
- }
-
- /**
- * Generate a HTTP client proxy based on an interface annotated with RestSimple annotations.
- *
- * @param objectMapper The Jackson's {@link ObjectMapper}
- * @param clazz A class an interface annotated with RestSimple annotations.
- * @param uri the based uri.
- * @param <T>
- * @return an instance of T
- */
- public static final <T> T createProxy(ObjectMapper objectMapper,
- Class<T> clazz,
- URI uri,
- Map<String,String> bindings) {
-
- return createProxy(objectMapper, clazz, uri, bindings, Collections.<String, String>emptyMap());
- }
-
- public static final <T> T createProxy(ObjectMapper objectMapper,
- Class<T> clazz, URI uri,
- Map<String,String> bindings,
- Map<String,String> properties ) {
-
+ WebProxyConfig config) {
return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz},
- new WebProxyHandler(uri, createServiceDefinition(clazz), clazz, objectMapper, bindings, properties));
+ new WebProxyHandler(uri, createServiceDefinition(clazz), clazz, config.getObjectMapper(), config.getBindings(), config.getProperties()));
}
private static class WebProxyHandler implements InvocationHandler {
View
2  restsimple-client/src/main/java/org/sonatype/restsimple/client/WebProxyConfig.java
@@ -60,7 +60,7 @@ public ObjectMapper getObjectMapper() {
private Map<String,String> bindings = Collections.<String, String>emptyMap();
private Map<String,String> properties = Collections.<String, String>emptyMap();
- private ObjectMapper objectMapper = null;
+ private ObjectMapper objectMapper = new ObjectMapper();
public Map<String, String> getBindings() {
return bindings;
Please sign in to comment.
Something went wrong with that request. Please try again.