Chapter 5 Aspect-oriented programming (AOP) II

Source: Internet
Author: User

The last time I briefly introduced several common functions of AOP in chapter 5, I would like to illustrate its powerful functions through actual examples, these examples are actually used in the project, rather than some examples of no use value. I will introduce where it is used in a complete system, including log processing, Exception Processing, transaction processing, identity authentication (permission control), and cache mechanism (level-2 cache ). This should be the best of AOP. I will write a very small demo to include all these functions.

Whether your system can fully play the role of AOP must ensure that your system has a good architecture design and good code programming, we know that APIs and proxies are promoted in spring. if there is no good design architecture and good code programming. Performance is also affected even when AOP is used. We know that any part of the system is important. If a link fails, the overall performance may be affected. This is the most difficult thing we can do. Before doing so, you must have a perfect solution.

Next, I will write a simple system, a simple description of the system, and log on to the system with different identities to perform different operations. Common users can browse information, while general users can add information, advanced users can perform all operations. Is a simple background management of the news publishing system. I mainly integrate several common functions of AOP into the system. The functions of this system are relatively simple, but the business needs can still use the features mentioned above.

Let's briefly introduce the process.

Common users can only view the latest news after logging on. You cannot perform any other operations. At the same time, you must use logs to record the most recent login users.

Normal users, that is, editing, can add news and modify news when they enter. However, news cannot be deleted, and the system must record their operations.

Finally, the Administrator (Advanced User) can delete a series of operations. It also records information. You must add transaction processing during deletion to prevent accidental data loss.

Before they log on, they must perform authentication. Cache policies must be applied to pages with frequent access. In this way, the system can run better. These simple operations have used all the functions we mentioned. The following describes how to integrate them into your business and how to use code to write them. At the same time, we should also consider performance issues.

Now I will build the project first. Implemented Using STRUTS + spring + hiberante technology. MySQL. log4j is used for logging in the database, acegi is used for the security framework, and ehcache is used for caching. transactions are built with spring.

After analyzing our requirements, let's look at how to build the technical framework. For example.

The following is how to build the project directory. For example. I will explain this part in detail later.

This is written first today.

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.