Code call method and device
Technical field
This disclosure relates to field of computer technology, in particular to a kind of code call method and device.
Background technique
With the popularity of the internet, content information becomes increasingly complex, and number of users and amount of access are increasing, business and scene
Also more and more.For each business scenario, developer generally requires exploitation Multiple Code, and same function code is not by of the same trade or business
Be engaged in code reference when, generally require to be coupled in the same method body with each service code, have very strong invasive, increase business is patrolled
There is the risk of bug when collecting modification.Moreover, change service code is still required, further when needing to delete the function code
It increases complication system and the risk of bug occurs.
It should be noted that information is only used for reinforcing the reason to the background of the disclosure disclosed in above-mentioned background technology part
Solution, therefore may include the information not constituted to the prior art known to persons of ordinary skill in the art.
Summary of the invention
The disclosure is designed to provide a kind of code call method and code calling device, at least to a certain degree
On overcome caused by the limitation and defect due to the relevant technologies in code invocation procedure it is invasive it is strong, increase system reliability wind
The problem of danger.
According to the first aspect of the embodiments of the present disclosure, a kind of code call method is provided, comprising: response method calling disappears
Breath detects whether called Java method includes default note, and the default note record has executable logic;If the quilt
Call method includes default note, executes the whole executable logic in all default notes;It is held according to described
The implementing result of row logic executes the service code in the called method.
In a kind of exemplary embodiment of the disclosure, the executable logic includes cache logic, the cache logic
Sequence, custom parameter are executed including cache key, caching expired time, caching type, caching type, caching.
In a kind of exemplary embodiment of the disclosure, default explain includes default note group, the default note
It include multiple default notes with setting execution sequence in group.
It is described according to the execution of the implementing result of the executable logic in a kind of exemplary embodiment of the disclosure
Service code in called method includes:
When the executable logic is used for reading cache data, according to the data cached execution service code;
When the executable logic is used for memory buffers data, it is described data cached to obtain to execute the service code
And it stores into caching.
In a kind of exemplary embodiment of the disclosure, the default note derives from customized note by adding manually
Note template in Xie Ku.
It is described according to the execution of the implementing result of the executable logic in a kind of exemplary embodiment of the disclosure
Service code in called method includes:
Determined whether to execute part or all in the service code according to the implementing result.
In a kind of exemplary embodiment of the disclosure, it can be held described in the whole executed in all default notes
Row logic includes:
The executable logic being performed simultaneously in multiple default notes.
According to the second aspect of an embodiment of the present disclosure, a kind of code calling device is provided, comprising:
Blocking module is called, response method is set as and calls message, detects whether called Java method includes default note
Solution, the default note record have executable logic;Execution module is explained, if it includes default for being set as the called method
It explains, executes the whole executable logic in all default notes;Service code execution module is set as according to institute
The implementing result for stating executable logic executes service code in the called method.
According to the third aspect of the disclosure, a kind of electronic equipment is provided, comprising: memory;And it is coupled to affiliated storage
The processor of device, the processor is configured to the instruction based on storage in the memory, executes such as above-mentioned any one
The method.
According to the fourth aspect of the disclosure, a kind of computer readable storage medium is provided, program is stored thereon with, the program
The code call method as described in above-mentioned any one is realized when being executed by processor.
The code call method that the embodiment of the present disclosure provides is by infusing the executable code modified according to template setting
Xie Zhong, and so that executable code is influenced service code in such a way that addition is explained, it can call to avoid code to service code
Intrusion, neatly increase, delete, change function code, improve the reliability of system.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not
The disclosure can be limited.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows the implementation for meeting the disclosure
Example, and together with specification for explaining the principles of this disclosure.It should be evident that the accompanying drawings in the following description is only the disclosure
Some embodiments for those of ordinary skill in the art without creative efforts, can also basis
These attached drawings obtain other attached drawings.
Fig. 1 is the flow chart of code call method in disclosure exemplary embodiment.
Fig. 2A and Fig. 2 B is the schematic diagram that cache logic is executed in disclosure exemplary embodiment.
Fig. 3 is a kind of block diagram of code calling device in one exemplary embodiment of the disclosure.
Fig. 4 is the block diagram of a kind of electronic equipment in one exemplary embodiment of the disclosure.
Fig. 5 is a kind of schematic diagram of computer readable storage medium in one exemplary embodiment of the disclosure.
Specific embodiment
Example embodiment is described more fully with reference to the drawings.However, example embodiment can be with a variety of shapes
Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, thesing embodiments are provided so that the disclosure will more
Fully and completely, and by the design of example embodiment comprehensively it is communicated to those skilled in the art.Described feature, knot
Structure or characteristic can be incorporated in any suitable manner in one or more embodiments.In the following description, it provides perhaps
More details fully understand embodiment of the present disclosure to provide.It will be appreciated, however, by one skilled in the art that can
It is omitted with technical solution of the disclosure one or more in the specific detail, or others side can be used
Method, constituent element, device, step etc..In other cases, be not shown in detail or describe known solution to avoid a presumptuous guest usurps the role of the host and
So that all aspects of this disclosure thicken.
In addition, attached drawing is only the schematic illustrations of the disclosure, identical appended drawing reference indicates same or similar portion in figure
Point, thus repetition thereof will be omitted.Some block diagrams shown in the drawings are functional entitys, not necessarily necessary and object
The entity managed or be logically independent is corresponding.These functional entitys can be realized using software form, or in one or more
These functional entitys are realized in hardware module or integrated circuit, or in heterogeneous networks and/or processor device and/or microcontroller
These functional entitys are realized in device.
Disclosure example embodiment is described in detail with reference to the accompanying drawing.
Fig. 1 schematically shows the flow chart of code call method in disclosure exemplary embodiment.With reference to Fig. 1, code tune
May include: with method 100
Step S102, response method call message, detect whether called Java method includes default note, described default
Explaining record has executable logic;
Step S104 executes the whole in all default notes if the called method includes default note
The executable logic;
Step S106 executes the service code in the called method according to the implementing result of the executable logic.
The code call method that the embodiment of the present disclosure provides is by infusing the executable code modified according to template setting
Xie Zhong, and so that executable code is influenced service code in such a way that addition is explained, it can call to avoid code to service code
Intrusion, neatly increase, delete, change function code, improve the reliability of system.
In the following, each step to code call method 100 is described in detail.
In step S102, response method calls message, detects whether called Java method includes default note, described pre-
If explaining record has executable logic.
The method that the disclosure provides can be completed by the code controller being independently arranged.The code controller can supervise
It listens Java method to call message, intercepts called Java method, and detect whether the Java method includes default note.
Note is a kind of data for describing data in Java, is commonly used in description method, and in the embodiments of the present disclosure, it will
The access interface as executable logic is explained, to call non-traffic code using note addition, modification and the convenience deleted
Executable logic.In the embodiments of the present disclosure, note is rewritten, or it may be said that by executable code to explain
Form is presented.It whether include that this record has and can hold in code controller detection method body after hold-up interception method calls message
The default note of row logic, if so, entering step S104.
This includes that the pre-set code of executable logic can be written as template in advance and be stored in customized note library
In, so that different service codes calls.When note is preset in addition, the template explained in library need to be only called, and according to specific
Service code rewrites note.
It can be by increasing default note to realize the addition to calling function, since note is without invasive, addition note
The process of solution will not impact service code structure, realize code calling without invasive.It needs to delete calling function
When, it is only necessary to the deletion that function can be conveniently realized by deleting default note reduces system reliability without changing service code
Risk.If necessary to modify called function, it is only necessary to which modification is explained, and will not be impacted to service code structure.
In step S104, if the called method includes default note, execute complete in all default notes
Logic can be performed described in portion.
It is different from conventional code call method, it is detected before running service code in the embodiment of the present disclosure all default
It explains, and executes whole executable codes in all default notes before running service code, with executable according to these
The implementing result of logic judges the executive mode of service logic.
In one embodiment of the present disclosure, executable logic includes cache logic, cache logic include cache key,
Caching expired time, caching type, caching type, caching execute sequence, custom parameter etc..I.e. in this embodiment,
Default note can be used for executing caching, the type of caching such as storing data or access evidence.At this point, one default
Note both can be set to only execute caching, may be set to be a series of can be performed that execution includes caching and patrols
Volume.When default note is only used for executing caching, different operation type, different expired times, difference can be sequentially carried out
The caching of data class.
Efficiency is called in order to further increase code, default note group can also be set, and sequentially by default note group
The executable code of multiple functions is executed to realize complicated function.
Default note group both can by explaining the template addition in library, can also by multiple note template occasional combinations and
At.It include multiple default notes in default note group, these default execution sequences explained are set when generating default note group
It is fixed.When multiple default notes in default note group are all set to execute caching, which can be real
The function of existing cache group.
Further, since find multiple default notes or default note group simultaneously may be performed simultaneously not in synchronization
With the executable logic in default note group, efficiency is called to improve code.
In step S106, in the business generation in the called method, is executed according to the implementing result of the executable logic
Code.
When default explain for executing cache logic, service code can be controlled according to the actual situation and be predetermined note
The mode that implementing result influences.For example, when executable logic is used for reading cache data, according to data cached execution business generation
Code;When executable logic is used for memory buffers data, service code is executed to obtain data cached and store into caching.I.e. such as
It needs to carry out storing data using service code in fruit executable code, can be gone to latency services code when being related to the data again
Data are stored in and are cached.
Fig. 2A and Fig. 2 B is the schematic diagram that cache logic is executed in the embodiment of the present disclosure.
With reference to Fig. 2A, when executing read data operation with default note, it is not necessary to modify service codes, are executing business generation
It only needs directly to take pre- first carry out when code and default explains obtained data.
With reference to Fig. 2 B, when executing storing data operation with default note, when it come to counted in service logic implementation procedure
It is operated according to storage, code controller executes data storage behaviour in default explain parallel while service logic normally executes
Make, does not influence the execution of service logic.At this point, addition, delete and modify relevant cache logic code will not be to business generation
Code impacts.
It can be determined whether to execute part or all in service code according to the implementing result of executable logic.
For example, the execution that some module in service code can be set needs to carry out condition judgement, and patrolled can be performed in default note
The implementing result collected is set as judging keyword, to realize the whole control to service code.Further, it is also possible to according to executable
The implementing result of logic executes sequence control each module in service code.
In conclusion funcall flexibly without intrusion may be implemented in the code call method that the embodiment of the present disclosure provides,
The function and execution of service code are controlled under the premise of not modifying service code, flexibly addition and deletion function, it can be very big
The reliability and development efficiency of raising system.
Corresponding to above method embodiment, the disclosure also provides a kind of code calling device, can be used for executing above-mentioned side
Method embodiment.
Fig. 3 schematically shows a kind of block diagram of code calling device in one exemplary embodiment of the disclosure.
With reference to Fig. 3, code calling device 300 may include:
Blocking module 302 is called, response method is set as and calls message, detects whether called Java method includes presetting
It explains, the default note record has executable logic;
Execution module 304 is explained, if being set as the called method includes default note, is executed all described default
The whole executable logic in note;
Service code execution module 306 is set as being executed according to the implementing result of the executable logic described called
Service code in method.
In a kind of exemplary embodiment of the disclosure, the executable logic includes cache logic, the cache logic
Sequence, custom parameter are executed including cache key, caching expired time, caching type, caching type, caching.
In a kind of exemplary embodiment of the disclosure, default explain includes default note group, the default note
It include multiple default notes with setting execution sequence in group.
In a kind of exemplary embodiment of the disclosure, service code execution module 306 is arranged are as follows:
When the executable logic is used for reading cache data, according to the data cached execution service code;
When the executable logic is used for memory buffers data, it is described data cached to obtain to execute the service code
And it stores into caching.
In a kind of exemplary embodiment of the disclosure, the default note derives from customized note by adding manually
Note template in Xie Ku.
In a kind of exemplary embodiment of the disclosure, service code execution module 306 is arranged are as follows:
Determined whether to execute part or all in the service code according to the implementing result.
In a kind of exemplary embodiment of the disclosure, explains execution module 304 and is arranged are as follows:
The executable logic being performed simultaneously in multiple default notes.
Since each function of device 300 has been described in detail in its corresponding embodiment of the method, the disclosure in this not
It repeats again.
It should be noted that although being referred to several modules or list for acting the equipment executed in the above detailed description
Member, but this division is not enforceable.In fact, according to embodiment of the present disclosure, it is above-described two or more
Module or the feature and function of unit can embody in a module or unit.Conversely, an above-described mould
The feature and function of block or unit can be to be embodied by multiple modules or unit with further division.
In an exemplary embodiment of the disclosure, a kind of electronic equipment that can be realized the above method is additionally provided.
Person of ordinary skill in the field it is understood that various aspects of the invention can be implemented as system, method or
Program product.Therefore, various aspects of the invention can be embodied in the following forms, it may be assumed that complete hardware embodiment, complete
The embodiment combined in terms of full Software Implementation (including firmware, microcode etc.) or hardware and software, can unite here
Referred to as circuit, " module " or " system ".
The electronic equipment 400 of this embodiment according to the present invention is described referring to Fig. 4.The electronics that Fig. 4 is shown
Equipment 400 is only an example, should not function to the embodiment of the present invention and use scope bring any restrictions.
As shown in figure 4, electronic equipment 400 is showed in the form of universal computing device.The component of electronic equipment 400 can wrap
It includes but is not limited to: at least one above-mentioned processing unit 410, at least one above-mentioned storage unit 420, the different system components of connection
The bus 430 of (including storage unit 420 and processing unit 410).
Wherein, the storage unit is stored with program code, and said program code can be held by the processing unit 410
Row, so that various according to the present invention described in the execution of the processing unit 410 above-mentioned " illustrative methods " part of this specification
The step of illustrative embodiments.For example, the processing unit 410 can execute step S102: responder as shown in fig. 1
Method calls message, detects whether called Java method includes default note, the default note record has executable logic;Step
Rapid S104: if the called method includes default note, the whole executed in all default notes is described executable
Logic;Step S104: the service code in the called method is executed according to the implementing result of the executable logic.
Storage unit 420 may include the readable medium of volatile memory cell form, such as Random Access Storage Unit
(RAM) 4201 and/or cache memory unit 4202, it can further include read-only memory unit (ROM) 4203.
Storage unit 420 can also include program/utility with one group of (at least one) program module 4205
4204, such program module 4205 includes but is not limited to: operating system, one or more application program, other program moulds
It may include the realization of network environment in block and program data, each of these examples or certain combination.
Bus 430 can be to indicate one of a few class bus structures or a variety of, including storage unit bus or storage
Cell controller, peripheral bus, graphics acceleration port, processing unit use any bus structures in a variety of bus structures
Local bus.
Electronic equipment 400 can also be with one or more external equipments 700 (such as keyboard, sensing equipment, bluetooth equipment
Deng) communication, can also be enabled a user to one or more equipment interact with the electronic equipment 400 communicate, and/or with make
Any equipment (such as the router, modulation /demodulation that the electronic equipment 400 can be communicated with one or more of the other calculating equipment
Device etc.) communication.This communication can be carried out by input/output (I/O) interface 450.Also, electronic equipment 400 can be with
By network adapter 460 and one or more network (such as local area network (LAN), wide area network (WAN) and/or public network,
Such as internet) communication.As shown, network adapter 460 is communicated by bus 430 with other modules of electronic equipment 400.
It should be understood that although not shown in the drawings, other hardware and/or software module can not used in conjunction with electronic equipment 400, including but not
Be limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive and
Data backup storage system etc..
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented
Mode can also be realized by software realization in such a way that software is in conjunction with necessary hardware.Therefore, according to the disclosure
The technical solution of embodiment can be embodied in the form of software products, which can store non-volatile at one
Property storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) in or network on, including some instructions are so that a calculating
Equipment (can be personal computer, server, terminal installation or network equipment etc.) is executed according to disclosure embodiment
Method.
In an exemplary embodiment of the disclosure, a kind of computer readable storage medium is additionally provided, energy is stored thereon with
Enough realize the program product of this specification above method.In some possible embodiments, various aspects of the invention may be used also
In the form of being embodied as a kind of program product comprising program code, when described program product is run on the terminal device, institute
Program code is stated for executing the terminal device described in above-mentioned " illustrative methods " part of this specification according to this hair
The step of bright various illustrative embodiments.
Refering to what is shown in Fig. 5, describing the program product for realizing the above method of embodiment according to the present invention
500, can using portable compact disc read only memory (CD-ROM) and including program code, and can in terminal device,
Such as it is run on PC.However, program product of the invention is without being limited thereto, in this document, readable storage medium storing program for executing can be with
To be any include or the tangible medium of storage program, the program can be commanded execution system, device or device use or
It is in connection.
Described program product can be using any combination of one or more readable mediums.Readable medium can be readable letter
Number medium or readable storage medium storing program for executing.Readable storage medium storing program for executing for example can be but be not limited to electricity, magnetic, optical, electromagnetic, infrared ray or
System, device or the device of semiconductor, or any above combination.The more specific example of readable storage medium storing program for executing is (non exhaustive
List) include: electrical connection with one or more conducting wires, portable disc, hard disk, random access memory (RAM), read-only
Memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read only memory
(CD-ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.
Computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal,
In carry readable program code.The data-signal of this propagation can take various forms, including but not limited to electromagnetic signal,
Optical signal or above-mentioned any appropriate combination.Readable signal medium can also be any readable Jie other than readable storage medium storing program for executing
Matter, the readable medium can send, propagate or transmit for by instruction execution system, device or device use or and its
The program of combined use.
The program code for including on readable medium can transmit with any suitable medium, including but not limited to wirelessly, have
Line, optical cable, RF etc. or above-mentioned any appropriate combination.
The program for executing operation of the present invention can be write with any combination of one or more programming languages
Code, described program design language include object oriented program language-Java, C++ etc., further include conventional
Procedural programming language-such as " C " language or similar programming language.Program code can be fully in user
It calculates and executes in equipment, partly executes on a user device, being executed as an independent software package, partially in user's calculating
Upper side point is executed on a remote computing or is executed in remote computing device or server completely.It is being related to far
Journey calculates in the situation of equipment, and remote computing device can pass through the network of any kind, including local area network (LAN) or wide area network
(WAN), it is connected to user calculating equipment, or, it may be connected to external computing device (such as utilize ISP
To be connected by internet).
In addition, above-mentioned attached drawing is only the schematic theory of processing included by method according to an exemplary embodiment of the present invention
It is bright, rather than limit purpose.It can be readily appreciated that the time that above-mentioned processing shown in the drawings did not indicated or limited these processing is suitable
Sequence.In addition, be also easy to understand, these processing, which can be, for example either synchronously or asynchronously to be executed in multiple modules.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to its of the disclosure
Its embodiment.This application is intended to cover any variations, uses, or adaptations of the disclosure, these modifications, purposes or
Person's adaptive change follows the general principles of this disclosure and including the undocumented common knowledge in the art of the disclosure
Or conventional techniques.The description and examples are only to be considered as illustrative, and the true scope of the disclosure and design are wanted by right
It asks and points out.