|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DuckPrxy
An interface for a duck typing proxy creator service.
A duck proxy delegates to its delegate by using the looking for a method, using the first strategy that yields a result:
DuckMethod
). If such a subdelegate is found,
the invocation will be forwarded to the subdelegate.
Once a method is found, the arguments are constructed to call this method.
Let arg_1,...,arg_n
be the arguments for the call and
par_1,...,par_k
the parameters of the duck delegate method.
A par_i
is filled with a value according to its DuckArg definition
if such a definition exists. Parameter with no such definition are filled
up with the arguments of the call. I.e., if k
parameters
par_j
with j < i
and par_j
duck arg definition
exists, that par_i
is filled with arg_(i-k)
.
To give a more practical example: If we want to map call
foo(String s, String t)
to a call bar("foo", s, t)
, we can
do this with the following definition:
@DuckMethod("foo")
public void bar(
@DuckArg(DuckArgType.NAME) String name,
String s, String t) {
...}
Method Summary | ||
---|---|---|
|
makeProxy(java.lang.Class<T> mainInterface,
java.lang.Object delegate,
java.lang.Class<?>... interfaces)
Creates an object that implements the defined interfaces delegating to a given object, mainly using duck typing. |
Method Detail |
---|
<T> T makeProxy(java.lang.Class<T> mainInterface, java.lang.Object delegate, java.lang.Class<?>... interfaces)
T
- The class of the main interface.mainInterface
- The main interface that the resulting object
shall implement.delegate
- The object to delegate the calls to.interfaces
- Secondary interfaces to implement.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |