CN115550337A - Network framework switching method and device - Google Patents

Network framework switching method and device Download PDF

Info

Publication number
CN115550337A
CN115550337A CN202211278973.2A CN202211278973A CN115550337A CN 115550337 A CN115550337 A CN 115550337A CN 202211278973 A CN202211278973 A CN 202211278973A CN 115550337 A CN115550337 A CN 115550337A
Authority
CN
China
Prior art keywords
request
http request
network framework
network
switching
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211278973.2A
Other languages
Chinese (zh)
Inventor
刘利刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202211278973.2A priority Critical patent/CN115550337A/en
Publication of CN115550337A publication Critical patent/CN115550337A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a network frame switching method and a device, relating to the technical field of network security, wherein the method comprises the following steps: the request interface receives an http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance; the factory class identifies the http request network frame type corresponding to the http request of the user; and calling the common request method by the callback interface according to the identified type of the http request network framework, and switching to the identified http request network framework. The invention can realize the high-efficiency switching of the network framework under the condition of changing the service codes less.

Description

Network framework switching method and device
Technical Field
The present invention relates to the field of network security technologies, and in particular, to a network framework switching method and apparatus.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
At present, the http request operation of the Android client can be implemented by a scheme such as Retrofit, okHttp, volley and the like. The above implementation schemes have advantages and disadvantages, and have applicable service scenarios. If the same APP wants to realize fast switching of different network frameworks (Retrofit, okhttp, volley), one traditional method is to realize one by one according to scenes, so that the efficiency is low, and a lot of program codes need to be changed.
Disclosure of Invention
The embodiment of the invention provides a network frame switching method, which is used for realizing high-efficiency switching of a network frame under the condition of changing a service code less, and comprises the following steps:
the request interface receives a current http request of a user; a common request method of all types of http request network frames is extracted in the request interface in advance;
the factory identifies the http request network frame type corresponding to the http request of the user according to the service scene corresponding to the current http request;
and calling the common request method by the callback interface according to the identified type of the http request network framework, and switching to the identified http request network framework.
The embodiment of the present invention further provides a network frame switching apparatus, which is used for implementing efficient switching of a network frame under the condition that a service code is changed less, and the apparatus includes:
the request interface is used for receiving a current http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance;
the factory class is used for identifying the http request network frame type corresponding to the http request of the user according to the service scene corresponding to the current http request;
and the callback interface is used for calling the common request method according to the identified type of the http request network framework and switching to the identified http request network framework.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the network framework switching method when executing the computer program.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the network framework switching method is implemented.
An embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the network framework switching method is implemented.
In the embodiment of the invention, compared with the technical scheme of network frame switching with low efficiency under the condition that a plurality of program codes need to be changed in the prior art, the network frame switching scheme has the following advantages that: the method comprises the steps that a request interface receives an http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance; the factory class identifies the http request network frame type corresponding to the http request of the user; and calling the common request method by the callback interface according to the identified type of the http request network framework, and switching to the identified http request network framework. The invention can realize the high-efficiency switching of the network framework under the condition of changing the service codes less.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:
fig. 1 is a schematic flowchart of a network framework switching method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a network frame switching method according to another embodiment of the present invention;
FIG. 3 is a schematic diagram of network framework switching according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a network frame switching apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
According to the technical scheme, the data acquisition, storage, use, processing and the like meet relevant regulations of national laws and regulations.
Interface: refers to the communication rules between different functional layers of the same computer;
class (ii): abstracting a thing with common characteristics in real life;
in order to solve technical problems in the prior art, an embodiment of the present invention provides a network framework switching scheme, which is a factory-mode Android network framework fast switching scheme, and is beneficial to solving fast switching of an http request of an Android client, implementing interface decoupling, and changing a service code less during switching. The network framework switching scheme is described in detail below.
Fig. 1 is a schematic flow chart of a network framework switching method in an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step 101: the request interface receives a current http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance;
step 102: the factory identifies the http request network frame type corresponding to the http request of the user according to the service scene corresponding to the current http request;
step 103: and calling the common request method by the callback interface according to the identified type of the http request network framework, and switching to the identified http request network framework.
The network frame switching method provided by the embodiment of the invention works as follows: the method comprises the steps that a request interface receives an http request of a user; a common request method of all types of http request network frames is extracted in the request interface in advance; the factory class identifies the http request network frame type corresponding to the http request of the user; and calling the common request method by the callback interface according to the identified type of the http request network framework, and switching to the identified http request network framework.
Compared with the technical scheme of network frame switching with low efficiency under the condition that a plurality of program codes need to be changed in the prior art, the method and the device can realize the high-efficiency network frame switching under the condition that the service codes are changed less. The network frame switching method is described in detail below.
In one embodiment, the http request web framework type may include: a Retrofit network framework, an OkHttp network framework, or a Volley network framework.
In one embodiment, the commonality request method may include get/post/put/delete.
The GET request sends a data request to the database to obtain information, and the request is just used for querying data like the select operation of the database, and cannot modify and add data, and cannot influence resource content, namely, the request cannot generate side effects. The results were the same regardless of how many operations were performed.
The PUT request is different from the GET in that the PUT request is for sending data to the server side so as to change information, and the request is the same as update operation of a database and is used for modifying the content of the data, but the types of the data are not increased, that is, the result is not different no matter how many times PUT operation is performed.
The POST request is similar to the PUT request and sends data to the server, but the request changes resources such as data types, and creates new content as for insert operation of a database. Almost all commit operations are currently requested using a POST.
The DELETE request, as the name implies, is used to DELETE a line, as is the DELETE operation of the database.
In step 102, the factory class may identify the http request network frame type corresponding to the http request of the user according to the service scenario corresponding to the current http request and a relationship between the service scenario and the http request network frame type (the relationship may be a table of different service scenarios and corresponding http request network frames).
In an embodiment, as shown in fig. 2, the callback interface calls the commonality request method according to the identified http request network framework type to switch to the identified http request network framework, which may include step 103':
in the Activity/Fragment/Presensor, the identified http request network frame type is used for calling the common request method, and a request result is obtained in the callback interface.
In one embodiment, the network framework switching method is a factory-mode android network framework switching method.
To facilitate an understanding of how the invention may be practiced, reference is now made in detail to FIG. 3.
1) Extracting a common method (get/post/put/delete) of an http request network framework into an interface, wherein the interface is called a request interface;
2) Creating an interface for returning a request result, wherein the interface is called a callback interface;
3) Respectively using Volley, okHttp and Retrofit to realize a 'request interface';
4) Creating an object with a class returning to the interface, wherein the class is called a factory class;
5) In Activity/Fragment/Presensor, the get/post/put/delete method is called by using the interface object returned by the factory, and the request result is obtained in the callback interface.
As shown in fig. 3, the specific implementation process may be as follows:
s1: the commonness method of the http request framework is extracted to an interface (get/post/put/delete method), a request interface IRequestManager and a callback interface IRequestCallback.
S2: this interface of IRequestManager is implemented with Volley. OkHttp and Retrofit are similar in other ways and are not listed.
S3: a "factory" class is created to return the objects of the IRequestManager request interface.
And realizing a set of get/post/put/delete request method according to OkHttp and Retrofit request modes, wherein the whole http request frame can be replaced without modifying any other codes as long as the object returned in the S3 is modified to be an OkHttpRequestManager object.
In summary, the network framework switching method provided by the embodiment of the invention is beneficial to solving the problem of fast switching of http requests of Android clients, realizing interface decoupling, and changing service codes less during switching.
The embodiment of the present invention further provides a network framework switching apparatus, as described in the following embodiments. Because the principle of the device for solving the problems is similar to the network frame switching method, the implementation of the device can refer to the implementation of the network frame switching method, and repeated parts are not described again.
Fig. 4 is a schematic structural diagram of a network frame switching device according to an embodiment of the present invention, and as shown in fig. 4, the device:
a request interface 01, configured to receive a current http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance;
the factory class 02 is used for identifying the http request network framework type corresponding to the http request of the user according to the service scene corresponding to the current http request;
and the callback interface 03 is used for calling the common request method according to the identified type of the http request network framework and switching to the identified http request network framework.
In one embodiment, the http request web framework type includes: a Retrofit network framework, an OkHttp network framework, or a Volley network framework.
In one embodiment, the commonality request method includes get/post/put/delete.
In one embodiment, the callback interface is specifically configured to:
in the Activity/Fragment/Presensor, the identified http request network frame type is used for calling the commonality request method, and a request result is obtained in a callback interface.
In one embodiment, the web framework switching device is a factory-mode android web framework switching device.
Based on the aforementioned inventive concept, as shown in fig. 5, the present invention further proposes a computer device 500, which comprises a memory 510, a processor 520 and a computer program 530 stored on the memory 510 and capable of running on the processor 520, wherein the processor 520 executes the computer program 530 to implement the aforementioned fund information processing method.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the network framework switching method is implemented.
An embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the network framework switching method is implemented.
In the embodiment of the invention, compared with the technical scheme of network frame switching with low efficiency under the condition that a plurality of program codes need to be changed in the prior art, the network frame switching scheme has the following advantages that: the request interface receives an http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance; the factory class identifies the http request network frame type corresponding to the http request of the user; and calling the common request method by the callback interface according to the identified type of the http request network framework, and switching to the identified http request network framework. The invention can realize the high-efficiency switching of the network framework under the condition of changing the service codes less.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (13)

1. A network framework switching method is characterized by comprising the following steps:
the request interface receives a current http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance;
the factory identifies the http request network frame type corresponding to the http request of the user according to the service scene corresponding to the current http request;
and calling the common request method by the callback interface according to the identified type of the http request network framework, and switching to the identified http request network framework.
2. The network framework switching method of claim 1, wherein the http requesting network framework type comprises: a Retrofit network framework, an OkHttp network framework, or a Volley network framework.
3. The network framework switching method of claim 1, wherein the commonality request method comprises get/post/put/delete.
4. The network frame switching method of claim 1, wherein the callback interface calls the commonality request method to switch to the identified http request network frame according to the identified http request network frame type, comprising:
in the Activity/Fragment/Presensor, the identified http request network frame type is used for calling the commonality request method, and a request result is obtained in a callback interface.
5. The network framework switching method according to claim 1, wherein the network framework switching method is a factory-mode android network framework switching method.
6. A network framework switching apparatus, comprising:
the request interface is used for receiving a current http request of a user; a common request method of all types of http request network frameworks is extracted in the request interface in advance;
the factory class is used for identifying the http request network frame type corresponding to the http request of the user according to the service scene corresponding to the current http request;
and the callback interface is used for calling the common request method according to the identified type of the http request network framework and switching to the identified http request network framework.
7. The network framework switching apparatus of claim 6, wherein the http request network framework type comprises: a Retrofit network framework, an OkHttp network framework, or a Volley network framework.
8. The network framework switching apparatus of claim 6, wherein the commonality request method comprises get/post/put/delete.
9. The network framework switching device of claim 6, wherein the callback interface is specifically configured to:
in the Activity/Fragment/Presensor, the identified http request network frame type is used for calling the common request method, and a request result is obtained in the callback interface.
10. The device of claim 6, wherein the network framework switching device is a factory mode android network framework switching device.
11. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 5 when executing the computer program.
12. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by a processor, implements the method of any one of claims 1 to 5.
13. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, carries out the method of any one of claims 1 to 5.
CN202211278973.2A 2022-10-19 2022-10-19 Network framework switching method and device Pending CN115550337A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211278973.2A CN115550337A (en) 2022-10-19 2022-10-19 Network framework switching method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211278973.2A CN115550337A (en) 2022-10-19 2022-10-19 Network framework switching method and device

