Java Web front-end to background common framework introduction __ Frame

Source: Internet
Author: User
Tags aop error handling memcached message queue redis rabbitmq redis server

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, using the idea of the MVC architecture pattern to decouple the WEB layer, which is based on the request-response model, The purpose of the framework is to help us simplify development, and Spring Web MVC simplifies our daily web development.

The model encapsulates the data of the application and the Pojo that they typically compose.

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

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

The spring Web model-View-Controller (MVC) framework is designed around Dispatcherservlet that handle all HTTP requests and responses.

Spring WEB MVC processes The process of a request

The following steps are implemented:

1, the first user to send the request ———— > front-end controller, the front-end controller based on the request information (such as URL) to decide which page controller to process and entrust the request to it, that is, the control of the previous controller logic part of the 1, 2 steps in Figure 2-1;

2, the page controller receives the request, carries on the function processing, first needs to collect and bind the request parameter to an object, this object is called the Command object in the 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-end controller to reclaim control, and then according to the return of the logical view name, select the appropriate view for rendering, and the model data passed to the view rendering, in Figure 2-1 steps 6, 7;

4. The front-end controller will regain control again, return the response to the user, step 8 in Figure 2-1, and end this whole.

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

The 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 building dependencies between those objects. Applications are assembled by the IOC container without the need to directly new objects in the code. Beanfactory is the actual representative of the IOC container in spring.

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

To put it simply, it encapsulates the logic or responsibility that is not related to the business, but is invoked by the business module to reduce the duplication of the system, reduce the coupling between modules, and facilitate future operability and maintainability. AOP represents 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 Fault Handling
Lazy Loading Lazy load
Debugging debugging
Logging, tracing, profiling and monitoring record tracking optimization calibration
Performance Optimization Performance optimization
Persistence persistence
Resource Pooling resource Pool
Synchronization Sync
Transactions Affairs

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 result sets. MyBatis uses simple XML or annotations for configuration and raw mapping, mapping interfaces and Java POJOs (Plain old Java Objects, normal Java objects) to records in the database.

Overall process:

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

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

(3) Processing operation request Trigger condition: API Interface Layer delivery request come over
Incoming arguments: 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, get the final SQL to execute and execute the incoming parameter.

(C) obtain a database connection, execute the database according to the resulting final SQL statement and execute the incoming parameters, and obtain the execution results.

(D) Converting the resulting execution results from the result mapping configuration in the Mappedstatement object and obtaining the final processing results.

(E) Release of connection resources.

(4) Return the processing result to return the final processing result.

One of the most powerful features of MyBatis is its dynamic statement function. If you've had previous experiences with JDBC or similar frameworks, you'll understand how painful it is to connect SQL statement conditions together, and make sure you don't forget the spaces or omit a comma after the columns column. Dynamic statements can completely solve the pain.

Four, 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 requirements, in fact, is not needed, only in the distributed time, only Dubbo such a distributed service framework requirements, and essentially a service call Dongdong, plainly is a remote service invocation of the distributed framework.

1, transparent remote method calls, just like the local method calls the remote method, just a simple configuration, no API intrusion.

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

3, the service automatic registration and discovery, no longer need to write dead service provider address, registry based on the interface name Query service provider's IP address, and can 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 time reconciliation call times for statistical services.
Container: Service Run container.

Five, Maven

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

MAVEN is a project that manages and builds automation tools that more and more developers use to manage jar packs in their projects. But for our programmers, our greatest concern is its project-building capabilities.

VI. RABBITMQ

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

Message Queuing is generally in the project, the need for some immediate return and time-consuming operations extracted, asynchronous processing, and this method of asynchronous processing greatly reduce the server's request response time, thereby increasing the system throughput.

RABBITMQ is a highly concurrent and highly reliable AMQP Message Queuing server implemented in Erlang.

Erlang is a dynamic type of functional programming language. corresponding to Erlang, each actor corresponds to a Erlang process, which communicates between processes through message passing. Compared to shared memory, the direct benefit of communication between processes through messaging is the elimination of direct lock overhead (regardless of the lock application in the underlying implementation of Erlang virtual machines).

