Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the frameworks commonly used in java

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces what are the commonly used frameworks in java, which have certain reference value. Interested friends can refer to them. I hope that after reading this article, you will gain a lot. Let Xiaobian take you to understand them together.

Top 10 common frameworks:

SpringMVC

II. Spring

III. Mybatis

IV. Dubbo

V. Maven

VI. RabbitMQ

VII. Log4j

VIII. Ehcache

IX. Redis

X. Shiro

Extended reading:

SpringMVC

Spring Web MVC is a Java-based implementation of the Web MVC design pattern of request-driven type of lightweight Web framework, that is, using the MVC architecture pattern of ideas, the web layer for decoupling responsibilities, request-driven based refers to the use of request-response model, the purpose of the framework is to help us simplify development, Spring Web MVC is also to simplify our daily Web development.

A model encapsulates the application's data and the POJOs they would normally make up.

View is responsible for rendering the model data and generally the HTML output it generates that the client browser can interpret.

The Controller is responsible for processing user requests, building the appropriate model, and passing it on to the view render.

Spring's web model-view-controller (MVC) framework is designed around DispatcherServlets that handle all HTTP requests and responses.

Spring Web MVC process request various framework source code http://www.1b23.com/forum.php

The specific implementation steps are as follows:

1. First, the user sends a request---> front-end controller, and the front-end controller decides which page controller to select for processing according to the request information (such as URL) and delegates the request to it, i.e., the control logic part of the previous controller; Steps 1 and 2 in Figure 2-1;

2. After receiving the request, the page controller performs functional processing. First, it needs to collect and bind the request parameters to an object, which is called command object in Spring Web MVC, and verify it, and then delegate the command object to the business object for processing. After processing, it returns a ModelAndView (model data and logical view name). Steps 3, 4 and 5 in Figure 2-1;

3. The front-end controller takes back the control right, and then selects the corresponding view for rendering according to the returned logical view name, and transmits the model data for view rendering; Steps 6 and 7 in Figure 2-1;

4. The front-end controller takes back control again and returns the response to the user, step 8 in Figure 2-1; the whole process ends here.

II. Spring

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

IOC container is a container with dependency injection function. IOC container is responsible for instantiating, locating, configuring objects in application and establishing dependencies among these objects. The application does not need to create new related objects directly in the code; the application is assembled by the IOC container. BeanFactory is the de facto representative of the IOC container in Spring.

2.2、AOP:http://blog.csdn.net/moreevan/article/details/11977115

Simply put, it is to encapsulate logic or responsibilities that are not related to the business but are commonly invoked by business modules, so as to reduce the duplication of code in the system, reduce the coupling degree between modules, and facilitate future operability and maintainability. AOP stands for a horizontal relationship

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

Authentication permissions Caching Context passing Error handling Lazy loading Debugging logging, tracing, profiling and monitoring Record tracing optimization Calibration Performance optimization Persistence Resource pooling Synchronization Transactions

III. Mybatis

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

Overall process:

(1)Loading configuration and initializing trigger conditions: Loading configuration files loads SQL configuration information into MappedStatement objects (including incoming parameter mapping configuration, executed SQL statements, and result mapping configuration), and stores them in memory.

(2)Receive call request trigger condition: Call API provided by Mybatis Incoming parameters: ID and incoming parameters for SQL Object processing: Pass the request to the lower request processing layer for processing.

(3)Trigger condition for processing operation request: API interface layer passes request incoming parameter: ID of SQL and incoming parameter object

Process:

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

(B)Parse the MappedStatement object according to the incoming parameter object to get the SQL to be executed and execute the incoming parameter.

(C)Acquire database connection, execute parameters passed in to database according to final SQL statement obtained, and obtain execution result.

(D)converting the obtained execution result according to the result mapping configuration in the MappedStatement object to obtain a final processing result.

(E)Release connection resources.

(4)Returns the final processing result.

One of the most powerful features of MyBatis is its dynamic statement capabilities. If you have previous experience with JDBC or similar frameworks, you know how painful it is to string SQL statement conditions together, making sure you don't forget spaces or omit a comma after columns, etc. Dynamic statements can completely eliminate this pain.

IV. Dubbo

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

Transparent remote method calls, just like calling local methods, with simple configuration and no API intrusion.

2. Soft Load Balancer and fault tolerance mechanism can replace hardware Load Balancer such as F5 in intranet, reduce cost and reduce single point.

Automatic service registration and discovery, no longer need to write dead service provider address, the registry queries the IP address of the service provider based on the interface name, and can smoothly add or delete service providers.

Node Role Description: Provider: The service provider that exposes the service. Consumer: The service consumer that invokes the remote service. Registry: A registry that serves registration and discovery. Monitor: A monitoring center that counts service invocation times and invocation times. Container: Service runs container.

V. Maven

