Processing strategy loading execution system and method based on Spring framework

By using a Spring-based strategy loading and execution system, which utilizes components such as component enumeration classes, strategy interfaces, and factory classes, the high coupling and poor extensibility of strategy loading and execution in existing technologies are solved, achieving independent management and efficient strategy loading and execution.

CN119166115APending Publication Date: 2024-12-20ELLIPSPACE (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411038493.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

Existing strategy loading and execution technologies suffer from high coupling, poor scalability, low code maintainability, and low system operation efficiency.

Method used

A strategy loading and execution system based on the Spring framework is adopted. Through component enumeration classes, strategy interfaces, strategy template classes, basic factory classes and component factory classes, combined with the dependency injection mechanism of the Spring framework, dynamic loading and cache management of strategy instances are realized, reducing system coupling and improving code maintainability and system efficiency.

Benefits of technology

It enables independent management of different strategies, reduces the need for code changes, improves system scalability and code maintainability, and enhances system operational efficiency through a caching mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166115A_ABST
    Figure CN119166115A_ABST
Patent Text Reader

Abstract

The invention discloses a processing strategy loading execution system and method based on a Spring framework, and relates to the technical field of software development, and the system comprises a component enumeration class, a strategy interface, a strategy template class, a basic factory class, the Spring framework and a component factory class. According to the method, the dependency injection mechanism of the Spring framework is combined with the policy mode formed by the policy interface, the basic factory class, the policy template class, the component enumeration class and the component factory class, so that independent management of different policies is realized, the coupling degree is reduced, codes do not need to be changed when the policies are newly added, and the expansibility is improved; an abstract template of the strategy is provided through the strategy template class, so that the code maintainability is improved; by introducing a cache mechanism into the basic factory class, the strategy instance is prevented from being searched repeatedly, and the system operation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of software development, and in particular to a processing strategy loading execution system and method based on a Spring framework. Background Art

[0002] In modern software development, when dealing with different types of business logic and functional modules, it is often necessary to load and execute different strategies according to different conditions.

[0003] Common strategy loading and execution technologies include: hard-coding and factory mode. Among them, the hard-coding method uses a large number of if-else or switch-case statements in the code to execute corresponding logic according to different conditions. The implementation method is: judge different business scenarios through conditional statements, and write corresponding business logic in each conditional branch. The factory mode defines an interface for creating objects and lets the subclass decide which class to instantiate, thus delaying the instantiation of the object to the subclass. The implementation method is: define a strategy interface, all specific strategies implement the interface, and use the factory class to create corresponding strategy instances according to different conditions.

[0004] However, the hard-coding method in the prior art has a high degree of code coupling because the business logic and conditional judgment are mixed together; each time the business logic is added or modified, the conditional judgment statement needs to be modified, which is easy to introduce new errors and the code maintainability is poor; when a new business type is added, the original code needs to be modified, which increases the maintenance cost and has poor scalability. The factory mode in the prior art also has poor scalability because the factory class needs to be modified each time a new strategy is added; as the number of strategy types increases, the factory class becomes bloated and the maintainability is also poor; each time a strategy instance is obtained, it will be created, and the system operation efficiency is poor.

[0005] In summary, the existing policy loading and execution technologies have high coupling, poor scalability, poor code maintainability, and poor system operation efficiency. Summary of the invention

[0006] The embodiments of the present application solve the problems of high coupling degree, poor scalability, poor code maintainability and poor system operation efficiency of existing policy loading and execution technologies by providing a processing policy loading and execution system and method based on the Spring framework.

[0007] In a first aspect, an embodiment of the present application provides a processing strategy loading execution system based on the Spring framework, including: a component enumeration class, a strategy interface, a strategy template class, a basic factory class, a Spring framework and a component factory class.

[0008] The component enumeration class is configured to define all possible component types in the system.

[0009] The strategy interface is configured to: define a generic method, and the generic method is used to return the enumeration type supported by the strategy.

[0010] The policy template class is configured to: implement the policy interface, and define the basic structure and execution process of the policy.

[0011] The basic factory class is configured to: load the corresponding policy instance according to the incoming enumeration type through the dependency injection mechanism of the Spring framework, and perform cache management on the policy instance.

[0012] The component factory class is configured to load and execute the corresponding component strategy according to the passed-in enumeration type.

[0013] In a possible implementation, the basic factory class uses a cache mechanism to perform cache management.

[0014] The cache mechanism includes: caching loaded policy instances.

[0015] In a possible implementation, the basic factory class uses a policy loading mechanism through a dependency injection mechanism of a Spring framework to load a corresponding policy instance according to an incoming enumeration type.

[0016] The policy loading mechanism includes: obtaining an enumeration type through the dependency injection mechanism of the Spring framework, matching a corresponding policy instance according to the passed-in enumeration type, caching and returning a policy instance if a policy instance is matched, and throwing an exception if a policy instance is not matched.

[0017] In a possible implementation, the basic structure and execution process of the policy includes two abstract methods, and the two abstract methods are used to execute the general pre-check logic and the specific policy processing logic respectively.

[0018] In a possible implementation, the component types include a data storage engine, a message queue, and a cache system.

[0019] In a possible implementation, the component factory class inherits from the base factory class.

[0020] In a possible implementation manner, the processing strategy loading execution system based on the Spring framework further includes: a specific strategy class.

[0021] The specific policy class inherits from the policy template class.

[0022] The specific policy class is configured to implement the abstract method of the policy template class.

[0023] In a possible implementation, the component factory class is further configured to: load and execute the corresponding component strategy in the specific strategy class according to the passed-in enumeration type.

[0024] In a second aspect, the embodiment of the present application provides a processing strategy loading and execution method based on the Spring framework, including:

[0025] Define all possible component types in the system.

[0026] Define a generic method that is used to return the enumeration type supported by the strategy.

[0027] Define the basic structure and execution flow of the strategy.

[0028] Through the dependency injection mechanism of the Spring framework, the corresponding policy instance is loaded according to the passed enumeration type, and the policy instance is cached and managed.

[0029] Load the corresponding component strategy according to the passed enumeration type and execute it.

[0030] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0031] The embodiment of the present application combines the dependency injection mechanism of the Spring framework with the strategy pattern formed by the strategy interface, the base factory class, the strategy template class, the component enumeration class, and the component factory class to achieve independent management of different strategies, reduce coupling, and do not need to change the code when adding new strategies, thereby improving scalability; providing an abstract template for the strategy through the strategy template class improves code maintainability; and introducing a caching mechanism in the base factory class avoids repeated searches for strategy instances, thereby improving system operation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0033] Figure 1 A schematic diagram of a module for a Spring framework-based processing strategy loading execution system provided in an embodiment of the present application;

[0034] Figure 2 A schematic diagram of the modules when the processing strategy based on the Spring framework provided in the embodiment of the present application is actually applied in the execution system;

[0035] Figure 3A flowchart of a Spring framework-based processing strategy loading and execution method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0036] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0037] like Figure 1 As shown, an embodiment of the present application provides a processing strategy loading execution system based on the Spring framework, including: a component enumeration class, a strategy interface, a strategy template class, a basic factory class, a Spring framework and a component factory class.

[0038] The component enumeration class is configured to define all possible component types in the system.

[0039] The strategy interface is configured to: define a generic method, which is used to return the enumeration type supported by the strategy.

[0040] The policy template class is configured to: implement the policy interface, and define the basic structure and execution flow of the policy.

[0041] The basic factory class is configured to: load the corresponding policy instance according to the incoming enumeration type through the dependency injection mechanism of the Spring framework, and perform cache management on the policy instance.

[0042] The component factory class is configured to load and execute the corresponding component strategy according to the passed-in enumeration type.

[0043] Specifically, in this embodiment, the processing logic is encapsulated in an independent strategy class through a strategy template class, and based on the dependency injection mechanism of the Spring framework, not only the system coupling is reduced, but also the readability and maintainability of the code are improved.

[0044] In this embodiment, the strategy pattern formed by the strategy interface, the basic factory class, the strategy template class, the component enumeration class, and the component factory class allows the algorithm strategy to be added or replaced dynamically without modifying the calling code. Combined with the Spring framework, the creation and management of strategy instances become more flexible and efficient. By introducing the basic factory class and the component factory class, they work together to ensure that the strategy service can be flexibly loaded and cached according to demand, further improving the system's scalability.

