mirror of https://github.com/apache/jclouds.git
Issue 76: fixed varags annotation searching for subclasses/implementors
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1653 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
2b0eb5025a
commit
3d5d31f037
|
@ -77,7 +77,11 @@ public class HttpRequest extends HttpMessage implements Request<URI> {
|
||||||
sb.append("{endPoint='").append(endpoint).append('\'');
|
sb.append("{endPoint='").append(endpoint).append('\'');
|
||||||
sb.append(", method='").append(method).append('\'');
|
sb.append(", method='").append(method).append('\'');
|
||||||
sb.append(", headers=").append(headers);
|
sb.append(", headers=").append(headers);
|
||||||
sb.append(", entity set=").append(entity != null);
|
if (entity != null && entity instanceof String) {
|
||||||
|
sb.append(", entity=").append(entity);
|
||||||
|
} else {
|
||||||
|
sb.append(", entity set=").append(entity != null);
|
||||||
|
}
|
||||||
sb.append('}');
|
sb.append('}');
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,7 +325,23 @@ public class JaxrsAnnotationProcessor {
|
||||||
|
|
||||||
public PostEntityBinder getPostEntityBinderOrNull(Method method, Object[] args) {
|
public PostEntityBinder getPostEntityBinderOrNull(Method method, Object[] args) {
|
||||||
for (Object arg : args) {
|
for (Object arg : args) {
|
||||||
if (arg instanceof PostEntityBinder) {
|
if (arg instanceof Object[]) {
|
||||||
|
Object[] postBinders = (Object[]) arg;
|
||||||
|
if (postBinders.length == 0) {
|
||||||
|
} else if (postBinders.length == 1) {
|
||||||
|
if (postBinders[0] instanceof PostEntityBinder) {
|
||||||
|
PostEntityBinder binder = (PostEntityBinder) postBinders[0];
|
||||||
|
injector.injectMembers(binder);
|
||||||
|
return binder;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (postBinders[0] instanceof PostEntityBinder) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"we currently do not support multiple varargs postBinders in: "
|
||||||
|
+ method.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (arg instanceof PostEntityBinder) {
|
||||||
PostEntityBinder binder = (PostEntityBinder) arg;
|
PostEntityBinder binder = (PostEntityBinder) arg;
|
||||||
injector.injectMembers(binder);
|
injector.injectMembers(binder);
|
||||||
return binder;
|
return binder;
|
||||||
|
@ -456,16 +472,21 @@ public class JaxrsAnnotationProcessor {
|
||||||
private HttpRequestOptions findOptionsIn(Method method, Object[] args) {
|
private HttpRequestOptions findOptionsIn(Method method, Object[] args) {
|
||||||
for (int index : methodToIndexesOfOptions.get(method)) {
|
for (int index : methodToIndexesOfOptions.get(method)) {
|
||||||
if (args.length >= index + 1) {// accomodate varargs
|
if (args.length >= index + 1) {// accomodate varargs
|
||||||
if (optionsVarArgsClass.isAssignableFrom(args[index].getClass())) {
|
if (args[index] instanceof Object[]) {
|
||||||
HttpRequestOptions[] options = (HttpRequestOptions[]) args[index];
|
Object[] options = (Object[]) args[index];
|
||||||
if (options.length == 0) {
|
if (options.length == 0) {
|
||||||
return null;
|
|
||||||
} else if (options.length == 1) {
|
} else if (options.length == 1) {
|
||||||
return options[0];
|
if (options[0] instanceof HttpRequestOptions) {
|
||||||
|
HttpRequestOptions binder = (HttpRequestOptions) options[0];
|
||||||
|
injector.injectMembers(binder);
|
||||||
|
return binder;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(
|
if (options[0] instanceof HttpRequestOptions) {
|
||||||
"we currently do not support multiple varargs options in: "
|
throw new IllegalArgumentException(
|
||||||
+ method.getName());
|
"we currently do not support multiple varargs options in: "
|
||||||
|
+ method.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return (HttpRequestOptions) args[index];
|
return (HttpRequestOptions) args[index];
|
||||||
|
|
Loading…
Reference in New Issue