Inspired by the tapestry extension "Tapestry-prop", I suddenly wrote an extension called "tapestry-delegate. This extension function is similar to the built-in "listener:" binding in Tapestry. It provides another method to define the listener method. Here I define it as a proxy function. On the one hand, it is because Tapestry uses the name of the listener function. On the other hand, it is more appropriate to call it a proxy function.
Now, I have created a project on java.net named "tapestry-delegate" and emailed Howard Lewis Ship, author of Tapestry. I feel that he is easy to communicate and enthusiastic, and his practice has been affirmed by him. You can download the source code and jarfile through the "https://tapestry-delegate.dev.java.net/##" project.
"Tapestry-delegate" provides a binding rule called "delegate:", which improves the binding efficiency in two aspects. First, it uses the Code Generation Technology to generate a proxy class and does not need to use the reflection mechanism when calling the actual method. Secondly, it can use precise function definition methods, such as "delegate: method ()" and "delegate: method (String, int, this avoids the overhead of the search function. In addition, even if there is only one function corresponding to the given function name in the form of "delegate: method", the function will be called directly without executing any search code. For more information, see the implementation details below.
Main object
DelegateBinding: implements the IBinding interface and IActionListener interface of Tapestry. The parameter obtained in the component is actually the bound object. It is used to call the actually bound function.
Delegatemehtop: it is a proxy method used to call the actual function. In actual operation, an instance is generated by using the code generation technology. Each instance corresponds to a function that needs to be called.
Delegatemethodinvoker: The interface defines the method for calling delegatemehtodd. Different invocation policies can be implemented through different implementations. When you can determine the function call form, the direct call form will be faster than the search call form.
Absolutedelegatemethodinvoker: An Implementation of delegatemethodinvoker. Use the same policy as "listener:" to search for appropriate proxy methods.
Cycledelegateinvoker: An Implementation of delegatemethodinvoker, which calls a function in the form of "method (irequestcycle.
Cycleparamdelegateinvoker: An Implementation of delegatemethodinvoker. It calls a function in the form of "method (irequestcycle, parameters.
Emptyparamdelegateinvoker: An Implementation of delegatemethodinvoker, which calls a function in the form of "method.
Paramdelegateinvoker: An Implementation of delegatemethodinvoker. It calls a function in the form of "method (parameters.
Main factory methods
The main objects mentioned above and their relationships are generated and implemented through these three different factory methods. Delegateclassfactory is mainly responsible for generating the proxy class of object functions. Delegatemethodinvokersource is mainly responsible for generating and caching the delegatemethodinvoker object for packaging proxy functions. Delegatebindingfacotry is mainly used by the tapestry framework. It is called at the production binding time and an ibingding instance is returned.