Permalink
Browse files

Add a new WebProxyConfig file

  • Loading branch information...
1 parent 9097ccb commit 2d332dfa10797b991f4745101127dd09c91b44f0 @jfarcand jfarcand committed Jun 15, 2011
@@ -109,80 +109,23 @@
* @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());
}
/**
* 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 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 {
@@ -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;

0 comments on commit 2d332df

Please sign in to comment.