[0045] In this embodiment, the component enumeration class provides a convenient way to add new component types to the system, eliminating the tediousness of modifying existing code. The policy template class establishes a unified execution process to ensure the correct execution and consistency of the policy. The introduction of the cache mechanism in the basic factory class further accelerates the execution of the policy and improves system performance.

[0046] By combining the dependency injection mechanism of the Spring framework with the strategy pattern formed by the strategy interface, basic factory class, strategy template class, component enumeration class, and component factory class, the resulting Spring framework-based strategy loading execution system is highly flexible and extensible, and can effectively solve the problems of high coupling, difficult maintenance and expansion in traditional software systems, while ensuring high performance requirements, making it suitable for the development and optimization of a variety of software systems.

[0047] Specifically, in this embodiment, the strategy interface (ISupport) defines a generic method support(), which is used to return the enumeration type supported by the strategy. This enables each strategy to clearly define the enumeration type (ie, processing type) it supports.

[0048] In this embodiment, the code implementation of the strategy interface (ISupport) is as follows:

[0049] public interface ISupport <e>{

[0050] / **

[0051] *Supported Processing

[0052] * /

[0053] E support();

[0054] }

[0055] Exemplarily, the basic factory class adopts a cache mechanism to perform cache management.

[0056] The cache mechanism includes: caching loaded policy instances.

[0057] Exemplarily, the basic factory class adopts a policy loading mechanism through a dependency injection mechanism of a Spring framework to load a corresponding policy instance according to an incoming enumeration type.

[0058] The policy loading mechanism includes: obtaining an enumeration type through the dependency injection mechanism of the Spring framework, matching a corresponding policy instance according to the passed-in enumeration type, caching and returning a policy instance if a policy instance is matched, and throwing an exception if a policy instance is not matched.

[0059] Specifically, in this embodiment, the base factory class (BaseFactory) is a general strategy factory class, which is used to load the corresponding strategy instance according to the input enumeration type and perform cache management on the strategy instance.

[0060] In this embodiment, the code implementation of the base factory class (BaseFactory) is as follows:

[0061] @Component

[0062] @Slf4j

[0063] public class BaseFactory <e>,E>extends org.springframework.context.support.ApplicationObjectSupport{

[0064] private Map<String, S> cache = new HashMap<>();

[0065] public S load(E enums) {

[0066] if (enums == null) {

[0067] String msg = "必须指定一个枚举";

[0068] log.error(msg);

[0069] throw new ValidateException(msg);

[0070] }

[0071] String key = enums.getClass().getName();

[0072] S s = cache.get(key);

[0073] if (s != null) {

[0074] return s;

[0075] }

[0076] ApplicationContext context = getApplicationContext();

[0077] Class <s>service=(Class <s>)((ParameterizedType)

[0078] getClass().getGenericSuperclass()).getActualTypeArguments()[0];

[0079] String[]supportStrategy=context.getBeanNamesForType(service);

[0080] if(supportStrategy==null||supportStrategy.length==0){

[0081] log.warn("No processing service available");

[0082] return null;

[0083] }

[0084] for(String item:supportStrategy){

[0085] S strategy=context.getBean(item,service);

[0086] if(strategy.support()!=null&&strategy.support()==enums){

[0087] cache.put(key,strategy);

[0088] return strategy;

[0089] }

[0090] }

[0091] throw new ValidateException("Policy not found: {}, corresponding enumeration: {}", service.getName(), enums.toString());

[0092] }

[0093] }

[0094] In the above code, the cache mechanism uses Map<String,S> Caches loaded policy instances.

[0095] The policy loading mechanism obtains all enumeration type beans that conform to type S through the ApplicationContext of the Spring framework, matches the corresponding policy instance according to the passed enumeration type, and caches and returns the policy instance if it matches. If it does not match the policy instance, an exception is thrown.

[0096] Exemplarily, the basic structure and execution process of the policy includes two abstract methods, and the two abstract methods are used to execute the general pre-check logic and the specific policy processing logic respectively.

[0097] Specifically, in this embodiment, the strategy template class (ComponentStrategy) is an abstract class that implements the strategy interface, defines the basic structure and execution process of the strategy, and includes two abstract methods preCheck() and doStrategy(), which are used to execute general pre-check logic and specific strategy processing logic respectively.

[0098] In this embodiment, the code implementation of the strategy template class (ComponentStrategy) is as follows:

[0099] public abstract class ComponentStrategy <e>implements ISupport <e>{

[0100] / **

[0101] * General pre-check logic

[0102] * /

[0103] protected abstract void preCheck();

[0104] / **

[0105] *Strategy processing logic

[0106] * /

[0107] protected abstract void doStrategy();

[0108] / **

[0109] * Execution strategy

[0110] * /

[0111] public void execute(){

[0112] preCheck();

[0113] doStrategy();

[0114] }

[0115] }

[0116] Exemplarily, the component types include a data storage engine, a message queue, and a cache system.

[0117] Specifically, the component enumeration class (ComponentTypeEnum) defines all possible component types in the system, such as data storage engines, message queues, cache systems, etc., to facilitate unified management and use in the system.

[0118] In this embodiment, the code implementation of the component enumeration class (ComponentTypeEnum) is as follows:

[0119] public enum ComponentTypeEnum{

[0120] DATABASE,

[0121] MESSAGE_QUEUE,

[0122] CACHE

[0123] }

[0124] Exemplarily, the component factory class inherits from the base factory class.

[0125] Specifically, the component factory class (ComponentFactory) inherits from the base factory class (BaseFactory), specifies the loaded type S as the strategy template class (ComponentStrategy), specifies the enumeration type E supported by the strategy as the component enumeration class (ComponentTypeEnum), and loads and executes the corresponding component strategy according to the passed in enumeration type.

[0126] In this embodiment, the code implementation of the component factory class (ComponentFactory) is as follows:

[0127] @Component

[0128] public class ComponentFactory extends BaseFactory <ComponentStrategy <componenttypeenum>,ComponentTypeEnum>{

[0129] }

[0130] like Figure 2 As shown, the processing strategy loading execution system based on the Spring framework also includes: a specific strategy class.

[0131] The specific policy class inherits from the policy template class.

[0132] The specific policy class is configured to implement the abstract method of the policy template class.

[0133] Specifically, in the actual application of the system, developers only need to define a specific strategy class (DatabaseStrategy), inherit from the strategy template class (ComponentStrategy), and implement the abstract methods of the strategy template class (ComponentStrategy).

[0134] In this embodiment, the code implementation of the specific strategy class (DatabaseStrategy) is as follows:

[0135] @Component

[0136] public class DatabaseStrategy extends ComponentStrategy <componenttypeenum>{

[0137] @Override

[0138] public ComponentTypeEnum support(){

[0139] return ComponentTypeEnum.DATABASE;

[0140] }

[0141] @Override

[0142] protected void preCheck(){

[0143] / / General pre-check logic

[0144] }

[0145] @Override

[0146] protected void doStrategy(){

[0147] / / Database strategy processing logic

[0148] }

[0149] }

[0150] Exemplarily, the component factory class is further configured to: load and execute the corresponding component strategy in the specific strategy class according to the passed-in enumeration type.

[0151] Specifically, after the specific strategy class (DatabaseStrategy) implements the abstract method of the strategy template class (ComponentStrategy), the corresponding component strategy in the specific strategy class is loaded and executed according to the passed enumeration type through the component factory class (ComponentFactory).

[0152] In this embodiment, the code implementation of the component factory class (ComponentFactory) loading the corresponding component strategy in the specific strategy class and executing it is as follows:

[0153] @Component

[0154] public class SomeService{

[0155] @Autowired

[0156] private ComponentFactory componentFactory;

[0157] public void performOperation(ComponentTypeEnum componentType){

[0158] ComponentStrategy <componenttypeenum>strategy=

[0159] componentFactory.load(componentType);

[0160] strategy.execute();

[0161] }

[0162] }

[0163] like Figure 3 As shown, the embodiment of the present application also provides a processing strategy loading and execution method based on the Spring framework, including:

[0164] S101, define all possible component types in the system.

