Disclosure of Invention
In view of the above, the present invention provides a data interfacing method, apparatus and computer readable storage medium.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, an embodiment provides a data docking method applied to a data docking system, where the method includes:
receiving data to be sent;
acquiring a transmission protocol of a sending object and a transmission protocol of a receiving object of the data to be sent;
and when the transmission protocol of the sending object is not matched with the transmission protocol of the receiving object, calling a plug-in to convert the data to be sent into target data supporting the transmission protocol of the receiving object, and sending the target data to the receiving object so as to complete data docking.
In an optional embodiment, the data docking system includes plug-ins respectively corresponding to transmission protocols, and the invoking plug-ins convert the data to be sent into target data supporting the transmission protocol of the received object, including:
finding out a first plug-in corresponding to the transmission protocol of the sending object and finding out a second plug-in corresponding to the transmission protocol of the receiving object;
analyzing the data to be sent based on the first plug-in to obtain the data content of the data to be sent and transmitting the data content to the second plug-in;
and converting the data content into target data supporting a transmission protocol of the receiving object based on the second plug-in.
In an alternative embodiment, each plug-in corresponding to each transport protocol is added to the data docking system by:
acquiring a plug-in correspondingly developed aiming at each transmission protocol;
adding the developed plug-in to the data docking system, and adding the information of the developed plug-in a registration file of the data docking system.
In an alternative embodiment, the method further comprises: and modifying the states of the first plugin and the second plugin in the registration file into starting, so that when the registration file is scanned, the first plugin and the second plugin are called through a java reflection technology to carry out data docking.
In an optional embodiment, when scanning the registration file, invoking the first plugin and the second plugin for data interfacing through a java reflection technology, includes:
loading the registration file from the data docking system, and analyzing the content in the registration file to obtain the first plugin and the second plugin which are in an open state;
and loading a corresponding code as a docking code according to the information of the first plug-in and the information of the second plug-in by using a java reflection technology, starting the docking code, and further performing data docking by using a Spring technology.
In an optional embodiment, invoking a plug-in to convert the data to be sent into target data supporting a transmission protocol of the received object includes:
judging whether the data to be sent needs to be filtered and screened, if so, filtering and screening the data to be sent according to set conditions, and calling a plug-in to convert the filtered and screened data into target data of a transmission protocol supporting the receiving object; if not, directly calling a plug-in to convert the data to be sent into target data of a transmission protocol supporting the receiving object.
In a second aspect, an embodiment provides a data interfacing apparatus, which is applied to a data interfacing system, and the data interfacing apparatus includes:
the data receiving module is used for receiving data to be sent;
a protocol acquisition module, configured to acquire a transmission protocol of a transmission object and a transmission protocol of a reception object of the data to be transmitted;
and the data docking module is used for calling a plug-in to convert the data to be sent into target data supporting the transmission protocol of the receiving object when the transmission protocol of the sending object is not matched with the transmission protocol of the receiving object, and sending the target data to the receiving object so as to complete data docking.
In an optional embodiment, the data docking system includes plug-ins corresponding to transmission protocols, the data docking module is configured to find a first plug-in corresponding to the transmission protocol of the sending object, find a second plug-in corresponding to the transmission protocol of the receiving object, analyze the data to be sent based on the first plug-in, obtain data content of the data to be sent and transmit the data content to the second plug-in, and convert the data content into target data supporting the transmission protocol of the receiving object based on the second plug-in.
In an alternative embodiment, each plug-in corresponding to each transport protocol is added to the data docking system by: and acquiring the plug-ins correspondingly developed aiming at each transmission protocol, adding the developed plug-ins into the data docking system, and adding the information of the developed plug-ins into the registration files of the data docking system.
In a third aspect, embodiments provide a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the data interfacing method as described in any one of the preceding embodiments.
According to the data docking method, the data docking device and the computer-readable storage medium provided by the embodiment of the invention, when the transmission protocol of the sending object is not matched with the transmission protocol of the receiving object, the plug-in is called to convert the data to be sent into the target data of the transmission protocol supporting the receiving object, and the target data is sent to the receiving object, so that data docking is realized, and the realization is convenient.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It is noted that relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
It should be noted that the features of the embodiments of the present invention may be combined with each other without conflict.
Referring to fig. 1, a flowchart of a data docking method according to an embodiment of the present invention is shown, where the data docking method is applied to a data docking system, and the data docking method includes S110, S120, and S130.
S110, receiving data to be transmitted.
S120, acquiring the transmission protocol of the sending object and the transmission protocol of the receiving object of the data to be sent.
S130, when the transmission protocol of the sending object is not matched with the transmission protocol of the receiving object, calling a plug-in to convert the data to be sent into target data supporting the transmission protocol of the receiving object, and sending the target data to the receiving object to complete data butt joint.
In the embodiment of the invention, when the transmission protocol of the sending object is not matched with the transmission protocol of the receiving object, the plug-in is called to convert the data to be sent into the target data supporting the transmission protocol of the receiving object, and the target data is sent to the receiving object, so that the data docking is conveniently realized.
By adopting the data docking scheme, the data docking is completed by calling the plug-in, so that the plug-in development can be performed only aiming at different points of a transmission protocol and different docking modes based on a plug-in development framework, and the development complexity is reduced. By adopting a plug-in development framework, different plug-ins corresponding to different transmission protocols are developed and added to the data docking system, and for transmitting objects supporting different transmission protocols and receiving objects supporting different transmission protocols, different transmitting objects and different receiving objects can be docked only by switching different plug-ins based on the same data docking system, so that the adaptability is high.
For example, referring to fig. 2, an exemplary application scenario diagram for invoking a plug-in to convert data to be sent into target data supporting a transmission protocol of a receiving object when the transmission protocol of the sending object and the transmission protocol of the receiving object are not matched is provided in an embodiment of the present invention. As shown in fig. 2, for a transmitting object and a receiving object whose transmission protocols do not match, data is transmitted from the transmitting object to the receiving object through the data interfacing system in the middle. In the data docking system, a first plug-in used for docking a sending object and a second plug-in used for docking a receiving object are called, and data transmission from the sending object to the receiving object is achieved through the first plug-in and the second plug-in. The first plug-in and the second plug-in are plug-in modules in the data docking system, and different plug-ins can be flexibly developed for data docking according to protocol documents and docking modes of different objects. Accordingly, each plug-in corresponding to each transmission protocol can be included in the data docking system. Referring to fig. 3, the step S130 of calling the plug-in to convert the data to be transmitted into the target data supporting the transmission protocol of the received object may be implemented through steps S131 to S133.
S131, finding out a first plug-in corresponding to the transmission protocol of the sending object, and finding out a second plug-in corresponding to the transmission protocol of the receiving object.
S132, analyzing the data to be sent based on the first plug-in, obtaining the data content of the data to be sent, and transmitting the data content to the second plug-in.
S133, converting the data content into target data supporting a transmission protocol of the receiving object based on the second plug-in.
Wherein each plug-in respectively corresponding to each transport protocol may be added to the data docking system by: and acquiring the plug-ins correspondingly developed aiming at each transmission protocol, adding the developed plug-ins into the data docking system, and adding the information of the developed plug-ins into the registration files of the data docking system. Based on the application scenario shown in fig. 2, in a case that the first plugin and the second plugin are selected to be invoked to implement transmission of data from a sending object to a receiving object, the states of the first plugin and the second plugin are modified to be started in the registration file, so that when the registration file is scanned, the first plugin and the second plugin are invoked by a java reflection technology to perform data interfacing. For example, the registration file may be loaded from the data docking system, the content in the registration file may be analyzed to obtain the first plugin and the second plugin in the opened states, a java reflection technology is used, a corresponding code is loaded according to the information of the first plugin and the information of the second plugin, the code is used as a code for docking, the code for docking is started, and then a Spring technology is used for data docking.
In the running state, the java reflection technology can know all the properties and methods of any entity class. Any method and property can be called for any object. This function of dynamically acquiring information and dynamically invoking object methods is also referred to as the reflection mechanism of the java language. Spring is an open source framework, a lightweight Control Inversion (IoC) and cut-Oriented Programming (AOP) container framework.
The data docking system in the embodiment of the invention is realized by adopting a java reflection technology and Spring, when the data docking system is started, the plug-in registration file is scanned, the required data docking can be called through the java reflection technology, the required data docking is developed based on the Spring technology, and the realization is more convenient.
According to the difference between the transmission protocol of the sending object and the transmission protocol of the receiving object, and the difference between the data required by the sending object and the data required by the receiving object, operations such as filtering and screening the data may be performed, and accordingly, invoking the plug-in S130 to convert the data to be sent into the target data supporting the transmission protocol of the receiving object may include: and judging whether the data to be sent needs to be filtered and screened, if so, filtering and screening the data to be sent according to set conditions, and calling a plug-in to convert the filtered and screened data into target data of a transmission protocol supporting the receiving object. If not, directly calling a plug-in to convert the data to be sent into target data of a transmission protocol supporting the receiving object.
In the embodiment of the present invention, the sending object and the receiving object do not refer to a certain sending object and receiving object, but refer to any group of sending object and receiving object that are not matched in transmission protocol but need data interfacing. Accordingly, the first plug-in is not limited to a plug-in corresponding to a transport protocol of a certain transmission object, and may refer broadly to any plug-in corresponding to a transport protocol of a different transmission object. The second plug-in is not limited to a plug-in corresponding to a transmission protocol of a certain receiving object, and may broadly refer to any plug-in corresponding to a transmission protocol of a different receiving object.
In order to more clearly illustrate the implementation principle of the embodiment of the present invention, the following scenario is illustrated as an example.
Assuming that the sending object is a lower domain (manufacturer), the receiving object is an upper domain (manufacturer), the transmission protocol of the lower domain is not matched with the transmission protocol of the upper domain, the data docking system comprises various plugins respectively corresponding to the transmission protocols, and each plugin comprises a lower domain plugin corresponding to the transmission protocol of the lower domain and an upper domain plugin corresponding to the transmission protocol of the upper domain. The data docking system realizes data docking between an upper domain and a lower domain through an upper domain docking module including an upper domain plug-in and a lower domain docking module including a lower domain plug-in.
Referring to fig. 4, an exemplary structural block diagram of a data docking system is provided in an embodiment of the present invention. As shown in fig. 4, the data docking system includes a plug-in selection module, a lower domain docking module, and an upper domain docking module. The lower domain docking module and the upper domain docking module respectively comprise a data transmission module, a protocol module, a data auxiliary module and a data circulation module.
Wherein, the plug-in selection module is responsible for selecting different protocols to process data interfacing. According to different protocols, after corresponding plug-ins are developed, the plug-ins are added into a data docking system, then information of the plug-ins is added into a registration file of the data docking system, if the plug-ins need to be selected for docking, the starting state of the plug-ins is modified into starting in the registration file, and after the data docking system is started, a plug-in selection module scans the registration file, so that the plug-ins for docking are started, and the data docking system can be used more flexibly.
The protocol module is a module (which may be understood as the above-mentioned plug-in, such as the upper domain plug-in and the lower domain plug-in) to be developed in the data docking system, and is developed for the transport protocols of the upper domain and the lower domain, the development content is mainly to process and convert data according to the difference of the transport protocols of the upper domain and the lower domain, the middle involves analyzing the data according to the transport protocol of the lower domain, and correspondingly converting the data according to the transport protocol of the upper domain. And in the actual docking there are two cases:
in the first case, the data docking system provider is a subordinate domain manufacturer, the subordinate domain plugin is equivalent to a fixed module, and the subordinate domain plugin performs data interaction with an internal system of the subordinate domain manufacturer. When data docking is carried out, data docking of the lower domain and the upper domain can be completed only by developing a protocol module in the upper domain plug-in.
And in the second situation, the data docking system provider is a superior domain manufacturer, the superior domain plugin is equivalent to a fixed module, and the superior domain plugin performs data interaction with an internal system of the superior domain manufacturer. When data docking is carried out, data docking of the lower domain and the upper domain can be completed only by developing a protocol module in the lower domain plug-in.
The data transmission module in the lower domain docking module can be regarded as a receiving module, and is mainly used for developing a transmission mode for the lower domain, docking data of the lower domain into the data docking system, receiving data sent by the lower domain for the data docking system, or actively acquiring the data of the lower domain, and performing next data docking processing after receiving the data in the module.
The data transmission module in the upper domain docking module can be regarded as a sending module and is mainly used for developing a transmission mode of the upper domain and sending data processed by the protocol module to the upper domain. The Transmission mode related to the module may be various, for example, http (hypertext transfer Protocol), web service, TCP (Transmission Control Protocol), and the like.
The data circulation module is used for converting and processing the data of the upper domain and the lower domain. According to the difference of the transmission protocols of the upper domain and the lower domain and the difference of the required data, the operations of filtering, screening and the like of the data can be completed in the data circulation module. For example, the data enters the data circulation module after being converted by the protocol module in the lower domain docking module, if operations such as filtering and screening are required, the data can be filtered and screened under specified conditions in the data circulation module, and after passing through the data circulation module, the data enters the protocol module in the upper domain docking module for continuous processing.
The data auxiliary module may include tools of various docking modes such as FTP (File Transfer Protocol), MQ (message queue), Web Service, http, TCP, and the like, may assist in rapid development when developing the data transmission module, and provide ready tools for auxiliary processing such as code conversion, encryption/decryption, time format conversion, and the like, which may be involved in the development of the Protocol module, thereby improving convenience of the development of the Protocol module.
The data docking system shown in fig. 4 may be implemented using java reflection technology and Spring. And scanning the registration file when the data docking system is started, and calling the required data through a java reflection technology for docking. Due to the fact that the lightweight of the Spring development framework and the IoC control reversal are convenient to manage and test, the framework is mature, the use of developers is not obstructed, Spring MVC and front-end technology can be integrated, and the technology is ecological. The interfacing of the required data may be developed based on Spring technology.
The registry file may be in XML (Extensible Markup Language) format, and may include the following definitions, < Protocol >: defining a Protocol, and paralleling a plurality of < Protocol > by a plurality of different plug-ins; in the < CLass >, Java reflects the called CLass path, and the CLass is called by reflection after the file is read; < project name > docking name; < Status > whether the plug-in is enabled for docking.
The plug-in selection module can realize plug-in calling in the following modes: and starting the data docking system, loading the registration file by the plug-in selection module after the data docking system is started, and analyzing the content in the registration file to obtain the information of the plug-in the state of opening. And loading a corresponding code according to the information of the plug-in analyzed from the registration file by using a java reflection technology, and starting the code. And loading the subsequent corresponding modules through the docking class started by java reflection, wherein a Spring technology is used, and the plug-in docking and starting are successful after the loading is finished.
Based on the above framework, in a scenario where a protocol module (upper domain plug-in) in an upper domain docking module and a protocol module (lower domain plug-in) in a lower domain docking module both need to be developed, a protocol module development process may be as follows: creating a com, demo, protocol, action, java plug-in starting class, calling the class through reflection, and then injecting other data docking methods in the module through Spring. And developing a protocol module in the lower-level domain docking module, and rapidly developing the lower-level domain data receiving and processing functions of the protocol module by using the data auxiliary module. And creating a data conversion class, and converting the data transmitted by the lower domain into the data protocol type of the upper domain. And developing a protocol module in the superior domain docking module, and developing a data transmission class by using the data auxiliary module according to the superior domain docking mode. And packaging the developed protocol module into a jar packet and adding the jar packet into the data docking system. Adding new plug-in information com.demo.protocol.action.java on the XML-format registration file, and setting the state to true. The docking development is completed by this point.
In a scenario that only the protocol module of the upper domain docking module or the protocol module of the lower domain docking module needs to be developed, the protocol module development process may be as follows: creating a com, demo, protocol, action, java plug-in starting class, calling the class through reflection, and then injecting other data docking methods in the module through Spring. When a protocol module of the upper domain docking module needs to be developed, the protocol module of the lower domain docking module can be developed into a fixed module which is fixed to be matched with a transmission protocol of the lower domain, and only the protocol module of the upper domain docking module needs to be developed for docking. When the protocol module of the lower-level domain docking module needs to be developed, the protocol module of the upper-level domain docking module can be developed into a fixed module which is fixed to be matched with the transmission protocol of the upper-level domain, and only the protocol module of the lower-level domain docking module needs to be developed for docking. The development process of the protocol module comprises the following steps: creating a data conversion class, converting lower domain data into a higher domain data protocol type, packaging a developed protocol module into a jar packet, adding the jar packet into a data docking system, adding new plug-in information com. The docking development is completed by this point.
Based on the data docking system shown in fig. 4, the data docking process in the corresponding scenario is as follows.
And calling a plug-in selection module, selecting plug-ins (the superior domain plug-ins and the inferior domain plug-ins) for docking from the plug-ins of the data docking system according to the transmission protocol of the superior domain and the transmission protocol of the inferior domain, and modifying the states of the selected superior domain plug-ins and the inferior domain plug-ins into a starting state.
And after the data docking system is started, the data docking system starts the selected superior domain plug-in and the subordinate domain plug-in and starts the data docking operation.
And acquiring the data from the lower domain to the data docking system through the data transmission module of the lower domain docking module, transmitting the data to the protocol module of the lower domain docking module, and analyzing the data in the protocol module according to the transmission protocol of the lower domain. In the parsing process, a data auxiliary module may be required to be used, and the tool provided by the data auxiliary module is used for performing operations such as encoding parsing, encryption and decryption.
The analyzed data enters the data circulation module and is transmitted to the upper domain docking module through internal data circulation, wherein the data circulation can be realized by adopting a queue, the data transmission can also be directly carried out, and the data circulation module can also carry out set condition filtering on the data according to requirements.
The protocol module of the superior domain docking module acquires data from the data flow module, converts the data according to the transmission protocol of the superior domain (the data auxiliary module may be used in the conversion), converts the data into a data format supported by the transmission protocol of the superior domain, and transmits the data format to the superior domain through the data transmission module in the superior domain docking module. According to different docking modes specified by the upper domain, the data transmission module in the upper domain docking module may correspondingly develop different sending modes, for example, sending modes such as http, web service, TCP, and the like may be included, and then the data is sent to the upper domain. Thereby completing the data interfacing.
It should be noted that, in the data docking system, the data transmission module, the data auxiliary module, and the data circulation module may be fixed modules that are common to all the plug-ins, and accordingly, development of plug-ins corresponding to different transmission protocols may be performed only on protocol modules, that is, the protocol modules are plug-ins in this embodiment. In another implementation manner, in the data docking system, the data auxiliary module and the data circulation module may also be fixed modules that are common to all the plug-ins, and accordingly, for the development of the plug-ins corresponding to different transmission protocols, the protocol module and the data transmission module may be developed, that is, the protocol module and the data transmission module constitute the plug-ins in this embodiment.
Referring to fig. 5, on the basis of the foregoing, an embodiment of the present invention further provides a data docking apparatus, which is applied to a data docking system, where the data docking apparatus includes: the device comprises a data receiving module, a protocol acquisition module and a data docking module.
The data receiving module is used for receiving data to be sent.
The protocol acquisition module is used for acquiring the transmission protocol of the sending object and the transmission protocol of the receiving object of the data to be sent.
The data docking module is used for calling a plug-in to convert the data to be sent into target data supporting the transmission protocol of the receiving object when the transmission protocol of the sending object is not matched with the transmission protocol of the receiving object, and sending the target data to the receiving object so as to complete data docking.
In an implementation manner, the data docking system includes plug-ins corresponding to transmission protocols, the data docking module is configured to find a first plug-in corresponding to the transmission protocol of the transmission object, find a second plug-in corresponding to the transmission protocol of the reception object, parse the data to be transmitted based on the first plug-in, obtain data content of the data to be transmitted and transmit the data content to the second plug-in, and convert the data content into target data supporting the transmission protocol of the reception object based on the second plug-in.
Optionally, each plug-in corresponding to each transport protocol is added to the data docking system by: and acquiring the plug-ins correspondingly developed aiming at each transmission protocol, adding the developed plug-ins into the data docking system, and adding the information of the developed plug-ins into the registration files of the data docking system.
It should be noted that the basic principle and the technical effect of the data docking device provided in the present embodiment are the same as those of the above method embodiment applied to the data docking system, and for the sake of brief description, no part of the present embodiment is mentioned, and reference may be made to the corresponding contents in the above method embodiment.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the data docking method described above.
Compared with the data docking scheme which is only applicable in the prior art, for example, a certain upper domain provides protocol documents and limited docking mode information to a certain lower domain, and the lower domain provides the provided documents and information to develop a corresponding data docking system, so that data docking of the upper domain and the lower domain is realized. The data docking scheme which is only single and suitable is characterized in that a data docking system needs to be re-developed aiming at different transmission protocols, development time consumption is long, the data docking system does not have a fixed development framework, development complexity is high, the data docking system is only developed aiming at a single superior domain protocol document and a docking mode, and applicability is poor. By adopting the data docking scheme provided by the embodiment of the invention, the plug-in development framework is adopted, and the plug-in development is only carried out aiming at different points of the protocol and different docking modes, so that the development complexity can be obviously reduced, the code development amount can be reduced, the time consumption of data docking development can be reduced, and the project cost can be saved. The method has the advantages that the rapid development can be realized, the consumed time is short, based on a plug-in type development framework, different upper-level domains and lower-level domains can be docked only by switching different plug-ins aiming at different transmission protocols, the adaptability is high, the docking is more flexible, and the docking stability is also higher.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.