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:
adrian.f.cole 2009-07-19 18:39:39 +00:00
parent 2b0eb5025a
commit 3d5d31f037
2 changed files with 34 additions and 9 deletions

View File

@ -77,7 +77,11 @@ public class HttpRequest extends HttpMessage implements Request<URI> {
sb.append("{endPoint='").append(endpoint).append('\'');
sb.append(", method='").append(method).append('\'');
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('}');
return sb.toString();
}

View File

@ -325,7 +325,23 @@ public class JaxrsAnnotationProcessor {
public PostEntityBinder getPostEntityBinderOrNull(Method method, Object[] 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;
injector.injectMembers(binder);
return binder;
@ -456,16 +472,21 @@ public class JaxrsAnnotationProcessor {
private HttpRequestOptions findOptionsIn(Method method, Object[] args) {
for (int index : methodToIndexesOfOptions.get(method)) {
if (args.length >= index + 1) {// accomodate varargs
if (optionsVarArgsClass.isAssignableFrom(args[index].getClass())) {
HttpRequestOptions[] options = (HttpRequestOptions[]) args[index];
if (args[index] instanceof Object[]) {
Object[] options = (Object[]) args[index];
if (options.length == 0) {
return null;
} else if (options.length == 1) {
return options[0];
if (options[0] instanceof HttpRequestOptions) {
HttpRequestOptions binder = (HttpRequestOptions) options[0];
injector.injectMembers(binder);
return binder;
}
} else {
throw new IllegalArgumentException(
"we currently do not support multiple varargs options in: "
+ method.getName());
if (options[0] instanceof HttpRequestOptions) {
throw new IllegalArgumentException(
"we currently do not support multiple varargs options in: "
+ method.getName());
}
}
} else {
return (HttpRequestOptions) args[index];