Spring Framework Summary (i)

Source: Internet
Author: User

Noun Explanation:

A framework is a collection of components.
For example: Struts, Spring, hibernate are the components of a collection

A component is a common feature package packaged into a tool class.

Common components:
Dom4j/xpath, Dbutils, C3P0, Beanutils, log4j

A framework is a collection of components.
For example: Struts, Spring, hibernate are the components of a collection

generics : type checking, fewer types of conversions, self-defining a class that can be any type, jdk1.5

Shortcut keys to use
Ctril + Shift + R to view the classes in the current project
Ctril + Shift + F View the class in the source code

The Web development approach before spring is the MVC pattern

It's Jsp+servlet+javabean.

This creates a problem that, if there is a lot of demand, you need to make multiple copies of the servlet, which can result in code redundancy and, at the same time, create a workload increase for developers.

According to this model, it is

Dao

1       Public class Userdao {23         Public void Saveuser () {4           System.out.println ("Save successful **********************"); 5 }67 }

Service

1         Public class UserService {2         Private New Userdao; 3 4          Public void Save () {5            dao.saveuser (); 6           }78 }

Action

 Public class useraction {    privatenew  userservice;      Public String Execute () {        us.save ();         return NULL ;    }}

This requires a lot of new DAO and service every time, and we know that each new object consumes memory, which slows the overall speed of the project.

At the same time, the dependency between classes and classes is much enhanced, and service must have dao,action must have service

The term above is:

(1) Number of objects action must be multiple, service and DAO One, creation time change
(2) The dependency of the object is closely related
Action Dependent Service
Service Dependent DAO

And spring solves both of these problems.

Spring Features

Noun Explanation:
Component/Frame Design
Intrusive Design
A framework is used, which has an effect on local classes and implements or inherits the class itself.
For example: Struts framework, must inherit actionsupport to implement function

Non-intrusive design (better than intrusive)
The framework is used and has no effect on its own class structure.
For example: Hibernate frame, just mapping, does not affect other
Spring Framework, spring promotes minimal intrusion

Control reversal: Replace the original new object with a setter method

Case Description:

Control inversion:
In the original action, a new service
public class action{
Daoservice s = new Daoserviceimp ();
}

When controlling inversion, call the external service
Public class action extends actionsupport{
Private Daoservice S;

Private Daoservice Setdaoservice (Daoservice Daos) {
This.s=daos;
}
}

The role of control inversion: the creation of objects to the external container processing container is useraction userservice

Dependency Injection : Dealing with an object's associated relationship

Case:

Public class action extends actionsupport{
Private Daoservice S;

Private Daoservice Setdaoservice (Daoservice Daos) {
This.s=daos;
}

}

Control inversion: Handling object creation problems, dependency injection, handling object relationships
Existing control inversion, only dependency injection
Dependency Injection implementation (add a set method, this one):
Dependency Injection via Set method


AOP-oriented tangent programming
Classes formed by a lot of repeating code
Example: Things/Logs/permissions


Spring main features and development steps
A framework to address object creation and dependency relationships
And can be used with other frameworks.
A framework for the integration (bonding) role
Spring and struts Spring and hibernate

Spring provides a one-stop solution

(1) Springcore Spring's core functionality (other features need to depend on it): IOC container: Resolving object creation and dependencies

Note: Control reversal belongs to IOC

(2) Springweb Spring support for Web modules
A, you can integrate with struts, so that struts action is created to spring
B, Springmvc mode, can omit struts, use SPRINGMVC instead of struts

(3) Springdao Spring Support for JDBC operations [jdbctemplate Template Tool class]
(4) Springorm Spring's support for ORM
A, can be integrated with Hibernate, [session]
b, you can also use spring's package for hibernate operations
(5) SPRINGAOP Slicing programming
(6) Springee Spring support for other Java EE modules

Spring Framework Summary (i)

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.