Spring-based declarative ftp transmission method and apparatus
Through the Spring-based declarative FTP transmission method, dynamic proxy and plug-in extensions are used to solve the problems of insufficient FTP file synchronization capabilities and high code intrusion, and achieve efficient and flexible FTP function expansion and maintenance.
Patent Information
- Application Number
- PCT/CN2023/143185
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-13
- Filing Date
- 2023-12-29
- Publication Date
- 2024-10-31
AI Technical Summary
The existing technology has weak FTP file synchronization capabilities and is cumbersome to implement. It is difficult to quickly access third-party FTP systems to synchronize data. The native FTP client has weak functions and lacks breakpoint resume and encryption and decryption functions. The code is intrusive and complex. Low usability and high maintenance costs.
Adopts a declarative FTP transmission method based on Spring, generates core FTP code by defining interfaces and annotations, supports plug-in extensions, and uses dynamic proxies and Spring containers to implement low-intrusive and scalable FTP functions, including breakpoint resume and encryption and decryption. plugin.
It improves the iterative upgrade capability and functional scalability of the FTP system, reduces the intrusiveness of the code, simplifies the implementation of the FTP client, enhances the reliability and flexibility of file upload and download, and supports applications in scenarios with large amounts of data.
Smart Images

Figure CN2023143185_31102024_PF_FP_ABST
Abstract
Description
A declarative FTP transmission method and device based on Spring Technical Field
[0001] The present invention relates to the technical field of network file security, and in particular to a Spring-based declarative FTP transmission method and device. Background Art
[0002] FTP is an application layer protocol used for bidirectional file transfers on the Internet. It is used to transfer files between clients and servers on computer networks. It consists of two components: an FTP server and an FTP client. FTP can operate on any type of file without further processing. Therefore, FTP is also a client / server system. Users connect to a server program running on a remote computer through a client program. The computer that provides services and transfers files according to the FTP protocol is the FTP server, while the computer that connects to the FTP server and transfers files with the server using the FTP protocol is the FTP client. Different FTP applications are used based on different operating systems, but all of these applications follow the same protocol to transfer files. FTP makes it very convenient to upload and download files.
[0003] For example, the Chinese patent with application number "202111635356.9" and invention name "A control method and system for resuming file transfer based on FTP protocol" provides a control method and system for resuming file transfer based on FTP protocol. It obtains feature information by performing feature preprocessing on data files, and establishes index nodes to save feature information for easy file pre-detection and data packet retransmission. By comparing the length of the transferred file with the length of the virus file in the virus library, it is preliminarily determined whether the data file is infected with a virus, and then the md5 value of the transferred file is compared with the md5 value of the virus file in the virus library to further determine whether the data file is infected with a virus. This avoids the steps of caching each uploaded file and then performing md5 value detection, saves cache space, and solves the problem of uncontrollable upload of virus files using the breakpoint resume method.
[0004] Another example is the Chinese patent with application number "202110864371.4" and invention name "A real-time file transfer method and system based on FTP protocol". This invention patent connects to the FTP server through multiple threads, and uses one of the threads as the main thread to realize real-time monitoring of the directory files of the FTP server and the local directory files; then obtains the files to the shared queue through the main thread, and combines the multi-threaded file transmission form to realize real-time and fast upload and download of files between the directory files of the FTP server and the local directory files.
[0005] The shortcomings of the existing technology are: there are some problems in file synchronization in the existing technology: for example, the above-mentioned patent has weak FTP file synchronization capabilities, cumbersome implementation, and difficulty in quickly accessing a third-party FTP system to synchronize data, and the native FTP client function is weak, without breakpoint resumption, encryption and decryption and other functions. If the FTP capability is expanded in the original way, it will cause the code to be highly invasive and have low reusability, making subsequent optimization and modification difficult and the maintenance cost high. Therefore, those skilled in the art provide a Spring-based declarative FTP transmission method and device to solve the problems raised in the above-mentioned background technology.
[0006] Summary of the Invention
[0007] The purpose of the present invention is to provide a Spring-based declarative FTP transmission method and device to address the above-mentioned deficiencies in the prior art.
[0008] In order to achieve the above object, the present invention provides the following technical solutions:
[0009] A declarative FTP transmission method based on Spring includes the following steps:
[0010] Declaratively define an interface and corresponding methods, and add corresponding annotations;
[0011] The defined interface generates the core FTP code;
[0012] Set up plug-ins around FTP functions and extend additional functions in a plug-in manner;
[0013] Custom extension plug-ins and interceptors, all extension codes are woven into FTP objects during proxy class generation;
[0014] After the proxy object is generated, it is added to the Spring container and injected through annotations.
[0015] As a further preferred solution in the embodiment of the present invention, when files are uploaded or downloaded, the data passes through the plug-in and interceptor code.
[0016] As a further preferred solution in the embodiment of the present invention, the data generated when the file is downloaded is made transparent to the developer through the plug-in and interceptor code details.
[0017] As a further preferred solution in the embodiment of the present invention, the defined interface generates core FTP code through JDK dynamic proxy.
[0018] A Spring-based declarative FTP transmission device is used to implement the above-mentioned Spring-based declarative FTP transmission method, characterized in that the device includes an FTP module, a Spring container, a plug-in module, and an interceptor.
[0019] As a further preferred solution in the embodiment of the present invention, the plug-in module is any one of a breakpoint resume plug-in, an encryption and decryption plug-in, and a custom extension plug-in.
[0020] As a further preferred solution in the embodiment of the present invention, when the Spring container scans an interface described by a specific annotation, it generates an FTP proxy object for the interface in a dynamic proxy manner and injects it into the Spring container in the above technical solution.
[0021] A Spring-based declarative FTP transmission system includes the above-mentioned Spring-based declarative FTP transmission method.
[0022] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned Spring-based declarative FTP transmission method.
[0023] The present invention provides a Spring-based declarative FTP transmission method and device with the following beneficial effects:
[0024] The solution of the present invention is based on the setting of the Spring container. It realizes declarative programming by setting a dynamic proxy. At the same time, it generates the core FTP code based on the JDK dynamic proxy and supports plug-in extension, thereby improving the iterative upgrade capability of subsequent systems. In addition, the usage functions of subsequent systems are also enhanced. All functions can be extended in the form of plug-ins. The code is less invasive and has strong scalability. That is, the FTP set up in this application can upload and download files very conveniently. While improving the extended FTP capability, it can also reduce the invasiveness of the code, thereby improving the overall usage effect of FTP.
[0025] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
[0026] This application document provides an overview of various implementations or examples of the technology described in this disclosure, and is not a comprehensive disclosure of the full scope or all features of the disclosed technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments described in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0028] FIG1 is a flow chart of a prior art solution;
[0029] FIG2 is a schematic diagram of a method flow chart provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0030] To make the purpose, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0031] Please refer to Figure 2;
[0032] Example 1:
[0033] A declarative FTP transmission method and device based on Spring, comprising the following steps:
[0034] Declaratively define an interface and corresponding methods, and add corresponding annotations;
[0035] The defined interface generates the core FTP code;
[0036] Set up plug-ins around FTP functions and extend additional functions in a plug-in manner;
[0037] Custom extension plug-ins and interceptors, all extension codes are woven into FTP objects during proxy class generation;
[0038] After the proxy object is generated, it is added to the Spring container and injected through annotations;
[0039] Specifically, existing solutions all involve manually initializing the FTP client and then connecting to the FTP server to upload and download files. As shown in Figure 1, the implementation of the FTP client is cumbersome and the code is highly invasive. During the process of uploading and downloading files, if the connection is disconnected due to network fluctuations, the entire file needs to be downloaded again. The solution of the present invention is based on the settings of the Spring container, which implements declarative programming through the dynamic proxy method. At the same time, it generates the core FTP code based on the JDK dynamic proxy method and supports plug-in extensions, thereby improving the iterative upgrade capabilities of subsequent systems and enhancing the usability of subsequent systems.
[0040] Then the functions can be extended in the form of plug-ins, with low code intrusion and strong scalability. That is, the FTP set up in this application can upload and download files very conveniently. While improving the ability to extend FTP, it can also reduce the intrusion of the code and improve the overall use effect of FTP.
[0041] Furthermore, when files are uploaded or downloaded, the data passes through the plug-in and interceptor code, and the data generated when the file is downloaded passes through the plug-in and interceptor code details, which are transparent to the developer.
[0042] The defined interface generates the core FTP code through JDK dynamic proxy. Annotations and dynamic proxies are used in the Spring framework. When the Spring container scans an interface described by a specific annotation, an FTP proxy object is generated for the interface in a dynamic proxy manner and injected into the Spring container. This solution can solve the problems of cumbersome traditional FTP transmission definitions and the impact of network fluctuations. At the same time, it is convenient to expand the functions of FTP in a plug-in manner, such as encryption and decryption, file verification, etc.
[0043] Example 2:
[0044] A Spring-based declarative FTP transmission device is used to implement the above-mentioned Spring-based declarative FTP transmission method. The device includes an FTP module, a Spring container, a plug-in module, and an interceptor. The plug-in module is any one of a breakpoint resume plug-in, an encryption and decryption plug-in, and a custom extension plug-in.
[0045] When the Spring container scans an interface described by a specific annotation, it generates an FTP proxy object for the interface in a dynamic proxy manner and injects it into the Spring container.
[0046] By implementing it based on dynamic proxy in the Spring framework, you can declare an FTP client through an annotation, so that you can set it up according to your needs. It has excellent features such as easy modification, low code intrusion, and easy expansion.
[0047] Through this solution, Spring-based declarative FTP programming can be applied to FTP file transfer scenarios to provide reliable file transfer services. Custom plug-ins can then be used to extend FTP functions, facilitate dynamic expansion, and be applied to existing software systems with low intrusion.
[0048] That is, according to the application, only software changes are needed to implement it and support scenarios with large amounts of data.
[0049] Example 3: A Spring-based declarative FTP transmission system, including the above-mentioned Spring-based declarative FTP transmission method.
[0050] Embodiment 4: A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned Spring-based declarative FTP transmission method when executed by a processor.
[0051] The above description is merely illustrative of certain exemplary embodiments of the present invention. It goes without saying that those skilled in the art will be able to modify the described embodiments in various ways without departing from the spirit and scope of the present invention. Therefore, the above drawings and description are illustrative in nature and should not be construed as limiting the scope of protection of the claims.
Claims
1. A declarative FTP transmission method based on Spring, characterized in that: The steps include: Declaratively define an interface and corresponding methods, and add corresponding annotations; The defined interface generates the core FTP code; Set up plug-ins around FTP functions and extend additional functions in a plug-in manner; Custom extension plug-ins and interceptors, all extension codes are woven into FTP objects during proxy class generation; After the proxy object is generated, it is added to the Spring container and injected through annotations.
2. According to a Spring-based declarative FTP transmission method according to claim 1, it is characterized in that: When files are uploaded or downloaded, the data passes through the plug-in and interceptor code.
3. According to a Spring-based declarative FTP transmission method according to claim 2, it is characterized in that: The data generated when the file is downloaded is processed transparently to the developer through the plug-in and interceptor code details.
4. According to a Spring-based declarative FTP transmission method according to claim 1, it is characterized in that: The defined interface generates the core FTP code through JDK dynamic proxy.
5. A declarative FTP transmission device based on Spring, comprising: Memory for storing computer programs; A processor, used for implementing the steps of the Spring-based declarative FTP transmission method as described in any one of claims 1 to 4 when executing a computer program.
6. According to the Spring-based declarative FTP transmission device of claim 5, it is characterized in that: The device includes an FTP module, a Spring container, a plug-in module, and an interceptor.
7. A Spring-based declarative FTP transmission device according to claim 6, characterized in that: The plug-in module is any one of a breakpoint resume plug-in, an encryption and decryption plug-in, and a custom extension plug-in.
8. According to the Spring-based declarative FTP transmission device of claim 5, it is characterized in that: When the Spring container scans an interface described by a specific annotation, it generates an FTP proxy object for the interface in a dynamic proxy manner.
9. A declarative FTP transmission system based on Spring, characterized in that: The invention comprises the Spring declarative FTP transmission method as described in any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that: A computer program is stored on a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the Spring-based declarative FTP transmission method as described in any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Method for dynamically managing Feign interface calling address based on user-defined plug-in
CN115712512A
Remote calling method, system, equipment and medium
CN117056103A
Spring-based declarative FTP (File Transfer Protocol) transmission method and device
CN117692214A
Declarative security management plugins
US20190327315A1
