mirror of https://github.com/apache/jclouds.git
openstack-nova: Adding support for @WrapWith on methods
This commit is contained in:
parent
95399121bd
commit
42b8071682
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.rest.annotations;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
|
@ -31,7 +32,7 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Target(PARAMETER)
|
||||
@Target( { METHOD, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface WrapWith {
|
||||
|
||||
|
|
|
@ -20,11 +20,15 @@ package org.jclouds.rest.binders;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.MapBinder;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
|
@ -33,7 +37,7 @@ import com.google.inject.assistedinject.Assisted;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BindToJsonPayloadWrappedWith implements Binder {
|
||||
public class BindToJsonPayloadWrappedWith implements MapBinder {
|
||||
|
||||
public static interface Factory {
|
||||
BindToJsonPayloadWrappedWith create(String envelope);
|
||||
|
@ -53,4 +57,8 @@ public class BindToJsonPayloadWrappedWith implements Binder {
|
|||
return jsonBinder.bindToRequest(request, (Object) ImmutableMap.of(envelope, checkNotNull(payload, "payload")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
|
||||
return this.bindToRequest(request, (Object) postParams);
|
||||
}
|
||||
}
|
|
@ -916,6 +916,9 @@ public class RestAnnotationProcessor<T> {
|
|||
return injector.getInstance(method.getAnnotation(MapBinder.class).value());
|
||||
} else if (method.isAnnotationPresent(org.jclouds.rest.annotations.Payload.class)) {
|
||||
return injector.getInstance(BindMapToStringPayload.class);
|
||||
} else if (method.isAnnotationPresent(WrapWith.class)) {
|
||||
return injector.getInstance(BindToJsonPayloadWrappedWith.Factory.class).create(
|
||||
method.getAnnotation(WrapWith.class).value());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue