Use tapestry-delegate to improve the running efficiency of tapestry

Source: Internet
Author: User

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 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 "" 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.