Maven is a project management and build automation tool that is increasingly being used by developers to manage jars in their projects. But for us programmers, what we care most about is its project-building capabilities.

VI. RabbitMQ

Message queue is generally in the project, some do not need to return immediately and time-consuming operations extracted, asynchronous processing, and this asynchronous processing method greatly saves the server request response time, thus improving the system throughput.

RabbitMQ is a highly concurrent and reliable AMQP message queue server implemented with Erlang.

Erlang is a dynamically typed functional programming language. In Erlang, each Actor corresponds to an Erlang process, and processes communicate with each other through message passing. An immediate benefit of interprocess communication via message passing over shared memory is the elimination of direct locking overhead (regardless of lock application in the underlying Erlang VM implementation).

AMQP(Advanced Message Queue Protocol) defines a message system specification. This specification describes how subsystems in a distributed system interact via messages.

VII. Log4j

The logging priority is OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL, or a level you define.

VIII. Ehcache

EhCache is a pure Java in-process cache framework, with fast, lean and other characteristics, Hibernate is the default CacheProvider. Ehcache is a widely used open source Java distributed cache. It is primarily targeted at generic caching,Java EE and lightweight containers. It features memory and disk storage, cache loader, cache extensions, cache exception handlers, a gzip cache servlet filter, support for REST and SOAP APIs, etc.

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 5. Cache data will be written to disk during VM restart 6. Distributed caching can be performed through RMI, pluggable API, etc. 7. Listening interface with cache and cache manager 8. Support multiple cache manager instances and multiple cache areas for one instance 9. Provide Hibernate cache implementation

Disadvantages: 1, the use of disk cache when very occupied disk space: this is because DiskCache algorithm is simple, the algorithm is simple also leads to Cache efficiency is very high. It simply appends storage directly to elements. So it's very fast to search for elements. If DiskCache is used, in very frequent applications, the disk will soon be full.

2, can not guarantee the security of data: when suddenly kill java, there may be conflicts, EhCache solution is to rebuild cache if the file conflicts. This can be detrimental when Cache data needs to be saved. Of course, Cache is just a simple acceleration and does not guarantee data security. If you want to keep your data safe, you can use Bekeley DB Java Edition. This is an embedded database. Storage security and space utilization can be ensured.

IX. Redis

Redis is a key-value storage system. Similar to Memcached, it supports a relatively large number of stored value types, including string, list, set, zset, and hash. These data types all support push/pop, add/remove, and take intersection union and subtraction, as well as richer operations, all of which are atomic. On this basis, redis supports a variety of different ways of sorting. As with memcached, data is cached in memory for efficiency. The difference is that redis periodically writes updated data to disk or changes to additional log files, and on this basis achieves master-slave synchronization.

The Redis database is entirely in memory, using disk only for persistence. Redis has a richer set of data types than many key-value data stores. Redis can copy data to any number of slave servers.

1.2 Redis Advantages:

(1) Extremely fast: Redis is very fast, performing about 110,000 sets per second, about 81000+ records per second.

(2) Support for rich data types: Redis supports the most data types most developers already know like lists, sets, ordered sets, hashes. This makes it very easy to solve a wide variety of problems because we know which problems can be handled better by the type of data it has.

(3) Operations are atomic: All Redis operations are atomic, which guarantees that if two clients access the Redis server at the same time, the updated value will be obtained.

(4) Multi-utility: Redis is a multi-utility tool that can be used in multiple applications such as caching, messaging, queues (Redis natively supports publish/subscribe), any ephemeral data, applications such as Web application sessions, page hit counts, etc.

1.3 Disadvantages of Redis: (1) Single thread (2) Memory consumption

X. Shiro

Apache Shiro is a Java security framework designed to simplify authentication and authorization. Shiro is available in both Java SE and Java EE projects. It is mainly used to handle identity authentication, authorization, enterprise session management and encryption. Shiro's specific functions are as follows:

(1) Identity authentication/login, verifying whether the user has the corresponding identity;

(2) Authorization, that is, permission verification, verifies whether an authenticated user has a certain permission; that is, judges whether the user can do something, such as verifying whether a user has a certain role. Or fine-grained verification of whether a user has a certain permission on a certain resource;

(3) Session management, that is, after the user logs in, it is a session. Before exiting, all its information is in the session; the session can be an ordinary Java SE environment, or it can be a Web environment;

(4) Encryption, which protects the security of data, 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: cache, for example, after a user logs in, his user information and roles/permissions do not have to be checked every time, which can improve efficiency;

(6) shiro supports concurrent validation of multithreaded applications, that is, if you open another thread in one thread, you can automatically propagate permissions to the past;

(7) provide testing support;

(8) Allow one user to pretend to be another user (if they allow it) for access;

(9) Remember me, this is a very common feature, that is, after logging in once, you don't have to log in next time.

Thank you for reading this article carefully. I hope that Xiaobian's "What are the commonly used frameworks in java" article will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report