Publications (1)

Publication Number Publication Date
CN115550337A true CN115550337A (en) 2022-12-30

Family

ID=84734917

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211278973.2A Pending CN115550337A (en) 2022-10-19 2022-10-19 Network framework switching method and device

Country Status (1)

Country Link
CN (1) CN115550337A (en)

Similar Documents

Publication Publication Date Title
CN107766509B (en) Method and device for static backup of webpage
CN111611207B (en) State data processing method and device and computer equipment
CN111064626B (en) Configuration updating method, device, server and readable storage medium
CN114615135A (en) Front-end gray level publishing method, system and storage medium
CN113556359A (en) Communication protocol conversion method, device, system and gateway device
CN112003976A (en) Hard-coding and hard-decoding test method and device
US20120166893A1 (en) Recording and Preventing Crash in an Appliance
CN113434323A (en) Task flow control method of data center station and related device
CN115550337A (en) Network framework switching method and device
CN112650592A (en) Zookeeper-based task load balancing and high-availability system
CN109389271B (en) Application performance management method and system
CN117251260A (en) Data processing method and system
CN115526586A (en) Business process processing method based on intelligent operation
CN114741162A (en) Service arranging method, device, storage medium and equipment
CN111782363A (en) Method and flow system for supporting multi-service scene calling
CN112668287A (en) Data table determination method, system and device
CN112995241A (en) Service scheduling method and device
CN114785711B (en) Performance monitoring method, device and storage medium of network equipment
CN113741946B (en) Clipping method, device and equipment of public interface function library and readable storage medium
CN113760836B (en) Wide table calculation method and device
CN115269161B (en) Abnormal process reverse rollback method and system
CN116755938B (en) Computing restarting method and device, storage medium and electronic equipment
WO2023207213A1 (en) Data processing method, and apparatus
CN115543300A (en) Service data processing method and device
CN117453292A (en) Workflow engine-based business process processing method, system, equipment and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination