Summary of the invention
The present invention proposes the call method and device of a kind of application component, to solve difference Moudle module in the prior artBetween component call it is excessively complicated, cumbersome, the technical issues of causing later maintenance cost higher, reduce usage experience.
First aspect present invention embodiment proposes a kind of call method of application component, comprising: obtains application componentComponent request;According to the component mark inquiry relation mapping table of component request, the component mark of component to be called is determined;RootDetermine that the corresponding component of the component to be called is intended to according to component mark, and described wait adjust according to component intention activationUse component.
The call method of the application component of the embodiment of the present invention determines the component mark of component to be called by relation mapping tableKnow, to find corresponding intention, rather than is directly intended to by the component mark building of component, avoids different Moudle modulesBetween the problem of cannot mutually calling, simplify component call, easy to maintain, effective promotion usage experience, preferably meeting makesWith demand, the calling purpose of application component such as Android inter-module is realized, solves difference Moudle module in the prior artBetween component call problem it is excessively complicated, cumbersome, the technical issues of causing later maintenance cost higher, reduce usage experience.
Second inventive embodiments of the invention propose a kind of calling device of application component, comprising: module are obtained, for obtainingThe component of application component is taken to request;Enquiry module, the component mark inquiry relation mapping table for being requested according to the component, reallyThe component mark of fixed component to be called;Calling module, for determining that the component to be called is corresponding according to component markComponent is intended to, and is intended to activate the component to be called according to the component.
The calling device of the application component of the embodiment of the present invention determines the component mark of component to be called by relation mapping tableKnow, to find corresponding intention, rather than is directly intended to by the component mark building of component, avoids different Moudle modulesBetween the problem of cannot mutually calling, simplify component call, easy to maintain, effective promotion usage experience, preferably meeting makesWith demand, the calling purpose of application component such as Android inter-module is realized, solves difference Moudle module in the prior artBetween component call problem it is excessively complicated, cumbersome, the technical issues of causing later maintenance cost higher, reduce usage experience.
Third aspect present invention embodiment proposes a kind of computer equipment, including processor and memory;Wherein, describedProcessor is corresponding with the executable program code to run by reading the executable program code stored in the memoryProgram, with the call method for realizing the application component as described in above-mentioned one side embodiment.
Fourth aspect present invention embodiment proposes a kind of computer readable storage medium, is stored thereon with computer journeySequence realizes the called side of the application component as described in above-mentioned one side embodiment when the computer program is executed by processorMethod.
The additional aspect of the present invention and advantage will be set forth in part in the description, and will partially become from the following descriptionObviously, or practice through the invention is recognized.
Specific embodiment
The embodiment of the present invention is described below in detail, examples of the embodiments are shown in the accompanying drawings, wherein from beginning to endSame or similar label indicates same or similar element or element with the same or similar functions.Below with reference to attachedThe embodiment of figure description is exemplary, it is intended to is used to explain the present invention, and is not considered as limiting the invention.
The call method and device of the application component proposed according to embodiments of the present invention are described with reference to the accompanying drawings, first willDescribe the call method of the application component proposed according to embodiments of the present invention with reference to the accompanying drawings.
For in above-mentioned background, mentioning since each Moudle module is not completely independent, it is sometimes desirable to call otherThe component of Moudle module, but between each Moudle module and complementary relationship is not present, it is therefore desirable to a callingProcess, but call flow is excessively complicated in the prior art, cumbersome, not only later maintenance cost is higher, and reduces and use bodyIt tests, is unable to satisfy use demand, all present invention propose a kind of call method of application component, may be implemented to manage and maintain eachThe routing module called between component effectively solves the problems, such as the component call between this disparate modules, keeps component call simpleChange, it is easy to maintain.
Fig. 1 is a kind of flow diagram of the call method of application component provided by the embodiment of the present invention.
As shown in Figure 1, the call method of the application component of the embodiment of the present invention, comprising:
In step s101, the component request of application component is obtained.
It will describe in detail by taking Android component as an example to the calling of application component in following part of the invention.ThoughRight following embodiment is by taking Android component as an example, it will be understood by those skilled in the art that for any application componentIt can be configured by following similar fashion, the present invention simultaneously loses and is limited to Android component.
It is understood that the embodiment of the present invention is to realize to manage and maintain the routing module called between each component, it canThe request of the component of the calling of each Android component is regarded as a route requests, such as opens new page, opens service,So as to externally provide a display intention or hidden schematic diagram according to constructing variable.
In step s 102, according to the component mark inquiry relation mapping table of component request, the group of component to be called is determinedPart mark.
It should be noted that compared with the prior art, the embodiment of the present invention can be identified by component and find corresponding meaningFigure, rather than be directly intended to by the component mark building of component, so as to avoid what cannot mutually be called between disparate modulesProblem.
Wherein, in one embodiment of the invention, requested according to component component mark inquiry relation mapping table itBefore, method further include: each application component is marked by explaining, to generate the component mark of each application component;According to eachThe component mark and component mark of application component pass through class generator production Methods mapping table.
Optionally, in one embodiment of the invention, component mark may include in bytecode, packet name and class name informationIt is one or more.
It is understood that the value being stored in the key-value pair in mapping table can be bytecode, it is also possible to Android groupThe information such as the packet name of part, class name, can be configured as the case may be, be not particularly limited herein.
For example, for the ease of later maintenance and management, as a kind of possible implementation, the embodiment of the present invention pairIn the collection of the module information of Android, it can be explained by addition@Route onto the class of associated component, be given in the noteComponent distributes a unique character string key (such as@Route (key=" login ") is used in above the Activity logged in), intoAnd in compilation process, by annotation processor collect the packet names of all Android components explained by@Route, class name,Bytecode and the corresponding character string key of routing, form the data of a Map structure, wherein key is to obtain from Router noteThe character string key arrived, value be packet name, class name, bytecode Information encapsulation object, to generate Router class, i.e. compiling durationBetween can pass through class generator generate Router class java file.
For module information is formed mapping table, the static state that can be Map in one structure of procedure initialization for generating classMember mTable, wherein key is character string, is worth for call request.It is internal publicly-owned to traverse the module information generation being collected into aboveThe interface Const and static code block of access authority take character string key and module information value, and key are turned capitalizationIt is added in Const interface as member name using key member as value, module information is configured to call by factory class and is askedIt asks, character string key and call request is added in mTable, and then form the relationship map of call request and component markTable.
Further, in one embodiment of the invention, before obtaining the component request of application component, method is also wrappedIt includes: when starting application program, initialization routing, and will be in the memory of relation mapping table deposit routing.
Can with and understand, using explain mark Android component, to component distribute a unique key after, volumeIt translates the phase to collect the key explained and be annotated the class bytecode marked, the mapping table in routing class is generated by class generator, is madeInitialization routing when obtaining application program launching, will be in the Map of mapping relations deposit memory.
In step s 103, it determines that the corresponding component of component to be called is intended to according to component mark, and is intended to according to componentActivate component to be called.
Specifically, dependence library of the Router as the bottom needs each Module module using routing in projectDependent on the library Router, so that compiling duration can obtain all Android components explained by@Route, and will be allThe Android component of Module module is all stored in the same mapping table, realizes that disparate modules pass through the side of key or urlFormula can call directly the Android component of other modules.
Further, in one embodiment of the invention, component request includes call parameters, wherein is anticipated according to componentFigure activates component to be called, comprising: additional call parameters are intended to component, it is to be called to be intended to activation by the component after addingComponent.
It is understood that using key and the parameter for needing to pass to component after the Map of mapping relations deposit memoryCall request is constructed, the key that route internal is requested in mapping table Map by query calls, obtaining needs Android to be startedThe component of component identifies, and determines that the Android component for needing to call is intended to, and gives and be intended to the additional calling ginseng for passing to componentNumber, and then by being intended to activate component to be called.
Further, in one embodiment of the invention, the corresponding component of component to be called is determined according to component markIt is intended to, comprising: the function of search request and/or the function according to url invocation component are added, to determine component by bean enginesIt is intended to.
It is understood that bean engines can be used as the middleware between routing and request, effect is according to characterString key finds corresponding request, and to request corresponding intention additional parameter and flag, and execution request etc..
Wherein, to find corresponding request, as a kind of mode in the cards, the embodiment of the present invention can be RouterClass adds power function, such as adds the function of search request, wherein the call parameters of function are the key of character string type, functionFunction can be according to key search mTable in call request, for another example add the function according to url invocation component, whereinArrange url rule so that parsing url, can obtain component name in path and component type and parameter, by component name andComponent type, constructs corresponding bean engines, and parameter is formed bundle, is added to bean engines, to pass through bean enginesCorresponding intention can be found by character string, rather than is directly intended to by the component mark building of Android component, effectivelyIt avoids the problem that mutually calling between disparate modules.
To sum up, the embodiment of the present invention supports the mode invocation component of url, without giving the longer url of component definition, onlyAs soon as needing a brief title abbreviation, can support to call by way of url
The call flow for simplifying the prior art supports chain type calling
Therefore, the component call problem between disparate modules not only may be implemented in the embodiment of the present invention, and makes component tuneIt is easy to maintain with simplification.
The call method of application component according to an embodiment of the present invention determines the group of component to be called by relation mapping tablePart mark to find corresponding intention, rather than is directly intended to by the component mark building of component, avoids different MoudleThe problem of cannot mutually calling between module, simplifies component call, easy to maintain, effectively promotion usage experience, preferably fullSufficient use demand realizes the calling purpose between application component, solves the group between difference Moudle module in the prior artPart calls problem excessively complicated, cumbersome, the technical issues of causing later maintenance cost higher, reduce usage experience.
Referring next to the calling device for the application component that attached drawing description proposes according to embodiments of the present invention.
Fig. 2 is a kind of structural schematic diagram of the calling device of application component provided by the embodiment of the present invention.
As shown in Fig. 2, the calling device 10 of the application component includes: to obtain module 100, enquiry module and calling module300。
Wherein, the component request that module 100 obtains application component is obtained.The component that enquiry module 200 is requested according to componentMark inquiry relation mapping table determines the component mark of component to be called.Calling module 300 is to be called according to component mark determinationThe corresponding component of component is intended to, and is intended to activate component to be called according to component.Calling device 10 according to an embodiment of the present inventionThe component mark that component to be called can be determined by relation mapping table, to find corresponding intention, rather than directly passes through groupThe component mark building of part is intended to, and avoids the problem of cannot mutually calling between different Moudle modules, keeps component call simpleDan Hua, it is easy to maintain, usage experience is effectively promoted, is preferably satisfied the use demand.
Further, in one embodiment of the present of invention kind, the device 10 of the embodiment of the present invention further include: labeling module andGeneration module.Wherein, labeling module marks each application component by explaining, to generate the component mark of each application component.Generation module passes through class generator production Methods mapping table according to the component of each application component mark and component mark.
Further, in one embodiment of the present of invention kind, the device 10 of the embodiment of the present invention further include: pre- storing module.Wherein, pre- storing module is when starting application program, initialization routing, and will be in the memory of relation mapping table deposit routing.
Further, in one embodiment of the present of invention kind, calling module 300 includes: processing unit.Wherein, processing is singleMember is intended to additional call parameters to component, to be intended to activate component to be called by the component after adding.
Further, in one embodiment of the present of invention kind, calling module 300 is further used for adding the letter of search requestFunction several and/or according to url invocation component, to determine that component is intended to by bean engines.
It should be noted that the explanation of the aforementioned call method embodiment to application component is also applied for the embodimentApplication component calling device, details are not described herein again.
The calling device of application component according to an embodiment of the present invention determines the group of component to be called by relation mapping tablePart mark to find corresponding intention, rather than is directly intended to by the component mark building of component, avoids different MoudleThe problem of cannot mutually calling between module, simplifies component call, easy to maintain, effectively promotion usage experience, preferably fullSufficient use demand realizes the calling purpose between application component, solves the group between difference Moudle module in the prior artPart calls problem excessively complicated, cumbersome, the technical issues of causing later maintenance cost higher, reduce usage experience.
In order to realize above-described embodiment, the embodiment of the present invention also proposes a kind of computer equipment, including processor and storageDevice;Wherein, processor is run and the executable program code by reading the executable program code stored in memoryCorresponding program, with the call method for realizing the application component as described in above-described embodiment.
In order to realize above-described embodiment, the embodiment of the present invention also proposes a kind of computer readable storage medium, stores thereonThere is computer program, the call method of the application component as described in above-described embodiment is realized when which is executed by processor.
In addition, term " first ", " second " are used for descriptive purposes only and cannot be understood as indicating or suggesting relative importanceOr implicitly indicate the quantity of indicated technical characteristic.Define " first " as a result, the feature of " second " can be expressed orImplicitly include at least one this feature.In the description of the present invention, the meaning of " plurality " is at least two, such as two, threeIt is a etc., unless otherwise specifically defined.
In the description of this specification, reference term " one embodiment ", " some embodiments ", " example ", " specifically showThe description of example " or " some examples " etc. means specific features, structure, material or spy described in conjunction with this embodiment or examplePoint is included at least one embodiment or example of the invention.In the present specification, schematic expression of the above terms are notIt must be directed to identical embodiment or example.Moreover, particular features, structures, materials, or characteristics described can be in officeIt can be combined in any suitable manner in one or more embodiment or examples.In addition, without conflicting with each other, the skill of this fieldArt personnel can tie the feature of different embodiments or examples described in this specification and different embodiments or examplesIt closes and combines.
Although the embodiments of the present invention has been shown and described above, it is to be understood that above-described embodiment is exampleProperty, it is not considered as limiting the invention, those skilled in the art within the scope of the invention can be to above-mentionedEmbodiment is changed, modifies, replacement and variant.