Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are used merely to distinguish one device, module, or unit from another device, module, or unit, and are not intended to limit the order or interdependence of the functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The following describes the technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
In view of the foregoing technical problems, a method for processing a service request according to an embodiment of the present disclosure may be performed by a user terminal, as shown in fig. 1, and may include:
Step S110, a service request to be processed is obtained, wherein the service request carries class objects of interfaces.
Wherein, the class object of the interface can be used for describing the interface, the interface can be understood as a special class, the class is an abstract concept, and only represents a template of things, and no specific concept exists, such as ' girlfriend ', ' men's friend '. An object is a specific entity that can be "seen" and "touched", and based on the class object of the interface, it is possible to know which interface the service request wants to request.
The service request refers to a request for realizing a function, and based on the request, an implementation class corresponding to the request needs to be acquired, so that the function from the request to the implementation can be realized based on the implementation class. The implementation class refers to code corresponding to implementing a function. The above-mentioned functions are understood to be corresponding functions in a certain application, such as playing music, etc.
In this scenario, a service request typically corresponds to an interface.
Step S120, determining a target interface based on the class object of the interface.
In practical application, the identity of the interface can be identified through the interface identifier, and then based on the class object of the interface, the interface identifier corresponding to which interface is requested corresponding to the service request can be determined, and based on the interface identifier, the interface corresponding to the service request is determined.
Step S130, determining a target implementation class corresponding to the service request based on the target interface and a pre-established corresponding relation, wherein the corresponding relation is the corresponding relation between the target interface and the target implementation class.
And determining which interface corresponds to the service request and which implementation class corresponds to the interface, namely the target implementation class, based on the pre-established corresponding relation and the class object of the interface in the service request.
In practical application, the implementation class can be identified by the implementation class identification, and the corresponding relationship can be the corresponding relationship between the interface identification and the implementation class identification.
Step S140, based on the target realization class, corresponding business processing is carried out on the service request.
The corresponding business processing of the service request based on the target implementation class means that the function of realizing the request corresponding to the service request can be realized based on the target implementation class.
According to the scheme in the embodiment of the disclosure, when the service request to be processed is acquired, a target interface corresponding to the identifier can be determined based on the class object of the interface carried in the service request, which interface the service request corresponds to want to access can be known based on the target interface, then, based on the target interface and the pre-established corresponding relation, a target implementation class corresponding to the target interface can be determined, namely, which implementation class is want to be called can be determined based on the corresponding relation, and further, based on the implementation class, corresponding service processing is performed on the service request. In the scheme, the corresponding relation is the corresponding relation between the target interface and the target implementation class, so that the name of the implementation class is not required to be known when the implementation class is called, and the corresponding implementation class can be called only by knowing which interface is required to be called, and therefore, the implementation class can be called in a reflection mode, and the system performance is improved.
In addition, as can be seen from the scheme, the scheme is interface-oriented rather than implementation-oriented, so that when in development, only the interfaces are required to be correspondingly configured, and the implementation-oriented is not required to be changed, thereby being convenient for development of research personnel.
In the embodiment of the disclosure, the correspondence is established by:
acquiring byte codes corresponding to a functional module, wherein the functional module corresponds to a business logic;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the byte code corresponding to the functional module;
based on the interface corresponding to the functional module and the implementation class corresponding to the interface, generating a mapping container class corresponding to the functional module, wherein the mapping container class stores the corresponding relation between the interface corresponding to the functional module and the implementation class corresponding to the interface.
In practical application, if the mapping container class corresponding to each functional module is generated based on the establishment mode of the corresponding relation, for convenience of management, a large mapping container class can be generated by the mapping container class corresponding to each functional module. The method is realized by the following steps:
based on the mapping container class corresponding to each functional module, generating a fused mapping container class, wherein the fused mapping container class stores the corresponding relation between the interfaces corresponding to each functional module and the implementation classes corresponding to each interface.
For each functional module, a mapping container class corresponding to each functional module may be generated based on an interface and an implementation class corresponding to each functional module, where the mapping container class may be called a table, and then a fused mapping container class may be generated based on a mapping container class corresponding to each functional module, where the mapping container class may be called a map. Based on the fused mapping container class, the corresponding relation between the interfaces corresponding to the functional modules and the implementation classes corresponding to the interfaces can be obtained.
The ASM is a java byte code manipulation framework, the ASM byte code processing framework processes class files, and the processed byte codes can be converted into classes. The bytecode corresponding to each functional module may be collected based on the ASM, and then the bytecode corresponding to each functional module may be processed to obtain a mapping container class corresponding to each functional module.
It can be understood that the correspondence may be established by other terminal devices, where the other terminal devices are terminal devices that distinguish the user terminal corresponding to the scheme of the present application, and after the correspondence is established on the other terminal devices, the correspondence may be invoked through interaction between the user terminal and the other terminal devices.
In an embodiment of the present disclosure, generating, based on an interface corresponding to the functional module and an implementation class corresponding to the interface, a mapping container class corresponding to the functional module includes:
obtaining class annotation information corresponding to the functional module;
based on class annotation information, determining an interface corresponding to the functional module and an implementation class corresponding to the interface;
taking the interface as a key, taking the implementation class as a Value, and establishing a corresponding relation between the key and the Value;
and generating a mapping container class corresponding to the functional module based on the corresponding relation between the key and the Value.
The class annotation information may be used to identify which interface and which implementation class corresponds to the functional module, and then, based on the class annotation information corresponding to the functional module, for example, the class annotation information is @ serviceinformation, the interface corresponding to the functional module and the implementation class corresponding to the interface may be determined. And taking the interface as a key, taking the implementation class as a Value, and establishing a k-v corresponding relation, namely, representing the mapping relation between one interface and the implementation class of the interface through a key Value pair.
The class annotation information can be obtained from byte codes corresponding to the functional modules.
It can be understood that if the interface has a corresponding interface identifier and the implementation class has a corresponding implementation class identifier, the interface identifier may be used as a key and the implementation class identifier may be used as a Value in the corresponding relationship between the key and the Value.
Alternatively, class annotation information corresponding to each functional module may be collected and processed based on APT (Annotation Processing Tool) annotation processor, and one functional module may correspond to one APT annotation processor.
In an embodiment of the present disclosure, the method further comprises:
generating a target packaging class corresponding to the target implementation class based on the target implementation class, wherein the target packaging class corresponds to a target packaging interface;
correspondingly, the corresponding relation can comprise a first corresponding relation between the target interface and the target packaging interface corresponding to the target interface and a second corresponding relation between the target packaging interface and the target implementation class;
correspondingly, the determining the target implementation class corresponding to the service request based on the target interface and the pre-established corresponding relation comprises the following steps:
determining a target packaging interface corresponding to the target interface based on the target interface and the first corresponding relation;
and determining a target implementation class corresponding to the service request based on the target packaging interface and the second corresponding relation.
Specifically, in order not to directly access the target implementation class, a target package class may be set for each target implementation class, where the target package class corresponds to an outer package of the target implementation class, and the target package class corresponds to a target package interface through which the corresponding target package class may be accessed. In an alternative, the package interface may also correspond to a package interface identifier, where the identity of the package interface is identified by the package interface identifier. The correspondence may include a first correspondence between an interface identifier of the target interface and an identifier of the target packaging interface, and a second correspondence between an identifier of the target packaging interface corresponding to the target interface and an identifier of the target implementation class.
In addition, the packaging class is accessed first and then the implementation class is accessed, so that lazy loading can be avoided, namely, when the packaging class is compiled instead of the implementation class, the compiling packaging is less in calculation amount than the compiling implementation class, and therefore, resources can be saved when the packaging class is initialized.
If each implementation class corresponds to one package class, the correspondence described above may include a first correspondence between an interface identifier of each interface and an identifier of a package interface corresponding to each interface, and a second correspondence between an identifier of a package interface corresponding to each interface and an implementation class identifier corresponding to each interface, when determining, based on the target interface identifier and a pre-established correspondence, a target implementation class identifier corresponding to the service request, a target package interface identifier corresponding to the target interface identifier, that is, which target package interface corresponds to the target interface, may be determined first based on the target interface identifier and the first correspondence, and then, based on the target package interface identifier and the second correspondence, a target implementation class identifier corresponding to the service request, that is, which package class corresponds to the target package interface, and which implementation class (target implementation class) corresponds to the package class may be determined.
In an embodiment of the present disclosure, if the service request further includes a service parameter, performing corresponding service processing on the service request based on a target implementation class, including:
transmitting the service parameters to a target implementation class through a target packaging interface;
and carrying out corresponding business processing on the service request based on the target implementation class containing the service parameters.
When each implementation class has a corresponding packaging class, the method supports the transmission of service parameters, specifically, the method can transmit the service parameters to functions in the implementation class through corresponding packaging interfaces, the service parameters serve as variables of the functions, and different results corresponding to the functions can be obtained based on different service parameters. If the service request includes the service parameter, the service parameter may be transferred to the target implementation class through the corresponding wrapper class (the target wrapper class corresponding to the target wrapper class interface), and then the service request is subjected to corresponding service processing based on the target implementation class including the service parameter. If the service parameters are not included, the service request can be processed correspondingly based on the target implementation class directly.
In the disclosed scheme, based on the class annotation information @ serviceoil, when the method supports service parameter transfer, the class annotation information is changed to @ serviceoil Param, and an @ serviceoil provider annotation tag function is used, wherein the function can be a private constructor or non-constructor.
In an embodiment of the present disclosure, the service parameter is an Object array.
After the service parameters are transferred to the target implementation class, checking can be performed first, after the service parameters pass the checking, corresponding service processing is performed on the service request based on the target implementation class containing the service parameters, and if the service parameters do not pass the checking, the corresponding service processing is not performed.
In the embodiment of the disclosure, the implementation classes include a single-instance implementation class and a non-single-instance implementation class, and when the target implementation class is the single-instance implementation class, determining, based on the target packaging interface and the second correspondence, the target implementation class corresponding to the service request includes:
and determining a target implementation class corresponding to the service request through a set function based on the target packaging interface and the second corresponding relation.
Where a single instance refers to an implementation class that can only be compiled once in one cycle, and a non-single instance refers to an implementation class that can be compiled multiple times in one cycle. If the target implementation class is a single-instance implementation class, the target implementation class can not be directly compiled and needs to be called through a set function. If the service request is a non-single instance implementation class, compiling can be directly performed, and the target implementation class corresponding to the service request can be determined based on the target packaging interface and the second corresponding relation. Wherein the set function may be a get function.
Based on the same principle as the service request processing method shown in fig. 1, there is also provided in an embodiment of the present disclosure a service request processing apparatus 20, as shown in fig. 2, the apparatus 20 may include: a request acquisition module 210, a target interface determination module 220, a target implementation class determination module 230, and a traffic processing module 240, wherein,
a request acquisition module 210, configured to acquire a service request to be processed, where the service request carries a class object of an interface;
a target interface determining module 220, configured to determine a target interface based on the class object of the interface;
the target implementation class determining module 230 is configured to determine a target implementation class corresponding to the service request based on the target interface and a pre-established correspondence, where the correspondence is a correspondence between the target interface and the target implementation class;
the service processing module 240 is configured to perform corresponding service processing on the service request based on the target implementation class.
When the service request processing device of the embodiment of the disclosure obtains the service request to be processed, the target interface corresponding to the identifier can be determined based on the class object of the interface carried in the service request, which interface the service request corresponds to want to access can be known based on the target interface, then the target implementation class corresponding to the target interface can be determined based on the target interface and the pre-established corresponding relation, namely which implementation class is wanted to be called can be determined based on the corresponding relation, and further, corresponding service processing is performed on the service request based on the implementation class. In the scheme, the corresponding relation is the corresponding relation between the target interface and the target implementation class, so that the name of the implementation class is not required to be known when the implementation class is called, and the corresponding implementation class can be called only by knowing which interface is required to be called, and therefore, the implementation class can be called in a reflection mode, and the system performance is improved.
Optionally, the device further includes a correspondence establishing module, where the correspondence establishing module is configured to:
acquiring byte codes corresponding to a functional module, wherein the functional module corresponds to a business logic;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the byte code corresponding to the functional module;
based on the interface corresponding to the functional module and the implementation class corresponding to the interface, generating a mapping container class corresponding to the functional module, wherein the mapping container class stores the corresponding relation between the interface corresponding to the functional module and the implementation class corresponding to the interface.
Optionally, the correspondence relation establishing module is specifically configured to, when generating the mapping container class corresponding to the functional module based on the interface corresponding to the functional module and the implementation class corresponding to the interface:
obtaining class annotation information corresponding to the functional module;
based on class annotation information, determining an interface corresponding to the functional module and an implementation class corresponding to the interface;
taking the interface as a key, taking the implementation class as a Value, and establishing a corresponding relation between the key and the Value;
and generating a mapping container class corresponding to the functional module based on the corresponding relation between the key and the Value.
Optionally, the apparatus further comprises:
The package class generation module is used for generating a target package class corresponding to the target implementation class based on the target implementation class, wherein the target package class corresponds to a target package interface;
the corresponding relation comprises a first corresponding relation between the target interface and the target packaging interface and a second corresponding relation between the target packaging interface and the target implementation class, and the target implementation class determining module is specifically used for determining the target implementation class corresponding to the service request when determining the target implementation class based on the target interface and the pre-established corresponding relation:
determining a target packaging interface corresponding to the target interface based on the target interface and the first corresponding relation;
and determining a target implementation class corresponding to the service request based on the target packaging interface and the second corresponding relation.
Optionally, if the service request further includes a service parameter, the service processing module is specifically configured to:
transmitting the service parameters to a target implementation class through a target packaging interface;
and carrying out corresponding business processing on the service request based on the target implementation class containing the service parameters.
Optionally, the service parameter is an Object array.
Optionally, the implementation classes include a single-instance implementation class and a non-single-instance implementation class, and when the target implementation class is the single-instance implementation class, the service processing module is specifically configured to:
And determining a target implementation class corresponding to the service request through a set function based on the target packaging interface and the second corresponding relation.
The apparatus of the embodiments of the present disclosure may execute a service request processing method shown in fig. 1, and its implementation principle is similar, and actions executed by each module in the service request processing apparatus in each embodiment of the present disclosure correspond to steps in the service request processing method in each embodiment of the present disclosure, and detailed functional descriptions of each module in the service request processing apparatus may be specifically referred to descriptions in the corresponding service request processing method shown in the foregoing, which are not described herein again.
Based on the same principle as the method in the embodiments of the present disclosure, reference is now made to fig. 3, which shows a schematic structural diagram of an electronic device (e.g. terminal device in fig. 1) 600 suitable for implementing the embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 3 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
An electronic device includes: a memory and a processor, where the processor may be referred to as a processing device 601 hereinafter, the memory may include at least one of a Read Only Memory (ROM) 602, a Random Access Memory (RAM) 603, and a storage device 608 hereinafter, as shown in detail below:
as shown in fig. 3, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 3 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 601.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (Hyper Text Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving triggering operation of a user on an image area in a video frame image of a currently played video through a video playing interface; if the video frame image contains a specified object and the image area is a specified area corresponding to the specified object, generating an object information acquisition request aiming at the specified object; and acquiring and displaying the link information of the specified object based on the object information acquisition request.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. 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.
The modules or units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Where the name of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a service request processing method, including:
acquiring a service request to be processed, wherein the service request carries a class object of an interface;
determining the target interface based on the class object of the interface;
determining a target implementation class corresponding to the service request based on the target interface and a pre-established corresponding relation, wherein the corresponding relation is the corresponding relation between the target interface and the target implementation class;
and based on the target implementation class, carrying out corresponding service processing on the service request.
According to one or more embodiments of the present disclosure, the correspondence is established by:
acquiring byte codes corresponding to a functional module, wherein the functional module corresponds to a business logic;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the byte code corresponding to the functional module;
and generating a mapping container class corresponding to the functional module based on the interface corresponding to the functional module and the implementation class corresponding to the interface, wherein the mapping container class stores the corresponding relation between the interface corresponding to the functional module and the implementation class corresponding to the interface.
According to one or more embodiments of the present disclosure, the generating, based on the interface corresponding to the functional module and the implementation class corresponding to the interface, a mapping container class corresponding to the functional module includes:
obtaining class annotation information corresponding to the functional module;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the class annotation information;
taking the interface as a key, taking the implementation class as a Value, and establishing a corresponding relation between the key and the Value;
and generating a mapping container class corresponding to the functional module based on the corresponding relation between the key and the Value.
According to one or more embodiments of the present disclosure, the method further comprises:
generating a target packaging class corresponding to the target implementation class based on the target implementation class, wherein the target packaging class corresponds to a target packaging interface;
the correspondence includes a first correspondence between the target interface and the target wrapper interface, and a second correspondence between the target wrapper interface and the target implementation class, and determining, based on the target interface and a pre-established correspondence, a target implementation class corresponding to the service request includes:
Determining a target packaging interface corresponding to the target interface based on the target interface and the first corresponding relation;
and determining a target implementation class corresponding to the service request based on the target packaging interface and the second corresponding relation.
According to one or more embodiments of the present disclosure, if the service request further includes a service parameter, the performing, based on the target implementation class, a corresponding service process on the service request includes:
transmitting the service parameters to the target implementation class through the target packaging interface;
and carrying out corresponding business processing on the service request based on the target implementation class containing the service parameters.
According to one or more embodiments of the present disclosure, the service parameter is an Object array.
According to one or more embodiments of the present disclosure, the implementation classes include a single-instance implementation class and a non-single-instance implementation class, and when the target implementation class is a single-instance implementation class, determining, based on the target package interface and the second correspondence, the target implementation class corresponding to the service request includes:
and determining a target implementation class corresponding to the service request through a set function based on the target packaging interface and the second corresponding relation.
According to one or more embodiments of the present disclosure, there is provided a service request processing apparatus [ example two ] including:
the request acquisition module is used for acquiring a service request to be processed, wherein the service request carries a class object of an interface;
a target interface determining module, configured to determine the target interface based on a class object of the interface;
the target implementation class determining module is used for determining a target implementation class corresponding to the service request based on the target interface and a pre-established corresponding relation, wherein the corresponding relation is the corresponding relation between the target interface and the target implementation class;
and the service processing module is used for carrying out corresponding service processing on the service request based on the target implementation class.
According to one or more embodiments of the present disclosure, the apparatus further includes a correspondence establishing module, where the correspondence establishing module is configured to:
acquiring byte codes corresponding to a functional module, wherein the functional module corresponds to a business logic;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the byte code corresponding to the functional module;
and generating a mapping container class corresponding to the functional module based on the interface corresponding to the functional module and the implementation class corresponding to the interface, wherein the mapping container class stores the corresponding relation between the interface corresponding to the functional module and the implementation class corresponding to the interface.
According to one or more embodiments of the present disclosure, the correspondence establishing module is specifically configured to, when generating a mapping container class corresponding to the functional module based on an interface corresponding to the functional module and an implementation class corresponding to the interface:
obtaining class annotation information corresponding to the functional module;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the class annotation information;
taking the interface as a key, taking the implementation class as a Value, and establishing a corresponding relation between the key and the Value;
and generating a mapping container class corresponding to the functional module based on the corresponding relation between the key and the Value.
According to one or more embodiments of the present disclosure, the apparatus further comprises:
the package class generation module is used for generating a target package class corresponding to the target implementation class based on the target implementation class, wherein the target package class corresponds to a target package interface;
the corresponding relation comprises a first corresponding relation between the target interface and the target packaging interface and a second corresponding relation between the target packaging interface and the target implementation class, and the target implementation class determining module is specifically configured to, when determining the target implementation class corresponding to the service request based on the target interface and the pre-established corresponding relation:
Determining a target packaging interface corresponding to the target interface based on the target interface and the first corresponding relation;
and determining a target implementation class corresponding to the service request based on the target packaging interface and the second corresponding relation.
According to one or more embodiments of the present disclosure, if the service request further includes a service parameter, the service processing module is specifically configured to, when performing corresponding service processing on the service request based on the target implementation class:
transmitting the service parameters to the target implementation class through the target packaging interface;
and carrying out corresponding business processing on the service request based on the target implementation class containing the service parameters.
According to one or more embodiments of the present disclosure, the service parameter is an Object array.
According to one or more embodiments of the present disclosure, the implementation classes include a single-instance implementation class and a non-single-instance implementation class, and when the target implementation class is the single-instance implementation class, the service processing module is specifically configured to, when determining, based on the target packaging interface and the second correspondence, the target implementation class corresponding to the service request:
and determining a target implementation class corresponding to the service request through a set function based on the target packaging interface and the second corresponding relation.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.