@Documented @Retention(value=RUNTIME) @Target(value=PARAMETER) public @interface Pipe
Unfortunately, before Java 8, the Java Class Library does not define any interface type which takes a single
Object type and returns another Object type. For this reason, a
Pipe.Binder needs to be installed explicitly
and registered on a MethodDelegation. The installed type is allowed to be an
interface without any super types that declares a single method which maps an Object type to
a another Object type as a result value. It is however not prohibited to use generics in the
process. The following example demonstrates how the @Pipe annotation can be installed on a user type.
As a preparation, one needs to define a type for which the @Pipe implements the forwarding behavior:
interface Forwarder<T, S> {
T forwardTo(S s);
}
Based on this type, one can now implement an interceptor:
class Interceptor {
private final Foo foo;
public Interceptor(Foo foo) {
this.foo = foo;
}
public String intercept(@Pipe Forwarder<String, Foo> forwarder) {
return forwarder.forwardTo(foo);
}
}
Using both of these types, one can now install the
Pipe.Binder and register it on a
MethodDelegation:
MethodDelegation .to(new Interceptor(new Foo())) .appendParameterBinder(Pipe.Binder.install(ForwardingType.class))
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
serializableProxy
Determines if the generated proxy should be
Serializable. |
public abstract boolean serializableProxy
Serializable.true if the generated proxy should be Serializable.Copyright © 2014–2015. All rights reserved.