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 are shown in the 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 rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the 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. Moreover, 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 "include" and variations thereof as used herein are 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". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing the devices, modules or units, and are not used for limiting the devices, modules or units to be different devices, modules or units, and also for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The following describes the technical solutions of the present disclosure and how to solve the above technical problems in specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
In view of the above technical problem, an embodiment of the present disclosure provides a service request processing method, which may be executed by a user terminal, and as shown in fig. 1, the method may include:
step S110, obtain a service request to be processed, where the service request carries a class object of an interface.
Wherein the class object of the interface can be used to describe 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 is available, such as 'girlfriend' or 'boyfriend'. An object is a specific entity that can be "seen, felt", and based on the class object of the interface, it can know which interface the service request wants to request.
The service request refers to a request for implementing a function, and based on the request, an implementation class corresponding to the request needs to be acquired, so that the function implemented by the request can be implemented based on the implementation class. An implementation class refers to code corresponding to implementing a function. The above functions may be understood as corresponding functions in an application, for example, playing music.
In this scenario, one service request typically corresponds to one interface.
Step S120, based on the class object of the interface, determining a target interface.
In practical applications, the identity of the interface may be identified by the interface identifier, and based on the class object of the interface, it may be determined which interface corresponds to the request of the service request, and based on the interface identifier, it may be determined which interface corresponds to the request of the service request.
Step S130, determining a target implementation class corresponding to the service request based on the target interface and a pre-established corresponding relationship, where the corresponding relationship is a corresponding relationship 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 correspondence and the class object of the interface in the service request.
In practical application, the implementation class may be identified by the implementation class identifier, and the corresponding relationship may be a corresponding relationship between the interface identifier and the implementation class identifier.
Step S140, based on the target implementation class, corresponding service processing is performed on the service request.
The performing of the corresponding service processing on the service request based on the target implementation class means that the function of the request implementation corresponding to the service request can be implemented based on the target implementation class.
According to the scheme in the embodiment of the disclosure, when a service request to be processed is obtained, a target interface corresponding to an identifier can be determined based on a class object of an interface carried in the service request, based on the target interface, it can be known which interface the service request corresponds to, and then based on the target interface and a pre-established corresponding relationship, a target implementation class corresponding to the target interface can be determined, that is, based on the corresponding relationship, it can be determined which implementation class the service request is to call, and further, based on the implementation class, corresponding service processing is performed on the service request. In the scheme, because the corresponding relation is the corresponding relation between the target interface and the target implementation class, when the implementation class is called, the name of the implementation class does not need to be known, and the corresponding implementation class can be called only by knowing which interface is called, so that the calling of the implementation class can be carried out without adopting a reflection mode, and the system performance is improved.
In addition, according to the scheme, the scheme is interface-oriented rather than implementation-oriented, so that during development, only corresponding configuration is needed to be carried out on the interface without changing the implementation class, and development of research and development personnel can be facilitated.
In the embodiment of the present disclosure, the corresponding relationship is established in the following manner:
acquiring a byte code corresponding to a functional module, wherein the functional module corresponds to a service 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.
In practical applications, if the mapping container class corresponding to each function module is generated based on the above-mentioned establishment manner of the correspondence, for convenience of management, the mapping container class corresponding to each function module may be generated into a large mapping container class. The method can be specifically realized by the following steps:
and generating a fused mapping container class based on the mapping container class corresponding to each functional module, wherein the fused mapping container class stores the corresponding relation between the corresponding interface of each functional module and the realization class corresponding to each interface.
For each function module, a mapping container class corresponding to each function module is generated based on a corresponding interface and implementation class of each function module, where the mapping container class may be referred to as a table, and then a fused mapping container class is generated based on the mapping container class corresponding to each function module, where the mapping container class may be referred to as a map. And obtaining the corresponding relation between the corresponding interfaces of the functional modules and the implementation classes corresponding to the interfaces based on the fused mapping container class.
The method comprises the steps that byte codes corresponding to all functional modules can be collected based on an ASM byte code processing framework, the ASM is a java byte code manipulation framework, the ASM byte code processing framework is used for processing class files, and the processed byte codes can be converted into classes. The bytecode corresponding to each function module may be collected based on the ASM, and then the bytecode corresponding to each function module is processed to obtain the mapping container class corresponding to each function module.
It can be understood that the corresponding relationship 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 corresponding relationship is established on the other terminal devices, the corresponding relationship may be invoked through interaction between the user terminal and the other terminal devices.
In the embodiment of the present disclosure, generating a mapping container class corresponding to the function module based on the interface corresponding to the function module and the implementation class corresponding to the interface 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 and 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 correspond to the function module, and based on the class annotation information corresponding to the function module, for example, the class annotation information is @ ServiceImpl, the interface corresponding to the function module and the implementation class corresponding to the interface may be determined. The interface is used as a key, the implementation class is used as a Value, and a k-v corresponding relation is established, that is, a mapping relation between one interface and the implementation class of the interface can be represented by a key-Value pair.
The class annotation information can be obtained from the byte code corresponding to the functional module.
It can be understood that, if the interface has a corresponding interface identifier and the implementation class has a corresponding implementation class identifier, in the correspondence between the key and the Value, the interface identifier may be used as the key, and the implementation class identifier may be used as the Value.
Optionally, the type annotation information corresponding to each functional module may be collected and processed by an APT (association Processing tool) -based annotation processor, and one functional module may correspond to one APT annotation processor.
In an embodiment of the present disclosure, the method further includes:
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 relationship may include a first corresponding relationship between the target interface and a target package interface corresponding to the target interface, and a second corresponding relationship between the target package 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 relationship 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.
Specifically, in order not to directly access the target implementation class, a target packaging class may be correspondingly set for each target implementation class, where the target packaging class is equivalent to an outer package of the target implementation class, the target packaging class corresponds to a target packaging interface, and the target packaging class may be accessed through the target packaging interface. In an alternative, the packaging interface may also correspond to a packaging interface identifier, and the identity of the packaging interface is identified by the packaging interface identifier. The corresponding relationship may include a first corresponding relationship between the interface identifier of the target interface and the identifier of the target packaging interface, and a second corresponding relationship between the identifier of the target packaging interface corresponding to the target interface and the target implementation class identifier.
In addition, the package class is accessed first, then the implementation class is accessed, so that lazy loading can be avoided, namely the package class is compiled instead of the implementation class during initialization, and the calculation amount of compiling the package class is less than that of compiling the implementation class, so that resources can be saved during initialization.
Wherein, if each implementation class corresponds to a package class, the correspondence described above may include a first correspondence between the interface identifier of each interface and the identifier of the package interface corresponding to each interface, and a second corresponding relationship between the identifier of the packaging interface corresponding to each interface and the implementation class identifier corresponding to each interface, when the target implementation class identifier corresponding to the service request is determined based on the target interface identifier and the pre-established corresponding relationship, the target packaging interface identifier corresponding to the target interface identifier may be determined based on the target interface identifier and the first corresponding relationship, namely which target packaging interface corresponds to the target interface, then determining the target implementation class identifier corresponding to the service request based on the target packaging interface identifier and the second corresponding relation, i.e. which wrapper class the target wrapper interface corresponds to, and which implementation class (target implementation class) the wrapper class corresponds to.
In the embodiment of the present disclosure, if the service request further includes a service parameter, based on the target implementation class, performing corresponding service processing on the service request includes:
transmitting the service parameters to a target implementation class through a target packaging interface;
and performing corresponding business processing on the service request based on the target implementation class containing the service parameters.
The method supports the transmission of service parameters when each implementation class has a corresponding packaging class, and specifically means that the method can transmit the service parameters to functions in the implementation classes 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 transmitted to the target implementation class through the corresponding packaging class (the target packaging class corresponding to the target packaging class interface), and then corresponding service processing may be performed on the service request based on the target implementation class including the service parameter. If the service parameter is not included, corresponding business processing can be directly carried out on the service request based on the target implementation class.
In the disclosed scheme, based on the class annotation information @ ServiceImpl, when the method supports service parameter delivery, the class annotation information is changed to @ ServiceImplParam, and the mark function is annotated by using @ ServiceImplProvider, and the function can be a private constructor a non-constructor.
In the embodiment of the present disclosure, the service parameter is an Object array.
After the service parameters are transmitted to the target implementation class, verification can be performed, corresponding service processing is performed on the service request based on the target implementation class containing the service parameters after the verification is passed, and corresponding service processing is not performed if the verification is not passed.
In the embodiment of the present disclosure, the implementation classes include a singleton implementation class and a non-singleton implementation class, and when the target implementation class is the singleton implementation class, determining the target implementation class corresponding to the service request based on the target package interface and the second correspondence 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.
Wherein, a singleton refers to an implementation class that can be compiled only once in a cycle, and a singleton refers to an implementation class that can be compiled multiple times in a cycle. If the single instance implementation class is adopted, direct compiling cannot be carried out, and the corresponding target implementation class needs to be called through a set function. If the service request is a non-singleton implementation class, the compiling can be directly carried out, 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, an embodiment of the present disclosure also provides a service request processing apparatus 20, as shown in fig. 2, where 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 service processing module 240, wherein,
a request obtaining module 210, configured to obtain 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;
a target implementation class determining module 230, configured to determine a target implementation class corresponding to the service request based on the target interface and a pre-established corresponding relationship, where the corresponding relationship is a corresponding relationship between the target interface and the target implementation class;
and the service processing module 240 is configured to perform corresponding service processing on the service request based on the target implementation class.
The service request processing apparatus of the embodiment of the disclosure, when acquiring a service request to be processed, may determine a target interface corresponding to the identifier based on a class object of an interface carried in the service request, and based on the target interface, may know which interface the service request corresponds to, and then based on the target interface and a pre-established correspondence, may determine a target implementation class corresponding to the target interface, that is, based on the correspondence, may determine which implementation class the service request is intended to call, and further, based on the implementation class, perform corresponding service processing on the service request. In the scheme, because the corresponding relation is the corresponding relation between the target interface and the target implementation class, when the implementation class is called, the name of the implementation class does not need to be known, and the corresponding implementation class can be called only by knowing which interface is called, so that the calling of the implementation class can be carried out without adopting a reflection mode, and the system performance is improved.
Optionally, the apparatus further includes a corresponding relationship establishing module, where the corresponding relationship establishing module is configured to:
acquiring a byte code corresponding to a functional module, wherein the functional module corresponds to a service 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.
Optionally, when the mapping container class corresponding to the functional module is generated based on the interface corresponding to the functional module and the implementation class corresponding to the interface, the correspondence establishing module is specifically configured to:
acquiring 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.
Optionally, the apparatus further comprises:
the package generation module is used for generating a target package class corresponding to the target implementation class based on the target implementation class, and the target package class corresponds to a target package interface;
the corresponding relationship includes a first corresponding relationship between the target interface and the target package interface, and a second corresponding relationship between the target package 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 relationship:
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, when performing corresponding service processing on the service request based on the target implementation class:
transmitting the service parameters to a target implementation class through a target packaging interface;
and performing 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 class includes a singleton implementation class and a non-singleton implementation class, and when the target implementation class is the singleton implementation class, the service processing module is specifically configured to, when determining the target implementation class corresponding to the service request based on the target wrapper interface and the second correspondence:
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 embodiment of the present disclosure may execute a service request processing method shown in fig. 1, and the implementation principles thereof are similar, the actions executed by the modules in the service request processing apparatus in the embodiments of the present disclosure correspond to the steps in the service request processing method in the embodiments of the present disclosure, and for the detailed functional description of the modules in the service request processing apparatus, reference may be specifically made to the description in the corresponding service request processing method shown in the foregoing, which is not described herein again.
Based on the same principle as the method in the embodiment of the present disclosure, reference is made to fig. 3, which shows a schematic structural diagram of an electronic device (e.g., a terminal device in fig. 1) 600 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as the processing device 601 hereinafter, and 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, which are specifically shown as follows:
as shown in fig. 3, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with 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 necessary 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 via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, 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 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present 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 contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (Hyper Text Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications 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 network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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 a triggering operation of a user aiming at an image area in a video frame image of a currently played video through a video playing interface; if the video frame image contains the designated object and the image area is the designated area corresponding to the designated object, generating an object information acquisition request aiming at the designated object; based on the object information acquisition request, link information of the specified object is acquired and displayed.
Computer program code for carrying out operations for the present disclosure may be written in any combination of 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the designation of a module or unit does not in some cases constitute a limitation of the unit itself.
The functions described herein above 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: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), 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. A 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, [ example one ] 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 relationship, wherein the corresponding relationship is the corresponding relationship between the target interface and the target implementation class;
and performing corresponding business processing on the service request based on the target implementation class.
According to one or more embodiments of the present disclosure, the correspondence is established by:
acquiring a byte code corresponding to a functional module, wherein the functional module corresponds to a service logic;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the bytecode 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 a mapping container class corresponding to the function module based on the interface corresponding to the function module and the implementation class corresponding to the interface includes:
acquiring 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.
In accordance with 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 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 wrapper interface;
and performing 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 determining a target implementation class corresponding to the service request based on the target wrapper interface and the second corresponding relationship when the target implementation class is a singleton implementation class 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, [ example two ] there is provided a service request processing apparatus comprising:
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;
the target interface determining module is used for determining the target interface based on the class object of the interface;
a target implementation class determining module, configured to determine a target implementation class corresponding to the service request based on the target interface and a pre-established corresponding relationship, where the corresponding relationship is a corresponding relationship between the target interface and the target implementation class;
and the business processing module is used for carrying out corresponding business 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 relationship establishing module, where the correspondence relationship establishing module is configured to:
acquiring a byte code corresponding to a functional module, wherein the functional module corresponds to a service logic;
determining an interface corresponding to the functional module and an implementation class corresponding to the interface based on the bytecode 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, when the mapping container class corresponding to the functional module is generated based on the interface corresponding to the functional module and the implementation class corresponding to the interface, the correspondence establishing module is specifically configured to:
acquiring 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 generation module is used for generating a target package class corresponding to the target implementation class based on the target implementation class, and the target package class corresponds to a target package interface;
the corresponding relationship includes a first corresponding relationship between the target interface and the target package interface, and a second corresponding relationship between the target package 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 a pre-established corresponding relationship:
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 wrapper interface;
and performing 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 class includes a singleton implementation class and a non-singleton implementation class, and when the target implementation class is the singleton implementation class, the service processing module is specifically configured to, when determining the target implementation class corresponding to the service request based on the target wrapper interface and the second correspondence:
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 exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while 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. Under 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 limitations on the scope of the 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 disclosed as example forms of implementing the claims.