AMQP (Advanced message Queue Protocol) defines a messaging system specification. This specification describes how each subsystem interacts with the 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, with fast, lean and so on, is the default Cacheprovider in Hibernate. Ehcache is a widely used open source Java distributed cache. Mainly for general-purpose caching, Java EE and lightweight containers. It features memory and disk storage, cache loaders, cache extensions, cache exception handlers, a gzip cache servlet filter, support for rest and soap APIs, and more.

Advantages:
1, fast
2, simple
3. Multiple Caching strategies
4, cache data has two levels: memory and disk, so no need to worry about capacity issues
5. Cached data will be written to disk during virtual machine reboot
6, can be through RMI, pluggable APIs and other ways to carry out the distributed cache
7. A listening interface with cache and cache manager
8. Support for multiple cache manager instances and multiple cache regions for an instance
9, provide Hibernate cache implementation

Disadvantages:
1, the use of disk cache is very much to occupy disk space: This is because the diskcache algorithm is simple, the algorithm is simple also cause cache efficiency is very high. It simply appends the storage to the element. So it's very fast to search for elements. If you use DiskCache, in a very frequent application, the disk will soon be full.

2, can not guarantee the security of data: When suddenly killed Java, may produce conflicts, Ehcache solution is if the file conflict, then rebuild the cache. This can be bad for cache data when it needs to be saved. Of course, the cache is simply accelerated, not guaranteed data security. If you want to keep your data secure, you can use the Bekeley DB Java Edition version. This is an embedded database. To ensure storage security and space utilization.

Nine, Redis

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

Redis is a key-value storage system. Like memcached, it supports a relatively larger number of stored value types, including string (string), list (linked list), set (set), Zset (sorted set– ordered set), and hash (hash type). These data types support Push/pop, Add/remove and intersection-set and differential sets and richer operations, and these operations are atomic. On this basis, Redis supports a variety of different ways of ordering. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to the disk or writes the modification operation to the appended record file, and on this basis, it realizes the Master-slave (master-slave) synchronization.

The Redis database is fully in memory and uses the disk for persistence only. Redis has a richer set of data types than many key-value data stores. Redis can copy data to any number of servers.

1.2, Redis Advantages:

(1) Exceptionally fast: the speed of Redis is very fast, can perform about 110,000 sets per second, about 81000 + records per second.

(2) Support 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 problems can be handled better by its data type.

(3) The operation is atomic: All Redis operations are atomic, which ensures that if two clients simultaneously access the Redis server, the updated value will be obtained.

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

1.3, Redis Disadvantage:
(1) Single thread
(2) Memory consumption

10, Shiro

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

The Apache Shiro is a Java security framework 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, verify that an authenticated user has a certain permission, that is, to determine whether the user can do things, such as: Verify that a user has a role. or fine-grained to verify that a user has a permission on a resource;

(3) Session management, that is, the user login is a session, before exiting, all of its information in the session, the session can be a common javase environment, can also be like the web environment;

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

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

(6) Shiro supports concurrent verification of multi-threaded applications, such as opening another thread in one thread, which automatically propagates the past;

(7) Provide test support;

(8) Allow a user to pretend to be visited by another user (if they allow);

(9) Remember me, this is a very common function, that is, once logged in, the next time you do not have to log in.

Text descriptions may not allow apes to fully understand the meaning of specific functions. Here we take the login verification as an example, to the ape friends to introduce the use of Shiro. As for other function points, ape friends use the time to delve into its usage is not too late.

11. Design mode

This is not a framework, can be ignored, but the blogger believes that 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:

Open and close principle: the opening and closing principle is said to the expansion of openness, to modify the closure. When the program needs to be expanded, you cannot modify the original code.

Programming for interfaces, true to interface programming, relies on abstraction rather than on concrete.

Try to use compositing/aggregation instead of inheritance.

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

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

Richter Substitution principle: (1) The ability of a subclass must be greater than or equal to the parent class, that is, the method that the parent class can use, and subclasses can use it. (2) The return value is the same reason. Assuming that a parent class method returns a list, the subclass returns a ArrayList, which of course can be. If the parent class method returns a ArrayList, the subclass returns a list and it doesn't make sense. The ability of a subclass to return a value is smaller than the parent class. (3) There is also the case of throwing exceptions. Any subclass method can declare a subclass that throws a parent class method declaration exception. The
cannot declare an exception that throws a parent class without a declaration.

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.