Java Web front-end to background common framework introduction

Source: Internet
Author: User
Tags aop message queue java web rabbitmq

First, SPRINGMVC

http://blog.csdn.net/evankaka/article/details/45501811

Spring Web MVC is a lightweight web framework that implements the request-driven type of the Web MVC design pattern based on Java, that is, the idea of using the MVC architecture pattern, decoupling the WEB layer from responsibility, and based on the request-driven approach is to use the request-response model, The purpose of the framework is to help us simplify our development, and Spring Web MVC also simplifies our daily web development.

The model encapsulates the data of the application and the Pojo that are typically made up of them.

The view is responsible for rendering the model data and generally the HTML output it generates, which the client's browser can interpret.

The controller is responsible for processing the user's request, establishing the appropriate model, and passing it on to the view rendering.

Spring's web Model-View-Controller (MVC) framework is designed around the dispatcherservlet that handles all HTTP requests and responses.

Process of processing requests by Spring WEB MVC

The following steps are performed:

1, the first user to send the request ———— > Front-end controller, the front controller according to the request information (such as URL) to decide which page controller to process and delegate the request to it, that is, the control logic of the previous controller, figure 2-1, 1, 2 steps;

2, after the page controller receives the request, carries on the function processing, first needs to collect and binds the request parameter to an object, this object calls the Command object in spring Web MVC, validates, and then delegates the command object to the business object for processing ; Returns a modelandview (model data and Logical view name) after processing; 3, 4, 5 steps in Figure 2-1;

3, the front controller retract control, and then according to the return of the logical view name, select the corresponding view to render, and the model data into the view rendering; steps 6, 7 in Figure 2-1;

4, the front controller again regain control, return the response to the user, figure 2-1, step 8;

Second, Spring

http://blog.csdn.net/cainiaowys/article/details/7107925

2.1. IOC container: http://www.cnblogs.com/linjiqin/archive/2013/11/04/3407126.html

An IOC container is a container that has dependency injection capabilities, and the IOC container is responsible for instantiating, locating, configuring objects in the application, and establishing dependencies between those objects. Applications do not need to be directly related to new objects in the code, and the application is assembled by an IOC container. Beanfactory is the actual representative of the IOC container in spring.

2.2, aop:http://blog.csdn.net/moreevan/article/details/11977115

Simply put, it is the logic or responsibility that is not related to the business, but for the business module to call together, to reduce the duplication of code, reduce the coupling between modules, and facilitate future operability and maintainability. AOP stands for a horizontal relationship.

AOP is used to encapsulate crosscutting concerns, which can be used in the following scenarios:

Authentication Permissions
Caching Cache
Context passing content delivery
Error handling Errors handling
Lazy Loading lazily loaded
Debugging Commissioning
Logging, tracing, profiling and monitoring record tracking optimization calibration
Performance Optimization performance Optimization
Persistence Persistence
Resource Pooling resource Pool
Synchronization synchronization
Transactions transactions

Third, Mybatis

http://blog.csdn.net/u013142781/article/details/50388204

MyBatis is an excellent persistence layer framework that supports common SQL queries, stored procedures, and advanced mappings. MyBatis eliminates the manual setting of almost all JDBC code and parameters and the retrieval of the result set. MyBatis uses simple XML or annotations for configuration and raw mapping, mapping interfaces and Java POJOs (Plain old Java Objects, ordinary Java objects) to records in a database.

Overall process:

(1) Load configuration and initialize
Trigger Condition: Load configuration file
The SQL configuration information is loaded into a Mappedstatement object (including the incoming parameter mapping configuration, executed SQL statement, result mapping configuration), which is stored in memory.

(2) Receive call request
Trigger condition: Call the API provided by MyBatis
Incoming parameters: ID for SQL and incoming parameter object
Process: Passes the request to the underlying request processing layer for processing.

(3) Processing operation request trigger conditions: API interface Layer delivery request come over
Incoming parameters: ID for SQL and incoming parameter object

Processing process:

(A) Find the corresponding Mappedstatement object based on the SQL ID.

(B) Parse the Mappedstatement object based on the incoming parameter object to get the final SQL to execute and execute the incoming parameters.

(C) obtain a database connection, based on the resulting SQL statements and execute incoming parameters into the database execution, and get the results of the execution.

(D) Conversion processing of the resulting execution results based on the result mapping configuration in the Mappedstatement object and the resulting processing results.

(E) Release the connection resources.

(4) The return processing result returns the final processing result.

One of the most powerful features of MyBatis is its dynamic statement functionality. If you have experienced using JDBC or similar frameworks before, you will understand how painful it is to connect SQL statement conditions together, make sure you can't forget the spaces or omit a comma after the columns column, and so on. Dynamic statements can completely solve the pain.

Iv. Dubbo

http://blog.csdn.net/u013142781/article/details/50387583

Dubbo is a distributed service framework dedicated to providing high-performance and transparent RPC (Remote Procedure Call Protocol) remote service invocation scenarios, as well as SOA service governance scenarios. Simply put, Dubbo is a service framework, if there is no distributed demand, in fact, it is not needed, only in the distributed time, only Dubbo such a distributed service framework needs, and essentially a service call East, plainly is a remote service invocation of the distributed framework.

1. Transparent remote method calls, just like calling a local method, call a remote method, simply configure, without any API intrusion.

2, soft load balancing and fault-tolerant mechanism, can replace F5 and other hardware load balancer in intranet, reduce cost and reduce single point.

3, service automatic registration and discovery, no longer need to write dead service provider address, registry based on the interface name to query the service provider's IP address, and be able to smooth add or remove service providers.

Node role Description:
Provider: The service provider that exposes the service.
Consumer: Invokes the service consumer of the remote service.
Registry: Registration Center for service Registration and discovery.
Monitor: The monitoring center of the call times of the statistics service and the call time.
Container: The service runs the container.

V. Maven

http://blog.csdn.net/u013142781/article/details/50316383

MAVEN, a project management and build automation tool, is used by a growing number of developers to manage the jar packages in a project. But for our programmers, our greatest concern is its project-building capabilities.

Liu, RabbitMQ

http://blog.csdn.net/u013142781/article/category/6061896

Message Queuing is usually in the project, some time-consuming operations without immediate return extraction, and asynchronous processing, which greatly saves the server's request response time, thus improving the system's throughput.

RABBITMQ is a high-concurrency high-reliability AMQP Message Queuing server implemented with Erlang.

Erlang is a dynamic type of functional programming language. corresponding to Erlang, each actor corresponds to an Erlang process, and the process communicates through message delivery. Compared to shared memory, the direct benefit of interprocess communication through messaging is to eliminate the direct lock overhead (regardless of the lock application in the Erlang virtual machine's underlying implementation).

AMQP (Advanced message Queue Protocol) defines a message system specification. This specification describes how each subsystem interacts with a message in a distributed system.

Seven, log4j

http://blog.csdn.net/u013142781/article/category/6045728

The priority of logging is divided into off, FATAL, ERROR, WARN, INFO, DEBUG, all, or the level you define.

Eight, Ehcache

http://blog.csdn.net/u013142781/article/category/6066337

EhCache is a pure Java in-process caching framework, which is fast and capable, and is the default Cacheprovider in Hibernate. Ehcache is a widely used, open source Java distributed cache. Primarily for general purpose caches, Java EE and lightweight containers. It features memory and disk storage, cache loaders, cache extensions, cache exception handlers, a gzip cache servlet filter, and support for rest and soap APIs.

Advantages:
1. Fast
2. Simple
3. Multiple Cache Policies
4, cache data has two levels: memory and disk, so there is no need to worry about capacity issues
5. Cache data is written to disk during virtual machine restart
6. Distributed cache can be done via RMI, pluggable API, etc.
7. Listening interface with cache and cache manager
8. Support multi-cache manager instance, and multiple cache zones for one instance
9. Provide Hibernate cache implementation

Disadvantages:
1, the use of disk cache when the disk space is very high: this is because the diskcache algorithm is simple, the algorithm is simple also results in the cache is very efficient. It just appends the storage to the element directly. So it's very fast when searching for elements. If you use DiskCache, in very frequent applications, the disk will soon be full.

2, can not guarantee the security of the data: when suddenly kill Java, there may be conflicts, Ehcache solution is if the file conflicts, the cache is rebuilt. This may be detrimental when the cache data needs to be saved. Of course, the cache is simply accelerating, not keeping the data safe. If you want to keep your data stored securely, you can use the Bekeley DB Java Edition version. This is an embedded database. Can ensure storage security and utilization of space.

IX. Redis

http://blog.csdn.net/u013142781/article/category/6067864

Redis is a key-value storage system. Similar to memcached, it supports storing more value types, including string (string), list (linked list), set (set), Zset (sorted set– ordered collection), and hash (hash type). These data types support Push/pop, Add/remove, and intersection-set and difference sets, and richer operations, and these operations are atomic. Based on this, Redis supports sorting in a variety of different ways. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to disk or writes the modified operation to the appended record file, and Master-slave (Master-Slave) synchronization is implemented on this basis.

The Redis database is completely in memory and uses disk for persistence only. Redis has a rich set of data types compared to many key-value data stores. Redis can replicate data to any number of slave servers.

1.2. Redis Advantages:

(1) Unusually fast: Redis is very fast and can perform about 110,000 episodes per second, about 81000 + records per second.

(2) Support for rich data types: Redis support Most developers already know like lists, collections, ordered collections, hash data types. This makes it very easy to solve a wide variety of problems because we know which issues are better than the data types that can be handled through it.

(3) Operations are atomic: All Redis operations are atomic, which ensures that Redis servers accessed by two clients will get the updated values.

(4) Multifunction utility: Redis is a multi-utility tool that can be used in multiple uses such as cache, message, queue (Redis native support publish/subscribe), any transient data, applications such as Web application sessions, Web page hits count etc.

1.3. Redis Cons:
(1) Single thread
(2) Memory consumption

Ten, Shiro

http://blog.csdn.net/u013142781/article/details/50629708

Apache Shiro is a security framework for Java that is designed to simplify authentication and authorization. Shiro can be used in both Javase and Java EE projects. It is mainly used to deal with identity authentication, authorization, enterprise session management and encryption. The specific function points of Shiro are as follows:

(1) Identity authentication/login, verify that the user has the corresponding identity;

(2) Authorization, that is, permission validation, to verify that a authenticated user has a permission, that is, to determine whether a user can do things, common such as: to verify that a user has a role. or fine-grained verification that a user has a certain permission on a resource;

(3) Session management, that is, the user login is a session, before the exit, all its information is in the session, the session can be ordinary javase environment, can also be such as the web environment;

(4) encryption, protection of data security, such as password encryption stored in the database, rather than plaintext storage;

(5) Web support, can be easily integrated into the web environment;
Caching: Cache, such as user login, its user information, the role/permissions do not need to check every time, this can improve efficiency;

(6) Shiro supports the concurrent authentication of multi-threaded applications, that is, to open another thread in one thread, can automatically propagate the past;

(7) Provide testing support;

(8) Allow one user to pretend to be accessed as another user (if they allow);

(9) Remember me, this is a very common feature, that is, once logged in, the next time you come back without logging in.

A literal description may not allow apes to fully understand the meaning of a specific function. Below we take the login verification as an example, to the ape friends to introduce the use of Shiro. As for other functional points, it is not too late for apes to delve into their usage.

Xi. Design Patterns

This is not a frame, can be ignored, but bloggers think the idea of design mode is necessary to understand.

http://blog.csdn.net/u013142781/article/details/50816245
http://blog.csdn.net/u013142781/article/details/50821155
http://blog.csdn.net/u013142781/article/details/50825301

Thought:

Opening and closing principle: open and close principle is to say to the expansion opened, to modify closed. When the program needs to be expanded, it is not possible to modify the original code.

For interface programming, true interface programming relies on abstraction rather than on specifics.

Use compositing/aggregation as much as possible, rather than using inheritance.

An entity should interact with the other entities as little as possible, making the system function modules relatively independent.

Using multiple isolated interfaces is better than using a single interface.

The principle of substitution on the Richter Scale: (1) The subclass's ability must be greater than or equal to the parent class, the method that the parent class can use, and the subclass to use. (2) The return value is the same. Assuming a parent class method returns a list, the subclass returns a ArrayList, which of course can. If the parent class method returns a ArrayList, the subclass returns a list, which does not speak. Here the subclass's ability to return a value is smaller than the parent class. (3) There is also a case of throwing an exception. Any child class method can declare a subclass that throws a parent class method declaration exception.
You cannot declare an exception that throws a parent class that is not declared

Java Web front-end to background common framework introduction

Related Article

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.