[0165] S102, defining a generic method, where the generic method is used to return an enumeration type supported by the policy.

[0166] S103, define the basic structure and execution process of the strategy.

[0167] S104, through the dependency injection mechanism of the Spring framework, load the corresponding policy instance according to the passed-in enumeration type, and perform cache management on the policy instance.

[0168] S105, loading and executing the corresponding component strategy according to the passed-in enumeration type.

[0169] Specifically, in this embodiment, step S101 is implemented by the component enumeration class (ComponentTypeEnum), step S102 is implemented by the strategy interface (ISupport), step S103 is implemented by the strategy template class (ComponentStrategy), step S104 is implemented by the base factory class (BaseFactory), and step S105 is implemented by the component factory class (ComponentFactory). Among them, the strategy template class (ComponentStrategy) is an abstract class, the base factory class (BaseFactory) is a generic class, and the component factory class (ComponentFactory) is a specific factory class. The component factory class (ComponentFactory) inherits from the base factory class (BaseFactory). The component factory class (ComponentFactory) uses the component enumeration class (ComponentTypeEnum) to load the corresponding component strategy. The strategy template class (ComponentStrategy) uses the component enumeration class (ComponentTypeEnum) to identify the supported strategy types.

[0170] In actual applications, developers only need to define a specific strategy class (DatabaseStrategy), which inherits from the strategy template class (ComponentStrategy), and implement the two abstract methods preCheck() and doStrategy() of the strategy template class (ComponentStrategy). Then, the corresponding component strategy in the specific strategy class is loaded and executed according to the passed enumeration type through the component factory class (ComponentFactory).

[0171] In a possible embodiment, the hard-coding method and factory mode in the existing policy loading and execution technology are compared with the Spring framework-based policy loading and execution system and method in the present application to illustrate the advantages of the present application.

[0172] The hard-coding method in the existing policy loading and execution technology uses a large number of if-else or switch-case statements in the code to execute corresponding logic according to different conditions. The implementation method is: judge different business scenarios through conditional statements and write corresponding business logic in each conditional branch.

[0173] The sample code of hard coding method is as follows:

[0174] public void processRequest(String type){

[0175] if (type.equals("TYPE_A")) {

[0176] / / Execute the processing logic of type A

[0177] }else if(type.equals("TYPE_B")){

[0178] / / Execute the processing logic of type B

[0179] }else if(type.equals("TYPE_C")){

[0180] / / Execute the processing logic of type C

[0181] }else{

[0182] / / Handle unknown types

[0183] }

[0184] }

[0185] It can be seen that the hard-coding method in the existing policy loading and execution technology mixes business logic and conditional judgment, resulting in high code coupling; each time the business logic is added or modified, the conditional judgment statement needs to be modified, which is easy to introduce new errors and has poor code maintainability; when a new business type is added, the original code needs to be modified, which increases maintenance costs and has poor scalability.

[0186] The factory pattern in the existing strategy loading and execution technology defines an interface for creating objects and lets the subclass decide which class to instantiate, thus delaying the instantiation of the object to the subclass. The implementation method is: define a strategy interface, all specific strategies implement the interface, and use the factory class to create corresponding strategy instances according to different conditions.

[0187] The sample code of the factory mode is as follows:

[0188] / / Usage example

[0189] public void processRequest(String type){

[0190] Strategy strategy=StrategyFactory.getStrategy(type);

[0191] strategy.execute();

[0192] }

[0193] It can be seen that the factory mode in the existing policy loading and execution technology has poor scalability because the factory class needs to be modified every time a new policy is added; as the number of policy types increases, the factory class becomes bloated and has poor maintainability; each time a policy instance is obtained, it is created, and the system operation efficiency is poor.

[0194] The embodiment of the present application combines the dependency injection mechanism of the Spring framework with the strategy pattern formed by the strategy interface, the basic factory class, the strategy template class, the component enumeration class, and the component factory class, thereby realizing the independent management of different strategies, reducing the coupling degree, and improving the extensibility without changing the code when adding a new strategy; providing an abstract template of the strategy through the strategy template class improves the maintainability of the code; and introducing a cache mechanism in the basic factory class avoids repeated searches for strategy instances, thereby improving the system operation efficiency. This solves the problems of high coupling degree, poor extensibility, poor code maintainability, and poor system operation efficiency in the existing strategy loading and execution technology.

