This issue recommends a lightweight Java application development framework – YMP.
YMP is a very simple and easy to use lightweight Java application development framework, covering AOP, IoC, WebMVC, ORM, Validation, Plugin, Serv, Cache and other features, so that development work as easy as building blocks!
Features
- Package in componentized, modular way, can be assembled on demand, flexible and extensible
- Using microkernel to achieve AutoScan, AOP, IoC, Event, etc., covering most of the core functions in SSH and SSM framework
- Unified configuration architecture, feel different file resource configuration and management mode
- Integrate multiple logging systems (Log4j, JCL, Slf4j, etc.), log files can be stored separately
- Lightweight persistence layer encapsulation with support for RDBMS (MySQL, SQL Server, Oracle, PostgreSQL) and NoSQL (MongoDB, Redis)
- Perfect plug-in mechanism to help finer granularity of business splitting
- Unique Serv development experience
- Powerful validation framework, based entirely on Java annotations, easy to use and extend
- Flexible caching service, supporting EhCache, Redis, and MultiLevel caching technology
- Configure simple MVC architecture, powerful and easy to maintain and extend, support RESTful style, support JSP, HTML, Binary, Freemarker, Velocity and other view technologies
Modules
YMP framework is mainly composed of Core and several Modules, the overall structure is simple and clear, as shown in the figure:
Core
The core is also called the application container (IApplication), which is mainly responsible for framework initialization, Events broadcasting and monitoring, module definition and its life cycle management, international resource management (I18N) and class object management, etc. Its core functions are automatic scanning of packages and classes (AutoScan), object lifecycle management, inversion control (IoC), dependency injection (DI), and method interception (AOP).
Configuration
Realize unified management of various resources such as configuration files during project development and maintenance through a simple directory structure, and provide flexible, simple and effective solutions for modular development and deployment:
- Standardize the modular development process and unify the life cycle management of resource files from the perspective of development;
- Integrate all resources in the whole system from the perspective of maintainability, with the advantages of effective resource reuse and flexible system integration construction, deployment, data backup and migration;
- Simple configuration file retrieval, loading and management mode;
- Resource sharing between modules. Modules can share resource files such as configuration, classes and jar packages of projects.
- The default support for XML, Properties and JSON configuration file parsing, can be customized through the IConfigurationProvider interface, support caching, avoid repeated loading;
- The configuration object supports @Configuration annotation declaration, and the configuration content can be automatically loaded and filled into the class object without coding.
- Modify the configuration file without restarting the service, and support automatic reload.
- Build (compile) and distribute integrated modules, start and stop services, and clear classification structure of resource files can be quickly located;
Log
Based on the open source log framework Log4j 2, it provides unified management of log recorder objects and integrates excellent log systems such as JCL and Slf4j. It can call any log recorder at any location to output logs, which realizes the separation of system and business logs. At the same time with the YMP configuration system module, the effect is better.
Persistence
JDBC
JDBC Persistence module A set of simple solutions for relational database (RDBMS) data access, focusing on data access efficiency, ease of use, stability and transparency, with the following features:
-
- Lightweight packaging based on JDBC framework API, simple structure, easy to develop, debug and maintain;
- Optimize batch data update, standardize result sets, and precompiled SQL statement processing;
- Support single entity ORM operation, no need to write SQL statements;
- Provide scaffolding tools, quickly generate data entity classes, support chain calls;
- Support for custom SQL statements via memory annotations or dynamic loading of SQL from configuration files and automatic execution;
- Support automatic assembly of result sets and value objects, support custom assembly rules;
- Support multiple data sources, default support C3P0, DBCP, Druid, HikariCP, JNDI connection pool configuration, support data source extension;
- Support a variety of databases (such as Oracle, MySQL, SQLServer, SQLite, H2, PostgreSQL, etc.);
- Support object-oriented database query encapsulation, helping to reduce or reduce program compile-time errors;
- Support database transaction nesting;
- Support database views and stored procedures;
MongoDB
According to the characteristics of MongoDB data access operation, the design idea of JDBC persistence module is simply encapsulated, the session mechanism is adopted, the transaction processing logic is simplified, and the multi-data source configuration and entity operation are supported. Objectify query conditions based on IOperator, and integrate MapReduce, GridFS, aggregation, function expressions, etc.
Redis
Based on Jedis driver, simple encapsulation based on the design idea of JDBC persistence module, using session mechanism, unified API call, simplifying subscribe and publish operations, supporting multi-data source and connection pool configuration, Support for data source connections such as jedis, shard, sentinel, and cluster.
Plugin
The plug-in module uses an independent ClassLoader to manage private packages, classes, resource files, etc. The design goal is to split the requirements into finer particles under the interface development mode, so as to achieve an idealized reusable code encapsulation form.
Each plug-in is a closed world, the only way to communicate between plug-ins and the outside world is through the business interface call, the container management of these plug-ins is called the plug-in factory (IPluginFactory), which is responsible for plug-in analysis, loading and initialization, as well as plug-in life cycle management. The plug-in module supports the creation of multiple plug-in factory instances, and the factory objects are completely independent from each other without any dependencies.
Service (Serv)
Service (Serv) is a communication service framework based on NIO implementation, providing TCP, UDP protocol client and server encapsulation, flexible message monitoring and message content encoding/decoding, simple configuration makes secondary development more convenient. At the same time, the client provides default service support such as disconnection and link maintenance (heartbeat). You only need to understand the business to complete the development work easily.
Validation
Verification module is a server-side parameter validity verification tool. It adopts annotation declaration to configure verification rules, which is simpler, more intuitive and friendly. It supports method parameter and class member attribute verification, international I18N resource binding of verification results, custom validators and multiple verification modes.
Cache
Cache module takes EhCache as the default JVM in-process cache service, integrates external Redis service to achieve MultiLevel lightweight cache framework, and deeply integrates with YMP framework (supports caching for class methods, Can be cached based on method parameter values), flexible configuration, easy to use, and extensible.
WebMVC
WebMVC module is another very important module in YMP framework in addition to JDBC persistence module. It integrates many features of YMP framework, and still maintains a consistent simple style in the design and use of functional structure. At the same time, it also inherits the genes of the mainstream MVC framework, and it is extremely easy for developers who understand and are familiar with framework technologies such as SSH or SSM to get started and have no learning costs.
Its main functions are as follows:
- Standard MVC implementation, clear structure, completely annotation-based configuration is simple;
- Support convention mode, no need to write controller code, directly match and execute view ‘
- Support for multiple view technologies (Binary, Forward, Freemarker, HTML, HttpStatus, JSON, JSP, Redirect, Text, Velocity, etc.);
- Support RESTful mode and URL style;
- Support automatic binding of request parameters to controller method parameters;
- Support parameter validity verification;
- Support for controller method interception;
- Support annotation configuration controller request route mapping;
- Support automatic scanning controller classes and registration;
- Support for custom handling of events and exceptions;
- Support I18N resource internationalization;
- Support for controller methods and view caching;
- Support plug-in extension;
Common Tool Kit (Commons)
The commonly used tool class library package is some very practical auxiliary tools accumulated during the development of YMP framework. Which mainly involves HttpClient request wrapper, JSON wrapper, file and resource management, data import and export, video image processing, two-dimensional code, serialization, class, date and time, mathematics, latitude and longitude, string encryption and decryption, runtime environment, network, thread operation, etc.
—END—
Open Source protocol: Apache2.0