Introduction to spring (AOP, IOC, bean scope, etc.)

Source: Internet
Author: User

Spring is an open-source framework created to solve the complexity of enterprise application development. One of the main advantages of the Framework is its layered architecture, which allows you to choose which component to use and provides an integrated framework for J2EE application development.

 

Personal Understanding: the Sping container is used as a bean factory to manage beans through configuration files (all components in the application are treated as beans)

 

Composition: beanfactory --------> applicationcontext (sub-interface) --------> classpathxmlapplicationcontext (Implementation class )········

 

The basic concept of IOC control inversion mode (also called dependency intervention) is to inject values to classes through the configuration file without the need for new objects. Benefit: low coupling. When the class changes, you do not need to modify it in the class. You only need to modify it in the configuration file.

For example:

 

  1. <Bean id = "bean2" class = "Yeah. Developers. Spring. bean2">
  2. <Property name = "bean3" ref = "bean3"> </property>
  3. </Bean>
  4. <Bean id = "bean3" class = "Yeah. Developers. Spring. bean3">

 

AOP for Aspect-Oriented Programming: defines a face-cutting class. There are many methods in it. Each method has its own starting point (where to use it) and enhancement processing (front and back)

For example:

Face Cutting

@ Aspectpublic class logprint {@ pointcut ("execution (* CN. itcast. service .. *. *(..)) ") // declare a start point private void anymethod (){}
@ Before ("anymethod () & ARGs (username)") // defines the pre-notification public void doaccesscheck (string username) {}@ afterreturning (pointcut = "anymethod ()", returning = "revalue") // defines the post-Notification public void doreturncheck (string revalue) {}@ afterthrowing (pointcut = "anymethod ()", throwing = "ex ") // define the exception notification public void doexceptionaction (exception ex) {}@ after ("anymethod ()") // define the final notification public void doreleaseaction () {}@ around ("anymethod ()") // public object dobasicprofiling (proceedingjoinpoint pjp) throws throwable {return pjp. proceed ();}}

 

 

 

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.