Introduction of Aspectnet function (II.)

Source: Internet
Author: User

Aspectnet is an aspect builder based on the. Net framework, which simultaneously enables static weaving and dynamic weaving, is a bobmazelin personal research project, and is still in the development phase, the introduction of AOP concepts please refer to: Www.aspectJ.org and IBM's project.

In the last article I introduced the basic structure of aspectnet, from this beginning I will specifically introduce the aspectnet in the static knitting function. This time I'll introduce you to call and execution two pointcut.

In the last chapter I mentioned that pointcut captures the code points that need to be woven, there are many ways to capture this code point in Aspectnet, and call and execution are two of the more basic.

1.call Pointcut: Captures code points that invoke certain methods;

2.execution Pointcut: Captures code points that perform certain methods.

They're very similar, and I'll show you a little example below to illustrate the difference.

Before giving the examples, let me explain their mode of approach:

Modifier returns the value type [method type.] Method name (List of parameter types)

1. Modifiers are public, protected,private,sealed,static and so on, they support! and operation (for example:!private static);

2. The return value type is the return value type of the method, which supports void,*, &&, | |, the!,+ operator. Void is not a return value; * is a wildcard, a separate * represents any type, and can be partially matched, for example: system.*,customer*. Order* and so on; && you can combine different types; + is a subclass operator, representing all of its subclasses, such as: system.object+, representing all classes;

3. The method type describes the method declaration type, which is similar to the pattern of the return value type; Note: it cannot be ignored in aspectnet;

4. The method name only supports the * and the new operator, and new represents the constructor of the class;

5. Parameter type list: Through, to split the parameter type, it supports ... An operator represents any number of arguments, such as: System.int,.., string describes the type of the first and last parameter of the method, without limiting the number and type of arguments in the middle.

Note: The description of the method pattern on the face of Aspectnet is not comprehensive.

The theory is over, come on, do something practical, since there is no passing stage of the parameters, I chose the simplest log as an example, and then give the example of the business relative complexity when introducing the parameter, this example mainly illustrates two problems, first: Capturing the subclass code point by +; second, the difference between call and execution .

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: info-contact@alibabacloud.com 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.