CN108196900B - Component registration method and device - Google Patents
Component registration method and device Download PDFInfo
- Publication number
- CN108196900B CN108196900B CN201711296126.8A CN201711296126A CN108196900B CN 108196900 B CN108196900 B CN 108196900B CN 201711296126 A CN201711296126 A CN 201711296126A CN 108196900 B CN108196900 B CN 108196900B
- Authority
- CN
- China
- Prior art keywords
- component
- code
- system process
- registration
- macro
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 41
- 230000026676 system process Effects 0.000 claims abstract description 49
- 238000012545 processing Methods 0.000 abstract description 3
- 230000006870 function Effects 0.000 description 13
- 239000011800 void material Substances 0.000 description 6
- 238000010586 diagram Methods 0.000 description 2
- 239000003550 marker Substances 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention provides a component registration method and device. The method comprises the following steps: the terminal equipment loads the target file of the component through a first system process; and when the target file of the component is loaded, the terminal equipment calls an Application Program Interface (API) providing a component registration function through a second system process to register the component. The invention avoids the registration processing of the component by explicitly calling the API which provides the registration function before the component is called by the application software, and realizes the decoupling of the component registration and the component calling.
Description
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for registering a component.
Background
The component is an important research object in application software development, and reuse and decoupling can be realized by packaging views, data, methods and the like.
In the prior art, before the application software uses the component, the component needs to be registered. Registration of a component is typically accomplished by explicitly calling an Application Programming Interface (API) that provides component registration functionality prior to the component call. For example, the application software calls an API component at the entry of the page loader to complete component registration.
However, there is a problem that component registration is coupled with component invocation significantly.
Disclosure of Invention
The invention provides a component registration method and device, which are used for solving the problem that component registration and component calling are coupled greatly in the prior art.
In a first aspect, the present invention provides a method for registering a component, including:
the terminal equipment loads the target file of the component through a first system process;
when the target file of the component is loaded, the terminal equipment calls an Application Program Interface (API) providing a component registration function through a second system process to register the component;
the first system process and the second system process are the same process, or the first system process and the second system process are different processes.
Optionally, the object file of the component includes:
the binary code corresponding to the first code for registering the component through the API, and the binary code corresponding to the second code for automatically executing the first code when the file is loaded.
Optionally, the source file corresponding to the target file includes a component registration macro, and the first code and the second code are encapsulated in a macro definition of the component registration macro.
In a second aspect, the present invention provides a device for registering a component, comprising:
the loading module is used for loading the target file of the component through the first system process;
the execution module is used for calling an Application Program Interface (API) providing a component registration function through a second system process to register the component when the target file of the component is loaded;
the first system process and the second system process are the same process, or the first system process and the second system process are different processes.
Optionally, the object file of the component includes:
the binary code corresponding to the first code for registering the component through the API, and the binary code corresponding to the second code for automatically executing the first code when the file is loaded.
Optionally, the source file corresponding to the target file includes a component registration macro, and the first code and the second code are encapsulated in a macro definition of the component registration macro.
According to the component registration method and device, when the target file of the component is loaded, the terminal device calls the API providing the component registration function through the second system process to register the component, so that the condition that application software explicitly calls the API providing the registration function to register the component before the component is called is avoided, and the decoupling of component registration and component calling is realized.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart of a first embodiment of a component registration method of the present invention;
FIG. 2 is a flowchart of a third embodiment of a method for registering a component of the present invention;
FIG. 3 is a block diagram of an embodiment of a registration apparatus of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart of a first embodiment of a method for registering a component according to the present invention, where an execution main body of the method of the present embodiment may be a terminal device with an operating system deployed, for example, a computer, a mobile phone, a tablet computer, and the like. As shown in fig. 1, the method of this embodiment may include:
In this step, the first system process may specifically be a system process of an operating system deployed on the terminal device. The components may be components defined in application software. The object file of the component may be an object file obtained after compiling a source file of the component.
And 102, when the target file of the component is loaded, the terminal equipment calls an Application Program Interface (API) providing a component registration function through a second system process to register the component.
In this step, the second system process may specifically be a system process of an operating system deployed on the terminal device. The first system process and the second system process may be the same process or different processes. Since the operating system deployed on the terminal device will generally provide a method that is automatically executed when the target file is completely loaded, for example, a load method provided by the iOS operating system implemented based on Objective C language, an API that provides a component registration function may be automatically called by a second system process of the operating system through the method to register the component.
In this embodiment, when the target file of the component is loaded, the terminal device calls the API that provides the component registration function through the second system process to register the component, so that processing of registering the component by explicitly calling the API that provides the registration function before the component is called by the application software is avoided, and decoupling of component registration and component calling is realized.
Embodiment two of registration method of component
Optionally, on the basis of the first embodiment of the component registration method, the target file of the component includes:
the binary code corresponding to the first code for registering the component through the API, and the binary code corresponding to the second code for automatically executing the first code when the file is loaded. Wherein,
the first code may be, for example: (void) register Module { [ ModuleFactory. shared Instance register ModuleWithKey: module Keywith ModuleLarasName: ModuleLarasName ] };
among them, the register module is an API providing a component registration function.
The second code may be, for example: (void) load { register Module (self); }
Further optionally, the source file corresponding to the target file includes a component registration macro, and the macro definition of the component registration macro encapsulates the first code and the second code.
The macro definition of the component registration macro may be, for example:
#define REGISTER_MODULE(moduleKey)\
+(void)registerModule{[ModuleFactory.sharedInstance registerModuleWithKey:moduleKey withModuleClassName:moduleClassName];}\
+(void)load{RegisterModule(self);}
wherein the macro name that the component REGISTERs the macro is REGISTER _ mode. The macro encapsulates the first code and the second code.
In this embodiment, the target file of the component includes the binary code corresponding to the first code for calling the API to register the component, and the binary code corresponding to the second code for automatically executing the first code when the file is completely loaded, so that when the target file of the component is completely loaded, the terminal device automatically calls the API for providing the component registration function through a system process to register the component. In addition, the source file of the component comprises the component registration macro, and the first code and the second code are encapsulated in the macro definition of the component registration macro, so that when the API is changed, only the macro definition of the component registration macro needs to be modified, and the software implementation is simplified.
Fig. 2 is a flowchart of a third embodiment of the registration method of the component of the present invention, and this embodiment mainly describes an overall flow from software development to software operation on the basis of the second embodiment of the method. As shown in fig. 2, the method of this embodiment may include:
Specifically, the first code and the second code are encapsulated into a component registration macro using a define syntax.
For example, # define REGISTER _ module (moduleKey) \
+(void)registerModule{[ModuleFactory.sharedInstanceregisterModuleWithKey:moduleKey withModuleClassName:moduleClassName];}\
+(void)load{RegisterModule(self);}
Specifically, pre-compiled markers corresponding to the component registration macros are laid down at the components. For example as shown in the following examples:
@interface WBAreaManager:NSObject
@end
@implementation RCTWBAreaManager
REGISTER _ mode (WB _ AREA); // this line is coded as a pre-compiled marker for tiling
@end
The above code registers the WBAreaManager component in the WBAreaManager component, and the API of the component registration is encapsulated in the macro. It can be seen that there is no component in the component to register the relevant code of the API, only one precompiled macro. In this way, component registration is completely loosely coupled with component code.
And 203, carrying out macro replacement when compiling the source file of the component, and generating a target file of the component.
Specifically, when the source file of the component is compiled, the compiler will replace the macro where it is defined into the corresponding first code and second code.
And step 204, loading the target file of the component, and registering the component when the loading is finished.
Specifically, the first system process loads the target file of the component, and when the target file of the component is completely loaded, the second system process automatically executes the code for registering the component.
In the embodiment, the component registration codes are packaged into the component registration macros by using the define syntax, the precompilation marks are laid at the components to generate the source files of the components, the macros are replaced when the source files of the components are compiled to generate the target files of the components, the target files of the components are loaded and the components are registered when the loading is completed, so that the registration processing of the components by explicitly calling an API (application programming interface) providing a registration function before the components are called by application software is avoided, and the decoupling of component registration and component calling is realized.
Fig. 3 is a schematic structural diagram of an embodiment of a registration apparatus of a component in the present invention, and the apparatus provided in this embodiment may be applied to the foregoing method embodiment to implement the function of the terminal device. As shown in fig. 3, the apparatus of the present embodiment may include: a load module 301 and an execute module 302.
The loading module 301 is configured to load a target file of a component through a first system process;
an execution module 302, configured to, when the target file of the component is completely loaded, call, by a second system process, an application program interface API that provides a component registration function to register the component;
the first system process and the second system process are the same process, or the first system process and the second system process are different processes.
Optionally, the object file of the component includes:
the binary code corresponding to the first code for registering the component through the API, and the binary code corresponding to the second code for automatically executing the first code when the file is loaded.
Optionally, the source file corresponding to the target file includes a component registration macro, and the first code and the second code are encapsulated in a macro definition of the component registration macro.
The apparatus of this embodiment may be used to implement the technical solutions of the first embodiment, the second embodiment, and the third embodiment of the registration method of the component, and the implementation principles and technical effects are similar, which are not described herein again.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (6)
1. A method for registering a component, comprising:
encapsulating the component registration code into a component registration macro;
laying a pre-compiled mark at a component and generating a source file of the component;
macro replacement is carried out when a source file of the component is compiled, and a target file of the component is generated;
the terminal equipment loads the target file of the component through a first system process;
when the target file of the component is loaded, the terminal equipment calls an Application Program Interface (API) providing a component registration function through a second system process to register the component;
the first system process and the second system process are the same process, or the first system process and the second system process are different processes.
2. The method of claim 1, wherein the object file of the component comprises:
the binary code corresponding to the first code for registering the component through the API, and the binary code corresponding to the second code for automatically executing the first code when the file is loaded.
3. The method according to claim 2, wherein a source file corresponding to the target file comprises a component registration macro, and the first code and the second code are encapsulated in a macro definition of the component registration macro.
4. An apparatus for registering a component, comprising:
a loading module for encapsulating the component registration code into a component registration macro; laying a pre-compiled mark at a component and generating a source file of the component; macro replacement is carried out when a source file of the component is compiled, and a target file of the component is generated; the system comprises a first system process, a second system process and a third system process, wherein the first system process is used for loading a target file of a component;
the execution module is used for calling an Application Program Interface (API) providing a component registration function through a second system process to register the component when the target file of the component is loaded;
the first system process and the second system process are the same process, or the first system process and the second system process are different processes.
5. The apparatus of claim 4, wherein the object file of the component comprises:
the binary code corresponding to the first code for registering the component through the API, and the binary code corresponding to the second code for automatically executing the first code when the file is loaded.
6. The apparatus according to claim 5, wherein a source file corresponding to the target file includes a component registration macro, and the first code and the second code are encapsulated in a macro definition of the component registration macro.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711296126.8A CN108196900B (en) | 2017-12-08 | 2017-12-08 | Component registration method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711296126.8A CN108196900B (en) | 2017-12-08 | 2017-12-08 | Component registration method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108196900A CN108196900A (en) | 2018-06-22 |
CN108196900B true CN108196900B (en) | 2021-11-09 |
Family
ID=62573705
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711296126.8A Active CN108196900B (en) | 2017-12-08 | 2017-12-08 | Component registration method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108196900B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101876898A (en) * | 2009-11-12 | 2010-11-03 | 北京东方网力科技有限公司 | Registration method of COM assembly and device thereof |
CN102007756A (en) * | 2008-04-24 | 2011-04-06 | 国际商业机器公司 | Method and apparatus for dynamic provisioning in data processing environment |
CN106126282A (en) * | 2016-06-20 | 2016-11-16 | 北京金山安全软件有限公司 | Injection method and device for dynamic link library file and terminal equipment |
CN107291480A (en) * | 2017-08-15 | 2017-10-24 | 中国农业银行股份有限公司 | A kind of function calling method and device |
Family Cites Families (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8204968B2 (en) * | 2008-12-03 | 2012-06-19 | At&T Mobility Ii Llc | Registration notification for mobile device management |
CN102073520A (en) * | 2010-12-30 | 2011-05-25 | 中国民航信息网络股份有限公司 | Dynamic management system and method for C++ application program version |
JP5879920B2 (en) * | 2011-10-21 | 2016-03-08 | 株式会社リコー | Image processing apparatus, image processing method, and program |
CN103336813B (en) * | 2013-06-27 | 2018-03-27 | 南京邮电大学 | A kind of Internet of Things data integrated management scheme based on middleware framework |
CN103605516B (en) * | 2013-11-12 | 2016-08-17 | 国家电网公司 | Flexible Web display frame model architecture method for designing |
CN103955364B (en) * | 2014-04-15 | 2017-06-20 | 南威软件股份有限公司 | A kind of front end assemblies method suitable for mobile phone |
CN104125275B (en) * | 2014-07-21 | 2017-08-25 | 浪潮电子信息产业股份有限公司 | A kind of safety service system based on dynamic scalable security service bus and engine container suite system |
CN106155755B (en) * | 2015-06-03 | 2020-06-23 | 上海红神信息技术有限公司 | Program compilation method and program compiler |
CN105205358B (en) * | 2015-09-21 | 2018-01-05 | 中科信息安全共性技术国家工程研究中心有限公司 | The method and detection method that a kind of identification Android APP are reinforced |
CN105763369B (en) * | 2016-02-04 | 2018-08-17 | 湖南长城信息金融设备有限责任公司 | A kind of terminal unit remote software version distribution method and system |
CN105809029B (en) * | 2016-03-03 | 2019-06-14 | 珠海豹趣科技有限公司 | A kind of method and device intercepting driver operation |
CN106169046A (en) * | 2016-07-04 | 2016-11-30 | 北京金山安全软件有限公司 | Method and device for preventing message hook injection and terminal equipment |
CN107368317A (en) * | 2017-07-24 | 2017-11-21 | 无锡江南计算技术研究所 | A kind of multiplexing of Web application modules and heavily loaded system and method |
-
2017
- 2017-12-08 CN CN201711296126.8A patent/CN108196900B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102007756A (en) * | 2008-04-24 | 2011-04-06 | 国际商业机器公司 | Method and apparatus for dynamic provisioning in data processing environment |
CN101876898A (en) * | 2009-11-12 | 2010-11-03 | 北京东方网力科技有限公司 | Registration method of COM assembly and device thereof |
CN106126282A (en) * | 2016-06-20 | 2016-11-16 | 北京金山安全软件有限公司 | Injection method and device for dynamic link library file and terminal equipment |
CN107291480A (en) * | 2017-08-15 | 2017-10-24 | 中国农业银行股份有限公司 | A kind of function calling method and device |
Also Published As
Publication number | Publication date |
---|---|
CN108196900A (en) | 2018-06-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107943469B (en) | Intelligent contract issuing method and device | |
CN107045438B (en) | Application top view processing method, device and component | |
CN110673853B (en) | Compiling method, device and system | |
US8756616B2 (en) | System and method for reducing the static footprint of mixed-language JAVA classes | |
US8464230B2 (en) | Methods and systems to implement non-ABI conforming features across unseen interfaces | |
EP3296906A1 (en) | Method for protecting dex file from being decompiled in android system | |
CN103902859A (en) | Code protecting method and system based on hook technology in JAVA | |
CN109933350B (en) | Method and device for embedding codes in application and electronic equipment | |
CN104536737A (en) | Program development framework based on assemblies | |
CN105159738A (en) | Hot patch implementation method and system | |
CN101957766B (en) | Method, device and system for weaving byte code | |
CN105975816A (en) | Method and system for code protection based on virtual technology under mobile terminal | |
CN106775781B (en) | Method and device for reducing application installation packages and electronic equipment | |
CN104267981A (en) | Method and device for loading application layout on desktop | |
CN106775754A (en) | The compatible processing method and processing device of application | |
CN105094878B (en) | A method and device for integrating system library files | |
CN105404794A (en) | Protection method and device of Java application software | |
CN106598662B (en) | Android-based application loading method and device | |
CN105373411A (en) | On-board programming system and design method for on-board digital signal processor | |
CN103885784B (en) | Method for establishing Android platform with security module and plugging function | |
CN108196900B (en) | Component registration method and device | |
CN105005497A (en) | Method and apparatus for calling local function in Java card virtual machine | |
CN105373384B (en) | A kind of software development methodology and device | |
CN104133669B (en) | A kind of control method and terminal device of desktop application | |
CN110413270A (en) | A general method and device for creating dbus objects |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |