Loading method and device for dynamically loading data source, equipment and medium
By combining the DFlow loading device with the Spring Boot framework, dynamic loading and switching of data sources are realized, which solves the problem of limited dynamic switching capabilities between multiple data sources in existing technologies, and improves the system's scheduling flexibility and operational efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SINOCHEM INFORMATION TECH CO LTD
- Filing Date
- 2026-02-09
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies require explicitly defining the connection target object for each called method or class within the code, which limits the ability to dynamically switch between multiple data sources and prevents applications from being scheduled horizontally.
By enabling the DFlow loader, the Spring Boot framework's auto-configuration class is triggered to initialize the core components of the initializer, configuration provider, connection request handler, and data source proxy. Combined with non-intrusive logic interception aspects and transparent data source objects, dynamic loading and switching of data sources are achieved.
It can meet the scheduling needs of multiple data sources without modifying the business code, supports horizontal scaling of applications, ensures seamless business switching and system stability, and improves scheduling flexibility and operation and maintenance efficiency.
Smart Images

Figure CN122019012A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data loading technology, and in particular to methods, apparatus, devices and media for dynamically loading data sources. Background Technology
[0002] As businesses expand and systems become more complex, the coexistence of multiple data sources has become the mainstream architectural approach.
[0003] On the one hand, different business modules deploy databases independently (such as order data sources, member data sources, and product data sources for e-commerce platforms) to achieve business decoupling; on the other hand, to ensure high availability, core businesses adopt a master-slave data source and disaster recovery data source architecture to avoid single points of failure.
[0004] While multi-data source architecture solves the performance bottlenecks and availability issues of a single database, it also brings new challenges. How to achieve efficient and dynamic switching between multiple data sources based on load fluctuations, fault status, and business needs becomes crucial to ensuring system stability. For example, during peak sales periods, order read traffic surges, requiring some requests to be switched from one data source to another; when the primary data source fails, write traffic needs to be switched to a backup primary data source within seconds; and during nighttime batch processing tasks, analytical traffic needs to be switched to an offline data source to avoid impacting online business.
[0005] Existing solutions that rely on client-side routing frameworks, such as Sharding-JDBC, require explicitly defining the connection target object for each called method or class within the code, which limits the ability to dynamically switch and prevents the application from scheduling in the horizontal direction. Summary of the Invention
[0006] In view of this, the present disclosure provides a method, apparatus, device and medium for dynamically loading data sources, in order to solve the problem in the prior art that the connection target object of each calling method or class needs to be explicitly defined in the code, which limits the ability to dynamically switch and causes the application to be unable to schedule in the horizontal direction.
[0007] A first aspect of this disclosure provides a method for dynamically loading a data source. The method includes: in response to the startup of a business application, enabling a DFlow loading device, triggering the Spring Boot framework to load a DFlow auto-configuration class, and controlling the DFlow auto-configuration class to initialize core components including an initializer, a configuration provider, a connection request processor, and a data source proxy; integrating the DFlow loading device with the business application based on the initializer, configuration provider, connection request processor, and data source proxy; in response to receiving a call request for a business method, controlling the non-intrusive logic interception aspect of the DFlow loading device to intercept the call request; controlling the non-intrusive logic interception aspect of the DFlow loading device to allow the call request to the transparent data source object of the DFlow loading device according to a preset allowance rule; controlling the transparent data source object of the DFlow loading device to obtain a data source instance; and executing the business method based on the data source instance.
[0008] A second aspect of this disclosure provides a loading device for dynamically loading data sources. The device includes: an initialization unit configured to, in response to the startup of a business application, enable the DFlow loading device, trigger the Spring Boot framework to load the DFlow auto-configuration class, and control the DFlow auto-configuration class to initialize core components including an initializer, a configuration provider, a connection request processor, and a data source proxy; an integration unit configured to integrate the DFlow loading device with the business application based on the initializer, configuration provider, connection request processor, and data source proxy; an interception unit configured to, in response to receiving a call request for a business method, control the non-intrusive logic interception aspect of the DFlow loading device to intercept the call request; a release unit configured to, according to a preset release rule, control the non-intrusive logic interception aspect of the DFlow loading device to release the call request to the transparent data source object of the DFlow loading device; an acquisition unit configured to control the transparent data source object of the DFlow loading device to acquire a data source instance; and an execution unit configured to, based on the data source instance, execute the business method.
[0009] A third aspect of this disclosure provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described above.
[0010] A fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.
[0011] The beneficial effects of this disclosed embodiment compared to the prior art are as follows: First, in response to the startup of the business application, the DFlow loading device is enabled, triggering the Spring Boot framework to load the DFlow auto-configuration class, and controlling the initialization of the core components including the initializer, configuration provider, connection request processor, and data source proxy of the DFlow auto-configuration class. Second, the DFlow loading device is integrated with the business application based on the initializer, configuration provider, connection request processor, and data source proxy. Then, in response to receiving a call request for a business method, the non-intrusive logic interception aspect of the DFlow loading device is controlled to intercept the call request. Next, according to preset allowance rules, the non-intrusive logic interception aspect of the DFlow loading device allows the call request to the transparent data source object of the DFlow loading device. Then, the transparent data source object of the DFlow loading device is controlled to obtain a data source instance. Finally, the business method is executed based on the data source instance. This disclosure enables the DFlow loading device and triggers the Spring Boot framework's auto-configuration. Relying on core components such as initializers and configuration providers, it achieves non-intrusive integration with business applications. By combining non-intrusive logic interception aspects and transparent data source objects, it realizes dynamic loading and switching of data sources. It can flexibly adapt to the scheduling needs of multiple data sources without modifying business code. At the same time, with the centralized configuration management and dynamic connection pool control capabilities of the DFlow loading device, it not only supports automated data source scheduling when the application is horizontally scaled, but also ensures seamless switching of business processes and system stability, significantly improving the scheduling flexibility and operational efficiency under a multi-data source architecture. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a schematic diagram of an application scenario of a method for dynamically loading data sources according to some embodiments of this disclosure;
[0014] Figure 2 This is a flowchart of some embodiments of the dynamic loading data source loading method according to this disclosure;
[0015] Figure 3 These are structural block diagrams of some embodiments of the DFlow loading apparatus according to this disclosure;
[0016] Figure 4This is a flowchart of some embodiments of the application startup phase of the dynamic data source loading method according to this disclosure;
[0017] Figure 5 This is a flowchart of some embodiments of the business processing stage of the dynamic data source loading method according to this disclosure;
[0018] Figure 6 This is a schematic diagram of the structure of some embodiments of the loading device for dynamically loading data sources according to this disclosure;
[0019] Figure 7 This is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. Detailed Implementation
[0020] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0021] It should also be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. Unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other.
[0022] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0023] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0024] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0025] This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0026] Figure 1 This is a schematic diagram of an application scenario of a method for dynamically loading data sources according to some embodiments of this disclosure.
[0027] exist Figure 1In the application scenario, firstly, in response to the startup of the business application, the computing device 101 can enable the DFlow loading device, triggering the Spring Boot framework to load the DFlow auto-configuration class 102, and controlling the DFlow auto-configuration class 102 to initialize the core components including the initializer 103, configuration provider 104, connection request processor 105, and data source proxy 106. Secondly, the computing device 101 can integrate the DFlow loading device with the business application based on the initializer 103, configuration provider 104, connection request processor 105, and data source proxy 106, as shown in Figure 107. Then, in response to receiving a call request from a business method, the computing device 101 can control the non-intrusive logic interception aspect of the DFlow loading device to intercept the call request 108. Then, the computing device 101 can control the non-intrusive logic interception aspect of the DFlow loading device to allow the call request to the transparent data source object 109 of the DFlow loading device according to preset allowance rules. Afterwards, the computing device 101 can control the transparent data source object 109 of the DFlow loading device to obtain the data source instance 1010. Finally, the computing device 101 can execute business methods based on the data source example 1010, as shown in the attached diagram 1011.
[0028] It should be noted that the aforementioned computing device 101 can be either hardware or software. When the computing device 101 is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device 101 is software, it can be installed in the hardware devices listed above. It can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are made here.
[0029] It should be understood that Figure 1 The number of computing devices shown is merely illustrative. Any number of computing devices can be used depending on implementation needs.
[0030] Figure 2 This is a flowchart of some embodiments of the dynamic loading method for data sources according to this disclosure. Figure 2 The dynamic loading method of the data source can be determined by Figure 1 The computing device 101 performs the operation. For example... Figure 2 As shown, the method for loading the dynamically loaded data source includes:
[0031] Step S201: In response to the startup of the business application, the DFlow loading device is enabled, triggering the Spring Boot framework to load the DFlow auto-configuration class, and controlling the initialization of the core components including the initializer, configuration provider, connection request processor and data source proxy in the DFlow auto-configuration class.
[0032] In some embodiments, this disclosure achieves horizontal automation by centrally managing configurations on the server side and dynamically managing data sources connected to the application through a message middleware; the DFlow loading device of this disclosure is a data source middleware based on a C / S architecture, and its overall architecture is as follows: Figure 3 As shown, the client is responsible for obtaining data source configuration, requesting connections, creating data source objects, receiving server instructions and executing corresponding operations, and reporting heartbeats and monitoring data to the server. The server provides a data source configuration query interface, processes data source connection requests, provides a dynamic configuration interface, supports command broadcasting, maintains data source status information, and is responsible for connection recycling. The client maintains data source information and the mapping relationship between applications and data sources, and provides monitoring data display functionality. The message middleware (MQ / Redis / others) acts as a message bus for communication and data exchange between the client and the server.
[0033] During the application startup phase, such as Figure 4 As shown, the business application starts and enables the DFlow loader using the `@EnableDFlowDataSource` annotation. Spring Boot loads the DFlow loader's autoconfiguration class (`DFlowAutoConfiguration`). This autoconfiguration class initializes the core components of DFlow, preparing for subsequent processes. These core components include: the initializer, configuration provider, connection request handler, and data source proxy.
[0034] Step S202: Integrate the DFlow loading device with the business application based on the initializer, configuration provider, connection request processor and data source agent.
[0035] In some embodiments, step S202 further includes: controlling the initializer to call the configuration provider to receive the data source configuration list returned by the server and parse it to obtain a valid configuration; controlling the initializer to connect to the connection request processor, send a connection request to the server according to the valid configuration, receive the connection success result returned by the server and synchronize it to the initializer; controlling the initializer to call the data source proxy, create a data source instance and build an internal association object, and register the data source instance as a data source node in the Spring container to complete the integration of the DFlow loading device with the business application.
[0036] like Figure 4 As shown, during the configuration pull phase, the initializer is invoked to begin processing the data source configuration.
[0037] The configuration provider (policy pattern) resolves configurations from multiple sources, such as application name, configuration file, and local.
[0038] It should be noted that if remote configuration is required, a request is sent to the DFlow loading device interface service to obtain the data source configuration list. Finally, the parsed and valid configuration is returned to the initializer.
[0039] During the connection request phase, a connection request processor using the strategy pattern dynamically adapts to different connection logics. A connection is requested via ApplyHandler, and a connection request is sent to the DFlow loading device interface service. The interface service returns the request result (success or failure) and synchronizes the status with the initializer.
[0040] During the data source creation phase, a data source proxy using the strategy pattern encapsulates the creation and operation of the data source. Then, a data source instance is created through DataSourceProxy, and the associated objects within the DFlow loading mechanism are constructed. Finally, the data source is registered as a Spring Bean for business use.
[0041] Finally, Spring Boot notifies the application: startup complete, DFlow loader successfully integrated, data source available.
[0042] Step S203: In response to receiving a call request for a business method, control the non-intrusive logic interception aspect of the DFlow loading device to intercept the call request.
[0043] In some embodiments, the non-intrusive logic interception aspect is the AOP aspect.
[0044] Step S204: According to the preset release rules, the non-intrusive logic of the DFlow loading device is controlled to intercept the aspect and release the call request to the transparent data source object of the DFlow loading device.
[0045] In some embodiments, step S204 further includes the following steps: controlling the non-intrusive logic interception aspect of the DFlow loading device to check whether there is a DFlow annotation and the corresponding annotation parser; if not, controlling the non-intrusive logic interception aspect to directly allow the call request to the transparent data source object of the DFlow loading device.
[0046] In one exemplary embodiment of this application, after the non-intrusive logic interception aspect of the DFlow loading device checks whether the DFlow annotation and the corresponding annotation parser exist, the method further includes: if they exist, controlling the annotation parser to parse the target data source name, and controlling the non-intrusive logic interception aspect to query whether the data source node corresponding to the target data source has been registered in the Spring container; if they are not registered, controlling the non-intrusive logic interception aspect to directly allow the call request to the transparent data source object of the DFlow loading device.
[0047] In one exemplary embodiment of this application, after controlling the non-intrusive logic to intercept aspect queries to check whether the data source node corresponding to the target data source has been registered in the Spring container, the above method further includes:
[0048] If already registered, the node name of the data source node corresponding to the target data source is written into the local storage object, and the non-intrusive logic is controlled to intercept the aspect and allow the call request to the transparent data source object of the DFlow loading device.
[0049] Here, as Figure 5 As shown, the business processing flow is as follows: The non-intrusive logic interception aspect controlling the DFlow loading device checks whether the DFlow annotation and its corresponding annotation parser exist. If not found, the business method is executed directly, bypassing the data source logic of the DFlow loading device. Conversely, if found, the annotation processing flow is entered. The annotation parser resolves the target data source name based on the annotation content (e.g., @DFlowJson). Then, the non-intrusive logic interception aspect searches for whether the data source node is already registered in DFlow based on the name. If not found, the business method continues execution, using the default data source. If found, the dynamic data source switching flow is entered. Afterward, the target node name is written to the local storage object ThreadLocal as the data source context for the current thread. The aspect then allows execution, the business method continues, and getConnection() is subsequently called.
[0050] Step S205: Control the transparent data source object of the DFlow loading device to obtain the data source instance.
[0051] In some embodiments, such as Figure 5 As shown, the transparent data source object DFlowDataSource checks ThreadLocal. If it is empty, it determines the default data source. If a default data source is configured, it returns the default data source name; otherwise, it throws a "data source not found" exception, and the process ends. Otherwise, if it is not empty, it retrieves the node name and enters the dynamic data source logic. Based on the node name, it retrieves the data source instance from the cache: if the data source instance is not initialized, it calls initConnection() to create and initialize the connection pool; otherwise, if the data source instance is initialized, it directly obtains a connection from the connection pool.
[0052] Step S206: Execute the business method according to the data source example.
[0053] In some embodiments, after executing the business method according to the data source example, the above method further includes: controlling non-intrusive logic interception aspect to clean up node names in local storage objects.
[0054] Here, according to the above process, a Connection is returned to the business method to execute the business logic. After the business method finishes executing, a non-intrusive logic interception aspect is returned. The non-intrusive logic interception aspect cleans up the ThreadLocal to prevent thread pollution. At this point, the process ends.
[0055] The beneficial effects of this disclosed embodiment compared to the prior art are as follows: First, in response to the startup of the business application, the DFlow loading device is enabled, triggering the Spring Boot framework to load the DFlow auto-configuration class, and controlling the initialization of the core components including the initializer, configuration provider, connection request processor, and data source proxy of the DFlow auto-configuration class. Second, the DFlow loading device is integrated with the business application based on the initializer, configuration provider, connection request processor, and data source proxy. Then, in response to receiving a call request for a business method, the non-intrusive logic interception aspect of the DFlow loading device is controlled to intercept the call request. Next, according to preset allowance rules, the non-intrusive logic interception aspect of the DFlow loading device allows the call request to the transparent data source object of the DFlow loading device. Then, the transparent data source object of the DFlow loading device is controlled to obtain a data source instance. Finally, the business method is executed based on the data source instance. This disclosure enables the DFlow loading device and triggers the Spring Boot framework's auto-configuration. Relying on core components such as initializers and configuration providers, it achieves non-intrusive integration with business applications. By combining non-intrusive logic interception aspects and transparent data source objects, it realizes dynamic loading and switching of data sources. It can flexibly adapt to the scheduling needs of multiple data sources without modifying business code. At the same time, with the centralized configuration management and dynamic connection pool control capabilities of the DFlow loading device, it not only supports automated data source scheduling when the application is horizontally scaled, but also ensures seamless switching of business processes and system stability, significantly improving the scheduling flexibility and operational efficiency under a multi-data source architecture.
[0056] All of the above-mentioned optional technical solutions can be combined in any way to form optional embodiments of this disclosure, and will not be described in detail here.
[0057] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein. For details not disclosed in the apparatus embodiments of this disclosure, please refer to the embodiments of the method disclosed herein.
[0058] Figure 6 These are schematic diagrams illustrating the structure of some embodiments of the loading apparatus for dynamically loading data sources according to this disclosure. For example... Figure 6As shown, the dynamic data source loading device includes: an initialization unit 601, configured to enable the DFlow loading device in response to the startup of a business application, trigger the Spring Boot framework to load the DFlow auto-configuration class, and control the initialization of the core components including an initializer, configuration provider, connection request processor, and data source proxy. An integration unit 602 is configured to integrate the DFlow loading device with the business application based on the initializer, configuration provider, connection request processor, and data source proxy. An interception unit 603 is configured to control the non-intrusive logic interception aspect of the DFlow loading device to intercept the call request in response to a received business method call request. A release unit 604 is configured to control the non-intrusive logic interception aspect of the DFlow loading device to release the call request to the transparent data source object of the DFlow loading device according to preset release rules. An acquisition unit 605 is configured to control the transparent data source object of the DFlow loading device to acquire a data source instance. An execution unit 606 is configured to execute the business method based on the data source instance.
[0059] In some optional implementations of certain embodiments, the integration unit 602 is configured to: control the initializer to call the configuration provider to receive the data source configuration list returned by the server and parse it to obtain a valid configuration; control the initializer to connect to the connection request processor, send a connection request to the server according to the valid configuration, receive the connection success result returned by the server and synchronize it to the initializer; control the initializer to call the data source proxy, create a data source instance and build an internal association object, and register the data source instance as a data source node in the Spring container to complete the integration of the DFlow loading device and the business application.
[0060] In some optional implementations of certain embodiments, the release unit 604 is configured to: control the non-intrusive logic interception aspect of the DFlow loading device to check whether there is a DFlow annotation and the corresponding annotation parser; if not, control the non-intrusive logic interception aspect to directly release the call request to the transparent data source object of the DFlow loading device.
[0061] In some optional implementations of certain embodiments, after the non-intrusive logic interception aspect of the DFlow loading device checks whether the DFlow annotation and its corresponding annotation parser exist, the device is further configured to perform the following steps: if they exist, the annotation parser is controlled to parse the target data source name, and the non-intrusive logic interception aspect is controlled to query whether the data source node corresponding to the target data source has been registered in the Spring container; if not registered, the non-intrusive logic interception aspect is controlled to directly allow the call request to the transparent data source object of the DFlow loading device.
[0062] In some optional implementations of some embodiments, after the control non-intrusive logic interception aspect queries whether the data source node corresponding to the target data source has been registered in the Spring container, the above device is further used to perform the following steps: if it has been registered, the node name of the data source node corresponding to the target data source is written into the local storage object, and the control non-intrusive logic interception aspect allows the call request to the transparent data source object of the DFlow loading device.
[0063] In some optional implementations of certain embodiments, if the DFlow annotation and its corresponding annotation parser do not exist, or if the DFlow annotation and its corresponding annotation parser exist but the data source node corresponding to the target data source in the Spring container is not registered, the data source instance corresponds to the default data source; if the DFlow annotation and its corresponding annotation parser exist and the data source node corresponding to the target data source in the Spring container is registered, the data source instance corresponds to the target data source.
[0064] In some alternative implementations of certain embodiments, after execution unit 606, the above-described apparatus is further configured to perform the following step: controlling non-intrusive logic interception aspect to clean up node names in local storage objects.
[0065] The following is for reference. Figure 7 It illustrates electronic devices suitable for implementing some embodiments of this disclosure (e.g., Figure 1 A schematic diagram of the structure of computing device 101) 700. Figure 7 The server shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0066] like Figure 7 As shown, the electronic device 700 may include a processing unit (e.g., a central processing unit, a graphics processor, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the electronic device 700. The processing unit 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0067] Typically, the following devices can be connected to I / O interface 705: input devices 706 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 707 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 708 including, for example, magnetic tapes, hard disks, etc.; and communication devices 709. Communication device 709 allows electronic device 700 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 700 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 7 Each box shown can represent a device or multiple devices as needed.
[0068] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 709, or installed from storage device 708, or installed from ROM 702. When the computer program is executed by processing device 701, it performs the functions defined in the methods of some embodiments of this disclosure.
[0069] It should be noted that, in some embodiments of this disclosure, the computer-readable medium described above may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0070] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0071] The aforementioned computer-readable medium may be included in the aforementioned device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: enable the DFlow loading device in response to the startup of a business application; trigger the Spring Boot framework to load the DFlow auto-configuration class; control the DFlow auto-configuration class to initialize the core components including the initializer, configuration provider, connection request handler, and data source proxy; integrate the DFlow loading device with the business application based on the initializer, configuration provider, connection request handler, and data source proxy; in response to receiving a business method call request, control the non-intrusive logic interception aspect of the DFlow loading device to intercept the call request; control the non-intrusive logic interception aspect of the DFlow loading device to allow the call request to the transparent data source object of the DFlow loading device according to preset allowance rules; control the transparent data source object of the DFlow loading device to obtain a data source instance; and execute the business method based on the data source instance.
[0072] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0073] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0074] The units described in some embodiments of this disclosure can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor may be described as including an initialization unit, an integration unit, an interception unit, a release unit, an acquisition unit, and an execution unit. The names of these units do not necessarily limit the unit itself; for example, the initialization unit may also be described as "a unit that, in response to the startup of a business application, enables the DFlow loading device, triggers the Spring Boot framework to load the DFlow auto-configuration class, and controls the initialization of the DFlow auto-configuration class, including core components such as an initializer, a configuration provider, a connection request processor, and a data source proxy."
[0075] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0076] The above description is merely a selection of preferred embodiments of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.
Claims
1. A method for dynamically loading data sources, characterized in that, The method includes: In response to the startup of business applications, the DFlow loading device is enabled, which triggers the Spring Boot framework to load the DFlow auto-configuration class and controls the initialization of the core components of the DFlow auto-configuration class, including the initializer, configuration provider, connection request processor and data source proxy. The DFlow loading device is integrated with business applications based on the initializer, configuration provider, connection request processor, and data source agent. In response to receiving a call request for a business method, the non-intrusive logic interception aspect of the DFlow loading device intercepts the call request; According to the preset release rules, the non-intrusive logic of the DFlow loading device intercepts and allows the aspect to release the call request to the transparent data source object of the DFlow loading device; The transparent data source object controlling the DFlow loading device obtains a data source instance; Execute the business method based on the data source example.
2. The method for dynamically loading data sources according to claim 1, characterized in that, The integration of the DFlow loading device with the business application based on the initializer, configuration provider, connection request processor, and data source agent includes: The control initializer calls the configuration provider to receive the data source configuration list returned by the server and parses it to obtain the valid configuration; The control initializer connects to the connection request processor, sends a connection request to the server according to the valid configuration, receives the connection success result returned by the server and synchronizes it to the initializer; The control initializer calls the data source proxy, creates a data source instance and builds internal associated objects, and registers the data source instance as a data source node in the Spring container to complete the integration of the DFlow loading device with the business application.
3. The method for dynamically loading data sources according to claim 1, characterized in that, The non-intrusive logic that controls the DFlow loading device according to preset release rules to intercept aspect-based release call requests to the transparent data source object of the DFlow loading device includes: The non-intrusive logic intercepts the aspect that controls the DFlow loading device to check for the existence of DFlow annotations and their corresponding annotation parsers. If it does not exist, the non-intrusive control logic intercepts the aspect, which directly allows the call request to the transparent data source object of the DFlow loading device.
4. The method for dynamically loading data sources according to claim 3, characterized in that, After the non-intrusive logic interception aspect controlling the DFlow loading device checks for the existence of DFlow annotations and their corresponding annotation parsers, the method further includes: If it exists, the annotation parser will then parse it to obtain the target data source name. Control non-intrusive logic to intercept aspect queries to check whether the data source node corresponding to the target data source has been registered in the Spring container; If not registered, the non-intrusive logic intercepts the aspect and directly allows the call request to the transparent data source object of the DFlow loading device.
5. The method for dynamically loading data sources according to claim 4, characterized in that, After controlling the non-intrusive logic to intercept aspect queries to check whether the data source node corresponding to the target data source has been registered in the Spring container, the method further includes: If already registered, the node name of the data source node corresponding to the target data source is written into the local storage object, and the non-intrusive logic is controlled to intercept the aspect and allow the call request to the transparent data source object of the DFlow loading device.
6. The method for dynamically loading data sources according to claim 5, if the DFlow annotation and its corresponding annotation parser do not exist, or if the DFlow annotation and its corresponding annotation parser exist, but the data source node corresponding to the target data source in the Spring container is not registered, the data source instance corresponds to the default data source; if the DFlow annotation and its corresponding annotation parser exist, and the data source node corresponding to the target data source in the Spring container has been registered, the data source instance corresponds to the target data source.
7. The method for dynamically loading a data source according to claim 5, after executing the business method according to the data source example, the method further includes: Control non-intrusive logic to intercept aspects and clean up node names in local storage objects.
8. A loading device for dynamically loading data sources, characterized in that, The device includes: The initialization unit is configured to respond to the startup of the business application, enable the DFlow loading device, trigger the Spring Boot framework to load the DFlow auto-configuration class, and control the initialization of the core components of the DFlow auto-configuration class, including the initializer, configuration provider, connection request processor and data source proxy. The integration unit is configured to integrate the DFlow loading device with business applications based on the initializer, configuration provider, connection request processor and data source agent; The interception unit is configured to intercept the call request by controlling the non-intrusive logic interception aspect of the DFlow loading device in response to the received call request for a business method. The release unit is configured to control the non-intrusive logic of the DFlow loading device to intercept aspect release call requests to the transparent data source object of the DFlow loading device according to preset release rules; The acquisition unit is configured to control the transparent data source object of the DFlow loading device to acquire data source instances; The execution unit is configured to execute business methods based on the data source example.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-7.