[0195] Some modules in the system described in the present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0196] The system or module described in the above application embodiment can be implemented by a computer chip or entity, or by a product with a certain function. For the convenience of description, the above system is described by dividing it into various modules according to its function. When implementing the embodiment of the present application, the functions of each module can be implemented in the same or more software and / or hardware. Of course, the module that realizes a certain function can also be implemented by combining multiple sub-modules or sub-units.

[0197] The methods, systems or modules described in this application can be implemented in a computer-readable program code or in any appropriate manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (English: Application Specific Integrated Circuit; Abbreviation: ASIC), a programmable logic controller and an embedded microcontroller. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, AtmelAT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the system included in it for implementing various functions can also be regarded as a structure within the hardware component. Or even, a system for implementing various functions may be considered as both a software module implementing the method and a structure within a hardware component.

[0198] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary hardware. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, or it can be reflected in the implementation process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.

[0199] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. All or part of this application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, mobile communication terminals, multi-processor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0200] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present application.< / componenttypeenum> < / componenttypeenum> < / componenttypeenum> < / e> < / e> < / s> < / s> < / e> ​< / e>

Claims

1. The processing strategy based on the Spring framework is loaded into the execution system, which is characterized by: include: Component enumeration class, strategy interface, strategy template class, base factory class, Spring framework and component factory class; The component enumeration class is configured to: define all possible component types in the system; The strategy interface is configured to: define a generic method, wherein the generic method is used to return an enumeration type supported by the strategy; The policy template class is configured to: implement the policy interface, define the basic structure and execution process of the policy; The basic factory class is configured to: load the corresponding policy instance according to the passed-in enumeration type through the dependency injection mechanism of the Spring framework, and perform cache management on the policy instance; The component factory class is configured to load and execute the corresponding component strategy according to the passed-in enumeration type.

2. The processing strategy loading and execution system based on the Spring framework according to claim 1 is characterized in that: The basic factory class adopts a cache mechanism for cache management; The cache mechanism includes: caching loaded policy instances.

3. The processing strategy loading and execution system based on the Spring framework according to claim 1 is characterized in that: The basic factory class adopts the strategy loading mechanism through the dependency injection mechanism of the Spring framework to load the corresponding strategy instance according to the passed enumeration type; The policy loading mechanism includes: obtaining an enumeration type through the dependency injection mechanism of the Spring framework, matching a corresponding policy instance according to the passed-in enumeration type, caching and returning a policy instance if a policy instance is matched, and throwing an exception if a policy instance is not matched.

4. The processing strategy loading and execution system based on the Spring framework according to claim 1 is characterized in that: The basic structure and execution flow of the strategy include two abstract methods, which are used to execute the general pre-check logic and the specific strategy processing logic respectively.

5. The processing strategy loading and execution system based on the Spring framework according to claim 1 is characterized in that: The component types include data storage engines, message queues, and cache systems.

6. The processing strategy loading and execution system based on the Spring framework according to claim 1 is characterized in that: The component factory class inherits from the base factory class.

7. The processing strategy loading and execution system based on the Spring framework according to claim 1 is characterized in that: Also includes: Specific strategy categories; The specific strategy class inherits from the strategy template class; The specific policy class is configured to implement the abstract method of the policy template class.

8. The processing strategy loading and execution system based on the Spring framework according to claim 7 is characterized in that: The component factory class is further configured to: load and execute the corresponding component strategy in the specific strategy class according to the passed-in enumeration type.

9. A processing strategy loading and execution method based on the Spring framework, implemented by a processing strategy loading and execution system based on the Spring framework as claimed in any one of claims 1 to 8, characterized in that: include: Define all possible component types in the system; Define a generic method, which is used to return the enumeration type supported by the strategy; Define the basic structure and execution process of the strategy; Through the dependency injection mechanism of the Spring framework, the corresponding policy instance is loaded according to the incoming enumeration type, and the policy instance is cached and managed; Load the corresponding component strategy according to the passed enumeration type and execute it.