CN107291458B - Plug-in construction method and system for Web application and server - Google Patents

Plug-in construction method and system for Web application and server Download PDF

Info

Publication number
CN107291458B
CN107291458B CN201710431511.2A CN201710431511A CN107291458B CN 107291458 B CN107291458 B CN 107291458B CN 201710431511 A CN201710431511 A CN 201710431511A CN 107291458 B CN107291458 B CN 107291458B
Authority
CN
China
Prior art keywords
plug
code
client
server
web application
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
Application number
CN201710431511.2A
Other languages
Chinese (zh)
Other versions
CN107291458A (en
Inventor
赵凌风
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Knownsec Information Technology Co Ltd
Original Assignee
Beijing Knownsec Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Knownsec Information Technology Co Ltd filed Critical Beijing Knownsec Information Technology Co Ltd
Priority to CN201710431511.2A priority Critical patent/CN107291458B/en
Publication of CN107291458A publication Critical patent/CN107291458A/en
Application granted granted Critical
Publication of CN107291458B publication Critical patent/CN107291458B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/22Procedural

Abstract

The invention discloses a plug-in construction method and a system for Web application, wherein the method comprises the following steps: scanning a plug-in directory, and installing a corresponding dependency library for each plug-in the plug-in directory; initializing Web server side service, registering a general component and creating a server application instance corresponding to the Web application, wherein the general component comprises static resource service; for each plug-in each plug-in, if the plug-in code of each plug-in comprises a server-side code, acquiring and analyzing a server-side registration code of the plug-in so as to inject a server-side execution code of the plug-in into a server application instance; initializing Web client service and providing a client entrance corresponding to Web application; and for each plug-in the plug-ins, if the plug-in codes of the plug-ins comprise client codes, packaging the client codes, and putting the client codes into a static resource directory as static resources so as to provide the static resources to the client through a static resource service, so that the construction of the Web application is completed.

Description

Plug-in construction method and system for Web application and server
Technical Field
The invention relates to the field of internet technology and software architecture, in particular to a method, a system, a server and computing equipment for constructing a plug-in of Web application.
Background
In the field of software architecture, it is always desirable to build systems composed of plug-ins or components to replace the overall style. The whole style is that a complete application is used as a development unit, the interior of the development unit is naturally divided into a client, a server and a database, but with the expansion of service functions, the maintenance difficulty of the whole style is increased, the coupling depth among modules is difficult to control, and troubles are brought to release, maintenance and expansion. And the plug-in style refers to the form of developing small services into a single application, each application can be independently developed, independently replaced and independently updated. When the boundaries of the plug-ins are determined, the plug-in style is divided around the business functions, so that the minimum centralized management of each plug-in is realized.
Nowadays, with the rapid development of internet technology, Web applications are widely popularized and used, and for Web applications, if an overall style is used for application construction, functions facing a client and a server are easily confused, so that modules are deeply coupled, and the later maintenance and updating are not facilitated, so that the Web applications are usually constructed by adopting a plug-in style.
In the existing plug-in construction method of the Web application, a node.js-based Web application back-end development framework represented by Express and Koa provides a scheme for enhancing the Web application by using middleware, various functions are extracted from the application and added into the framework as the middleware, but the middleware is not suitable for realizing business logic, and the back-end development framework can not provide front-end functions, if a user interface needs to be realized additionally, the development of the business functions is still based on the integral style. On the other hand, for the front-end function, common user interfaces such as a sidebar and a bulletin board aiming at presentation often define plug-ins included in the user interfaces, cannot support variable service scenes, and the plug-ins are unrelated and cannot be dependent or linked with each other, and as a front-end technology, the realization of a back end is not involved. Therefore, a new plug-in construction method of Web application is needed to optimize the above process.
Disclosure of Invention
To this end, the present invention provides a solution for a plug-in construction of a Web application in an attempt to solve or at least alleviate the above existing problems.
According to one aspect of the present invention, a plug-in construction method for a Web application is provided, which is suitable for being executed in a server, the Web application is suitable for being generated by a plurality of plug-in combinations, each plug-in has a corresponding dependency library and plug-in codes, the plug-in codes comprise server-side codes and/or client-side codes, the server-side codes comprise server-side registration codes and server-side execution codes, and the method comprises the following steps: firstly, scanning a plug-in directory, and installing a corresponding dependency library for each plug-in the plug-in directory; initializing Web server side service, registering a general component and creating a server application instance corresponding to the Web application, wherein the general component comprises static resource service; for each plug-in each plug-in, if the plug-in code of each plug-in comprises a server-side code, acquiring and analyzing a server-side registration code of the plug-in so as to inject a server-side execution code of the plug-in into a server application instance; initializing Web client service and providing a client entrance corresponding to Web application; and for each plug-in the plug-ins, if the plug-in codes of the plug-ins comprise client codes, packaging the client codes, and putting the client codes into a static resource directory as static resources so as to provide the static resources to the client through a static resource service, so that the construction of the Web application is completed.
Optionally, in the plug-in construction method of the Web application according to the present invention, the step of creating the server application instance corresponding to the Web application includes: reading initialization configuration information of Web server side service, wherein the initialization configuration information comprises basic configuration of Web application; and creating a server application instance corresponding to the Web application according to the basic configuration.
Optionally, in the plug-in construction method of the Web application according to the present invention, the basic configuration includes an IP address of the Web server side service and a monitored port.
Optionally, in the plug-in construction method of a Web application according to the present invention, after the step of creating a server application instance corresponding to the Web application, the method further includes: and traversing all the plug-ins in the plug-in directory, acquiring the configuration files of all the plug-ins, and exporting the configuration files.
Optionally, in the plug-in construction method of the Web application according to the present invention, the configuration file includes a plug-in ID, a server-side code entry and/or a client-side code entry.
Optionally, in the plug-in construction method of a Web application according to the present invention, the method further includes: acquiring a client code entry from a configuration file; and obtaining a path of the corresponding client code according to the client code entry, and finding the client code through the path.
Optionally, in the plug-in construction method of the Web application according to the present invention, the client code includes a client registration code and a client execution code, and before the step of packaging the client code, the method further includes: analyzing the client code to obtain a plug-in ID corresponding to the client code and complete the registration of the corresponding plug-in; and putting the analyzed plug-ins into the plug-in set so as to search the corresponding plug-ins from the plug-in set through the plug-in IDs to call.
According to a further aspect of the present invention, there is provided a plug-in building system for a Web application, the system being adapted to reside in a server, the Web application being adapted to be generated by a plurality of plug-in combinations, each plug-in having a corresponding dependency library and plug-in code, the plug-in code comprising server-side code and/or client-side code, the server-side code comprising server-side registration code and server-side execution code, the system comprising an installation module, a first initialization module, a first processing module, a second initialization module and a second processing module. The installation module is suitable for scanning the plug-in catalog and installing a corresponding dependency library for each plug-in the plug-in catalog; the first initialization module is suitable for initializing Web server side service, registering a general component and creating a server application instance corresponding to the Web application, wherein the general component comprises static resource service; the first processing module is suitable for acquiring and resolving a server side registration code of each plug-in when the plug-in code of each plug-in comprises a server side code so as to inject the server side execution code of the plug-in into the server application example; the second initialization module is suitable for initializing Web client service and providing a client entrance corresponding to the Web application; the second processing module is suitable for packaging the client code when the plug-in code of each plug-in comprises the client code and putting the client code into the static resource directory as a static resource so as to provide the static resource to the client through the static resource service to complete the construction of the Web application.
Optionally, in the plug-in building system of a Web application according to the present invention, the first initialization module is further adapted to: reading initialization configuration information of Web server side service, wherein the initialization configuration information comprises basic configuration of Web application; and creating a server application instance corresponding to the Web application according to the basic configuration.
Optionally, in the plug-in building system of the Web application according to the present invention, the basic configuration includes an IP address of the Web server side service and a port for monitoring.
Optionally, in the plug-in building system of a Web application according to the present invention, further comprising an export module adapted to: and traversing all the plug-ins in the plug-in directory, acquiring the configuration files of all the plug-ins, and exporting the configuration files.
Optionally, in the plug-in construction system of the Web application according to the present invention, the configuration file includes a plug-in ID, a server-side code entry and/or a client-side code entry.
Optionally, in the plug-in building system of a Web application according to the present invention, the plug-in building system further includes an obtaining module adapted to: acquiring a client code entry from a configuration file; and obtaining a path of the corresponding client code according to the client code entry, and finding the client code through the path.
Optionally, in the plug-in building system of a Web application according to the present invention, the client code includes a client registration code and a client execution code, and the second processing module is further adapted to: analyzing the client code to obtain a plug-in ID corresponding to the client code and complete the registration of the corresponding plug-in; and putting the analyzed plug-ins into the plug-in set so as to search the corresponding plug-ins from the plug-in set through the plug-in IDs to call.
According to a further aspect of the invention, a server is provided comprising a plug-in building system for a Web application according to the invention.
According to yet another aspect of the present invention there is provided a computing device comprising one or more processors, memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising instructions for performing a plug-in build method for a Web application according to the present invention.
According to yet another aspect of the present invention, there is also provided a computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a computing device, cause the computing device to perform a method of plug-in construction of a Web application according to the present invention.
According to the technical scheme of the plug-in construction of the Web application, firstly, a dependency library for each plug-in to form the Web application is installed, Web server side service is initialized to create a server application instance for the Web application, for the plug-in with plug-in codes comprising server side codes, server side execution codes of the plug-in are injected into the server application instance, Web client side service is initialized, for the plug-in with plug-in codes comprising client side codes, the client side codes are packaged to be used as static resources and placed into a static resource directory so as to be provided for a client side, and therefore the construction of the Web application is completed. In the technical scheme, the basic functions of the server side do not need to be repeatedly developed when other Web applications are subsequently developed by providing the basic Web server side service, and each plug-in can be reused, so that one-time development and multiple use are realized. Moreover, one plug-in can integrate the logics of the Web server side and the Web client side, in other words, one plug-in can provide back-end and front-end functions together, and the usability and compatibility of the plug-in are enhanced. Meanwhile, each plug-in is a single-function and independent plug-in developed after the Web application is decomposed from the service perspective, so that mutual decoupling between the plug-ins is realized, and the influence of other plug-ins is not required to be considered during development. The functions of other plug-ins need to be used, package codes do not need to be developed, calling can be directly carried out, and replacement, upgrading or elimination of one plug-in does not affect other plug-ins, so that the dependency relationship among the plug-ins is clearer and can be maintained.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a block diagram of a computing device 100, according to an embodiment of the invention;
FIG. 2 illustrates a flow diagram of a method 200 for plug-in construction of a Web application according to one embodiment of the present invention;
FIG. 3 illustrates a schematic diagram of a plug-in build system 300 for a Web application according to one embodiment of the present invention; and
FIG. 4 shows a schematic diagram of a plug-in build system 400 for a Web application according to yet another embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Fig. 1 is a block diagram of an example computing device 100. In a basic configuration 102, computing device 100 typically includes system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between the processor 104 and the system memory 106.
Depending on the desired configuration, the processor 104 may be any type of processing, including but not limited to a microprocessor (μ P), a microcontroller (μ C), a digital information processor (DSP), or any combination thereof the processor 104 may include one or more levels of cache, such as a level one cache 110 and a level two cache 112, a processor core 114, and registers 116 the example processor core 114 may include an arithmetic logic unit (A L U), a Floating Point Unit (FPU), a digital signal processing core (DSP core), or any combination thereof the example memory controller 118 may be used with the processor 104 or, in some implementations, the memory controller 118 may be an internal part of the processor 104.
Depending on the desired configuration, system memory 106 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 106 may include an operating system 120, one or more applications 122, and program data 124. In some embodiments, application 122 may be arranged to operate with program data 124 on an operating system.
Computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus/interface controller 130. The example output device 142 includes a graphics processing unit 148 and an audio processing unit 150. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 158. An example communication device 146 may include a network controller 160, which may be arranged to facilitate communications with one or more other computing devices 162 over a network communication link via one or more communication ports 164.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes made in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
Computing device 100 may be implemented as a server, such as a file server, a database server, an application server, a WEB server, etc., or as part of a small-form factor portable (or mobile) electronic device, such as a cellular telephone, a Personal Digital Assistant (PDA), a personal media player device, a wireless WEB-watch device, a personal headset device, an application specific device, or a hybrid device that include any of the above functions. Computing device 100 may also be implemented as a personal computer including both desktop and notebook computer configurations.
In some embodiments, the computing device 100 is implemented as a server configured to execute the plug-in build method 200 of a Web application according to the present invention. The application 122 includes a plug-in build system 300 for Web applications in accordance with the present invention. The Web application is suitable for being generated by a plurality of plug-in combinations, each plug-in has a corresponding dependency library and plug-in codes, the plug-in codes comprise server-side codes and/or client-side codes, and the server-side codes comprise server-side registration codes and server-side execution codes. Therefore, plug-ins can be divided into three types, wherein the first type is server-side plug-ins, the plug-in codes only comprise server-side codes, the second type is client-side plug-ins, the plug-in codes only comprise client-side codes, the third type is mixed plug-ins, the plug-in codes comprise both server-side codes and client-side codes, and the mixed plug-ins can be understood as a combination of one server-side plug-in and one client-side plug-in. Meanwhile, a server-side code corresponding to the appointed plug-in is developed into a component of hapi.
FIG. 2 illustrates a flow diagram of a method 200 for plug-in construction of a Web application according to one embodiment of the invention. The plug-in construction method 200 of a Web application is suitable for execution in a computing device 100 implemented as a server, such as the computing device 100 shown in fig. 1.
As shown in fig. 2, the method 200 begins at step S210. In step S210, the plug-in directory is scanned, and a corresponding dependency library is installed for each plug-in the plug-in directory. According to an embodiment of the present invention, the path of the plug-in directory is/config/plugins, and the structure of the plug-in directory is as follows:
Figure BDA0001313910240000071
Figure BDA0001313910240000081
in this embodiment, the plugin directories are found and scanned according to the paths/config/plugins, and the scanned plugins, such as plugins, are installed with corresponding dependency libraries, where the dependency libraries generally refer to third-party open source libraries, which are developed and maintained by the open source community, following an open source protocol such as GP L (General Public L icense ), and conventional dependency libraries include act.js, hapi.js, and webpack.js.
Subsequently, step S220 is entered, where the Web server side service is initialized, a generic component is registered, and a server application instance corresponding to the Web application is created, where the generic component includes a static resource service. According to one embodiment of the invention, after initializing Web server side service, a universal component is registered, wherein the universal component comprises static resource service, a database and the like, and then a server application instance corresponding to the Web application is created in the following way. The method comprises the steps of firstly reading initialization configuration information of Web server side service, wherein the initialization configuration information comprises basic configuration of Web application, and then creating a server application instance corresponding to the Web application according to the basic configuration. The basic configuration comprises an IP address of the Web server side service and a monitored port. As can be seen from an example of the plug-in directory given in step S210, a path of the global configuration file is/configuration/configuration.yml, and initialization configuration information of the Web server side service is stored in the global configuration file configuration.yml, basic information in the initialization configuration information is obtained, an IP address of the Web server side service in the basic information is configured as server.host:127.0.0.1, and a monitored port is configured as server.port:9999, so that the server side service of the Web application is started on a local 9999 port, where the created server is a server application instance corresponding to the Web application and is responsible for monitoring the port, receiving external requests, sending responses, and other server side logical entities.
After the creation of the server application example corresponding to the Web application is completed, if the subsequent steps are to be executed continuously, the configuration file of each plug-in is also required to be acquired, so that the server-side code and/or the client-side code of each plug-in is found based on the configuration file, and the subsequent plug-in code processing is performed. According to one embodiment of the invention, after the server application instance corresponding to the Web application is created, all plugins in the plugin directory are traversed, the configuration file of each plugin is obtained, and the configuration file is exported. Wherein the configuration file comprises the plug-in ID, the server-side code entry and/or the client-side code entry. In this embodiment, the configuration file of the plug-in is usually named index. For example, the rights management plug-in has a configuration file of/plug ins/authplug-in/index. js, and the contents are as follows:
import auth from'./server/auth';
export function declarePlugin(platform){
return new platform.Plugin({
id:'auth',
ui:{main:'./client'},
server:async server(server){
await auth(server);},
});
}
the configuration file of the plug-in as shown above declares that the plug-in ID is auth, and respectively gives a client code entry and a server code entry of the plug-in, wherein the client code entry is seen in the ui part of the configuration file, and the server code entry is seen in the server part of the configuration file. It can be understood that the configuration file of the plug-in actually provides a function, the input and output forms of the function are agreed in advance, if the configuration file does not give agreed output, the plug-in cannot be analyzed and added, and the configuration file is an illegal configuration file. Furthermore, in the actual processing, a legal configuration file needs to be selected from the obtained configuration files according to the differentiation rule and exported, so as to search the server-side code and/or the client-side code corresponding to the plug-in from the legal configuration file.
Considering that the plug-ins are classified into three types, namely server-side plug-ins, client-side plug-ins and hybrid plug-ins, the server-side plug-ins only need to acquire corresponding server-side codes, the client-side plug-ins only need to acquire corresponding client-side codes, and the hybrid plug-ins need to acquire corresponding server-side codes and client-side codes. According to an embodiment of the invention, when the server-side code corresponding to the server-side plug-in and the hybrid plug-in is obtained, the server-side code entry is obtained from the legal configuration file, then the path of the corresponding server-side code is obtained according to the server-side code entry, and the server-side code is found through the path, and when the client-side code corresponding to the client-side plug-in and the hybrid plug-in is obtained, the client-side code entry is obtained from the legal configuration file, then the path of the corresponding client-side code is obtained according to the client-side code entry, and the client-side code is found through the path. For example, the rights management plug-in authplug-in is obviously a hybrid plug-in, if a server-side code of the plug-in is to be obtained, a server-side code entry, i.e., contents of a server part, is obtained from the configuration file/plugins/authplug-in/index.js, and then a path of a corresponding server-side code is obtained to search for the server-side code, and if a client-side code of the plug-in is to be obtained, a client-side code entry, i.e., contents of a ui part, is obtained from the configuration file/plugins/authplug-in/index.js, and then a path of a corresponding client-side code is obtained to search for the client-side code.
Next, step S230 is entered, and for each plugin in the plugins, if the plugin code includes a server-side code, the server-side registration code of the plugin is obtained and analyzed, so as to inject the server-side execution code of the plugin into the server application instance. According to an embodiment of the invention, the plug-in codes of the server-side plug-in and the hybrid plug-in both include corresponding server-side codes, and for the two types of plug-ins, the server-side registration codes of the plug-ins are acquired and analyzed, and the server-side execution codes of the plug-ins are injected into the server application instance by executing the server-side registration codes. The server side executing code is actually similar to a route, the injected route is added into a corresponding monitoring list, and once a request for the route is received, the request is forwarded to a corresponding plug-in for processing, and relevant codes of the injection process are as follows:
v/plug-in calls plug-in constructor create plug-in instance
module.exports=platform=>new platform.Plugin({
id:'mysql_node',
server:async server=>{
await mysqlNode(server);},
});
// Call register inject plug-in instances
server.register(plugins,err=>handleErr(err,server));
In step S240, the Web client service is initialized, and a client entry corresponding to the Web application is provided. According to one embodiment of the invention, after the Web client service is initialized, a single data source is provided in addition to the client entry corresponding to the Web application. In this embodiment, the single data source refers to the reduce technology, and the maintenance of the client component state is simplified and clear by aggregating the data or state originally held by each component of the client into one storage container Store and passing through the unidirectional data stream layer. The detailed implementation of Redux technology is a mature prior art and is not described herein.
After the Web client service is initialized, step S250 should be executed to perform packaging processing on the client plug-ins and the client codes corresponding to the hybrid plug-ins, but before packaging, plug-ins corresponding to the client codes need to be registered. According to one embodiment of the invention, the client codes comprise client registration codes and client execution codes, the client codes are analyzed before being packaged to obtain the plug-in IDs corresponding to the client codes and complete the registration of the corresponding plug-ins, and then the analyzed plug-ins are put into the plug-in assembly set so as to search the corresponding plug-ins from the plug-in assembly set through the plug-in IDs for calling. Since only the client plug-in and the hybrid plug-in have corresponding client codes, in this embodiment, the client plug-in may be further divided into a routed client plug-in and a non-routed client plug-in, and the hybrid plug-in is composed of a server plug-in and a routed client plug-in.
For a routed client plug-in, it typically corresponds to one or several pages, such as the AuthPlugin providing "/location", "/signup" pages. At this time, after the client code of the client plug-in with the route is analyzed, the plug-in ID corresponding to the client code is obtained as auth, and the client plug-in with the route is mounted in the client route registered by the client plug-in with the route according to the use of read-Router, so that the registration of the corresponding plug-in is completed, wherein the related codes are as follows:
// plug-in calls addReducer and addRouteConfig to pass routing configuration and status functions
Register.addReducer('auth',auth);
Register.addRouteConfig({
path:'/auth',
indexRoute:{component:require('./containers/Auth').default},
});
// client routing Using React-Router, mounting a plug-in to its registration
ReactDOM.render(
<Provider store={store}>
<Router history={history}routes={{childRoutes:modules}}/>
</Provider>,
……
);
It should be noted that, in the actual processing process, similar client side plug-ins with routes and server side plug-ins with routes take effect after registration is completed, and the client side plug-ins without routes can start working by accessing corresponding routes, but the client side plug-ins without routes are different. For a client plugin without a route, which is a common component used on a page, such as a table, a pop-up box, and the like, after registration of the client plugin without a route is completed, the parsed plugin needs to be put into a plugin set, so that a corresponding plugin is searched from the plugin set through a plugin ID to be called, and then rendered into the page, where relevant codes are as follows:
// plug-in calls addHook to join plug-in set
Register.addHook(DataTable,{hook:'DataTable'});
Obtaining plug-in according to plug-in ID and converting into React interface element
const hook=hooks[plugin_name];
React.createElement(hook,{children:this.props.children})
Finally, step S250 is performed, and for each plug-in each plug-in, if the plug-in code includes the client code, the client code is packaged and put into the static resource directory as the static resource so as to be provided to the client through the static resource service, so as to complete the construction of the Web application. According to an embodiment of the present invention, a client code corresponding to a client plug-in and a hybrid plug-in is packaged, and is put into a static resource directory as a static resource, for example, a "/dist/assets" folder is put into the static resource directory, where the "/dist/assets" folder is an example of the static resource directory, and is specifically shown as follows:
Figure BDA0001313910240000121
Figure BDA0001313910240000131
after the Web application is constructed, the plug-in ID and the version number of each plug-in can be obtained from a package.
FIG. 3 shows a schematic diagram of a plug-in build system 300 for Web applications, according to one embodiment of the invention. As shown in fig. 3, the plug-in building system 300 of the Web application includes an installation module 310, a first initialization module 320, a first processing module 330, a second initialization module 340, and a second processing module 350.
The installation module 310 is adapted to scan the plug-in directory and install a corresponding dependency library for each plug-in the plug-in directory.
The first initialization module 320 is connected to the installation module 310 and is adapted to initialize Web server side services, register general components including static resource services, and create server application instances corresponding to Web applications. The first initialization module 320 is further adapted to: reading initialization configuration information of Web server side service, wherein the initialization configuration information comprises basic configuration of Web application; and creating a server application instance corresponding to the Web application according to the basic configuration. The basic configuration comprises an IP address of the Web server side service and a monitored port.
The first processing module 330 is connected to the first initialization module 320 and is adapted to, for each of the plug-ins, when the plug-in code thereof includes a server-side code, obtain and parse the server-side registration code of the plug-in, so as to inject the server-side execution code of the plug-in into the server application instance.
The second initialization module 340 is connected to the installation module 310 and adapted to initialize the Web client service and provide a client portal corresponding to the Web application.
The second processing module 350 is connected to the first initialization module 320 and the second initialization module 340, respectively, and is adapted to, for each of the plug-ins, package the client code when the plug-in code thereof includes the client code, and place the client code as a static resource into the static resource directory so as to be provided to the client through the static resource service, so as to complete the construction of the Web application. The client codes include client registration codes and client execution codes, and the second processing module 350 is further adapted to analyze the client codes to obtain plug-in IDs corresponding to the client codes and complete registration of corresponding plug-ins; and putting the analyzed plug-ins into the plug-in set so as to search the corresponding plug-ins from the plug-in set through the plug-in IDs to call.
FIG. 4 shows a schematic diagram of a plug-in build system 400 for Web applications according to yet another embodiment of the invention. As shown in fig. 4, the installation module 410, the first initialization module 420, the first processing module 430, the second initialization module 440, and the second processing module 450 of the plug-in construction system 400 of the Web application correspond to the installation module 310, the first initialization module 320, the first processing module 330, the second initialization module 340, and the second processing module 350 of the plug-in construction system 300 of the Web application in fig. 3 one to one, and are consistent, and the derivation module 460 and the acquisition module 470 are added.
Export module 460 is adapted to traverse all plugins in the plugin directory, obtain configuration files for each plugin, and export the configuration files. Wherein the configuration file comprises the plug-in ID, the server-side code entry and/or the client-side code entry.
The obtaining module 470 is connected to the second processing module 450 and the exporting module 460, respectively, and is adapted to obtain a client code entry from the configuration file; and obtaining a path of the corresponding client code according to the client code entry, and finding the client code through the path.
Specific steps and embodiments of the plug-in construction of the Web application are disclosed in detail in the description based on fig. 2, and are not described herein again.
In the conventional plug-in construction method of Web application, a front-end function cannot be provided on back-end development, the used middleware is not suitable for realizing business logic, the development of the business function is mainly based on an integral style, and for the front-end development, variable business scenes are difficult to support, and plug-ins are not associated, cannot be mutually dependent or linked and do not relate to the realization of the back-end. According to the technical scheme of the plug-in construction of the Web application, firstly, a dependency library for each plug-in to form the Web application is installed, Web server side service is initialized to create a server application instance for the Web application, for the plug-in with a plug-in code comprising a server side code, a server side execution code of the plug-in is injected into the server application instance, Web client side service is initialized, and for the plug-in with a plug-in code comprising a client side code, the client side code is packaged to be used as a static resource and put into a static resource directory so as to be provided for a client side, so that the construction of the Web application is completed. In the technical scheme, the basic functions of the server side do not need to be repeatedly developed when other Web applications are subsequently developed by providing the basic Web server side service, and each plug-in can be reused, so that one-time development and multiple use are realized. Moreover, one plug-in can integrate the logics of the Web server side and the Web client side, in other words, one plug-in can provide back-end and front-end functions together, and the usability and compatibility of the plug-in are enhanced. Meanwhile, each plug-in is a single-function and independent plug-in developed after the Web application is decomposed from the service perspective, so that mutual decoupling between the plug-ins is realized, and the influence of other plug-ins is not required to be considered during development. The functions of other plug-ins need to be used, package codes do not need to be developed, calling can be directly carried out, and replacement, upgrading or elimination of one plug-in does not affect other plug-ins, so that the dependency relationship among the plug-ins is clearer and can be maintained.
A7. The method of any of a1-6, the client code comprising client registration code and client execution code, the method further comprising, prior to the step of packaging the client code:
analyzing the client code to obtain a plug-in ID corresponding to the client code and complete the registration of the corresponding plug-in;
and putting the resolved plug-ins into a plug-in set so as to search corresponding plug-ins from the plug-in set through the plug-in IDs for calling.
B9. The system of B8, the first initialization module further adapted to:
reading initialization configuration information of the Web server side service, wherein the initialization configuration information comprises basic configuration of the Web application;
and creating a server application instance corresponding to the Web application according to the basic configuration.
B10. The system of B9, the base configuration including an IP address of the Web server side service and a port to listen on.
B11. The system of any one of B8-10, further comprising an export module adapted to:
and traversing all the plug-ins in the plug-in directory, acquiring the configuration files of all the plug-ins, and exporting the configuration files.
B12. The system of B11, the configuration file including a plug-in ID, a server-side code entry, and/or a client-side code entry.
B13. The system of claim B11 or 12, further comprising an acquisition module adapted to:
acquiring a client code entry from the configuration file;
and acquiring a path of the corresponding client code according to the client code entry, and searching the client code through the path.
B14. The system of any of B8-13, the client code comprising client registration code and client execution code, the second processing module further adapted to:
analyzing the client code to obtain a plug-in ID corresponding to the client code and complete the registration of the corresponding plug-in;
and putting the resolved plug-ins into a plug-in set so as to search corresponding plug-ins from the plug-in set through the plug-in IDs for calling.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules or units or groups of devices in the examples disclosed herein may be arranged in a device as described in this embodiment, or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. Modules or units or groups in embodiments may be combined into one module or unit or group and may furthermore be divided into sub-modules or sub-units or sub-groups. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as floppy diskettes, CD-ROMs, hard drives, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to execute the plug-in construction method of the Web application of the present invention according to the instructions in the program code stored in the memory.
By way of example, and not limitation, computer readable media may comprise computer storage media and communication media. Computer-readable media includes both computer storage media and communication media. Computer storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of computer readable media.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense, and the scope of the present invention is defined by the appended claims.

Claims (17)

1. A plug-in construction method of a Web application, adapted to be executed in a server, the Web application being adapted to be generated by a plurality of plug-in combinations, each plug-in having a corresponding dependency library and plug-in code, the plug-in code comprising server-side code and/or client-side code, the server-side code comprising server-side registration code and server-side execution code, the method comprising:
scanning a plug-in directory, and installing a corresponding dependency library for each plug-in the plug-in directory;
initializing Web server side service, registering a general component and creating a server application instance corresponding to the Web application, wherein the general component comprises static resource service;
for each plug-in each plug-in, if the plug-in code of each plug-in comprises a server-side code, acquiring and analyzing a server-side registration code of the plug-in so as to inject a server-side execution code of the plug-in into the server application instance;
initializing Web client service and providing a client entrance corresponding to the Web application;
and for each plug-in each plug-in, if the plug-in code of each plug-in comprises a client code, packaging the client code, and putting the client code into the static resource directory as a static resource so as to provide the static resource directory for the client through the static resource service, so as to complete the construction of the Web application.
2. The method of claim 1, the step of creating a server application instance corresponding to the Web application comprising:
reading initialization configuration information of the Web server side service, wherein the initialization configuration information comprises basic configuration of the Web application;
and creating a server application instance corresponding to the Web application according to the basic configuration.
3. The method of claim 2, wherein the base configuration comprises an IP address and a port of listening for the Web server side service.
4. The method of any of claims 1-3, further comprising, after the step of creating the server application instance to which the Web application corresponds:
and traversing all the plug-ins in the plug-in directory, acquiring the configuration files of all the plug-ins, and exporting the configuration files.
5. The method of claim 4, the configuration file comprising a plug-in ID, a server-side code entry, and/or a client-side code entry.
6. The method of claim 4, further comprising:
acquiring a client code entry from the configuration file;
and acquiring a path of the corresponding client code according to the client code entry, and searching the client code through the path.
7. The method of claim 1, the client code comprising client registration code and client execution code, the method further comprising, prior to the step of packaging the client code:
analyzing the client code to obtain a plug-in ID corresponding to the client code and complete the registration of the corresponding plug-in;
and putting the resolved plug-ins into a plug-in set so as to search corresponding plug-ins from the plug-in set through the plug-in IDs for calling.
8. A plug-in build system for a Web application adapted to reside in a server, the Web application adapted to be generated by a plurality of plug-in combinations, each plug-in having a corresponding dependency library and plug-in code, the plug-in code comprising server side code and/or client side code, the server side code comprising server side registration code and server side execution code, the system comprising:
the installation module is suitable for scanning the plug-in catalog and installing a corresponding dependency library for each plug-in the plug-in catalog;
the first initialization module is suitable for initializing Web server side service, registering a general component and creating a server application instance corresponding to the Web application, wherein the general component comprises static resource service;
the first processing module is suitable for acquiring and analyzing a server side registration code of each plug-in when the plug-in code of each plug-in comprises a server side code so as to inject the server side execution code of the plug-in into the server application example;
the second initialization module is suitable for initializing Web client service and providing a client entrance corresponding to the Web application;
and the second processing module is suitable for packaging the client codes when the plug-in codes of the plug-ins comprise the client codes and putting the client codes into the static resource catalog as static resources so as to provide the static resources to the client through the static resource service, so that the construction of the Web application is completed.
9. The system of claim 8, the first initialization module further adapted to:
reading initialization configuration information of the Web server side service, wherein the initialization configuration information comprises basic configuration of the Web application;
and creating a server application instance corresponding to the Web application according to the basic configuration.
10. The system of claim 9, wherein the base configuration includes an IP address and a port of listening for the Web server side service.
11. The system of any one of claims 8-10, further comprising an export module adapted to:
and traversing all the plug-ins in the plug-in directory, acquiring the configuration files of all the plug-ins, and exporting the configuration files.
12. The system of claim 11, the configuration file comprising a plug-in ID, a server-side code entry, and/or a client-side code entry.
13. The system of claim 11, further comprising an acquisition module adapted to:
acquiring a client code entry from the configuration file;
and acquiring a path of the corresponding client code according to the client code entry, and searching the client code through the path.
14. The system of claim 8, the client code comprising client registration code and client execution code, the second processing module further adapted to:
analyzing the client code to obtain a plug-in ID corresponding to the client code and complete the registration of the corresponding plug-in;
and putting the resolved plug-ins into a plug-in set so as to search corresponding plug-ins from the plug-in set through the plug-in IDs for calling.
15. A server comprising a plug-in building system for a Web application according to any of claims 8-14.
16. A computing device, comprising:
one or more processors;
a memory; and
one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising instructions for performing any of the methods of claims 1-7.
17. A computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a computing device, cause the computing device to perform any of the methods of claims 1-7.
CN201710431511.2A 2017-06-06 2017-06-06 Plug-in construction method and system for Web application and server Active CN107291458B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710431511.2A CN107291458B (en) 2017-06-06 2017-06-06 Plug-in construction method and system for Web application and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710431511.2A CN107291458B (en) 2017-06-06 2017-06-06 Plug-in construction method and system for Web application and server

Publications (2)

Publication Number Publication Date
CN107291458A CN107291458A (en) 2017-10-24
CN107291458B true CN107291458B (en) 2020-07-14

Family

ID=60096145

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710431511.2A Active CN107291458B (en) 2017-06-06 2017-06-06 Plug-in construction method and system for Web application and server

Country Status (1)

Country Link
CN (1) CN107291458B (en)

Families Citing this family (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109842637B (en) * 2017-11-24 2021-09-07 武汉斗鱼网络科技有限公司 Distributed service registration method and device
CN110442327B (en) * 2018-05-03 2023-06-23 阿里巴巴集团控股有限公司 Application program construction method, device and server
CN108762805A (en) * 2018-05-07 2018-11-06 武汉斗鱼网络科技有限公司 A kind of Hybrid Development Frameworks and frame design method based on Cordova and Typescript
CN108829380B (en) * 2018-05-31 2021-08-31 郑州云海信息技术有限公司 Method and device for realizing consistency of plug-in acquired information
CN108804155A (en) * 2018-05-31 2018-11-13 中链科技有限公司 Profile acquisition method, device, terminal and computer readable storage medium
CN109144482B (en) * 2018-08-22 2023-04-18 海南新软软件有限公司 Method and device for building rapid development environment based on webpack
CN109284096A (en) * 2018-08-22 2019-01-29 深圳点猫科技有限公司 A kind of automated construction method and electronic equipment of programming project
CN109597611B (en) * 2018-11-29 2022-04-12 北京京东尚科信息技术有限公司 Front-end data flow control component development system, method, device and storage medium
CN111324373B (en) * 2018-12-13 2023-12-05 北京奇虎科技有限公司 Method and device for sub-coding warehouse on multiple engineering files and computing equipment
CN111324333B (en) * 2018-12-17 2022-08-30 中移(杭州)信息技术有限公司 Software development method and device based on componentization
CN109960505B (en) * 2019-03-28 2022-11-25 江苏满运软件科技有限公司 User interface component plug-in method, system, equipment and storage medium
CN110784509B (en) * 2019-09-16 2021-07-13 腾讯科技(深圳)有限公司 Medical information processing method and system and related components
CN110688171B (en) * 2019-09-26 2023-11-10 深圳市奋源科技有限公司 Plug-in configuration method, device and equipment of application program and storage medium
CN111026455B (en) * 2019-11-27 2023-02-24 掌阅科技股份有限公司 Plug-in generation method, electronic device and storage medium
CN111475193B (en) * 2020-06-04 2021-03-30 成都安易迅科技有限公司 Plug-in dynamic updating method and device, electronic equipment and storage medium
CN111813385B (en) * 2020-07-07 2023-09-22 赞同科技股份有限公司 Page plug-in method, device and equipment based on Web application
CN111966365A (en) * 2020-08-17 2020-11-20 北京一览群智数据科技有限责任公司 Module deployment method and system
CN112506529B (en) * 2020-11-26 2024-03-26 杭州讯酷科技有限公司 Method for quickly constructing compatible system by using plug-in
CN113157333B (en) * 2021-03-25 2022-09-02 中国电子科技集团公司第二十九研究所 Situation plotting plug-in front-end integrated system
CN116541622A (en) * 2022-01-25 2023-08-04 腾讯科技(深圳)有限公司 Webpage rendering method, device, equipment and storage medium
CN114936031B (en) * 2022-07-22 2022-11-11 浙江中控技术股份有限公司 Component calling method and electronic equipment
CN115617420B (en) * 2022-11-03 2024-03-01 北京百度网讯科技有限公司 Application program generation method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101256492A (en) * 2008-03-31 2008-09-03 宋乃辉 Software development method and system for executing model drive structure
CN101799768A (en) * 2010-03-19 2010-08-11 上海交通大学 Web service packaging system of power cataclysm simulation network
CN103645901A (en) * 2013-12-16 2014-03-19 上海证券交易所 Event chain based user interface plugin interaction method
CN105898438A (en) * 2016-04-07 2016-08-24 广州华多网络科技有限公司 Live broadcasting room dynamic configuration method, device, system and server

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9740462B2 (en) * 2014-08-27 2017-08-22 Sap Se Adaptive, context-aware, model-based suggestions

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101256492A (en) * 2008-03-31 2008-09-03 宋乃辉 Software development method and system for executing model drive structure
CN101799768A (en) * 2010-03-19 2010-08-11 上海交通大学 Web service packaging system of power cataclysm simulation network
CN103645901A (en) * 2013-12-16 2014-03-19 上海证券交易所 Event chain based user interface plugin interaction method
CN105898438A (en) * 2016-04-07 2016-08-24 广州华多网络科技有限公司 Live broadcasting room dynamic configuration method, device, system and server

Also Published As

Publication number Publication date
CN107291458A (en) 2017-10-24

Similar Documents

Publication Publication Date Title
CN107291458B (en) Plug-in construction method and system for Web application and server
US10452372B2 (en) Method and deployment module for managing a container to be deployed on a software platform
CN110688232B (en) Application program calling method, terminal equipment and computer readable storage medium
CN107809383B (en) MVC-based path mapping method and device
US9135263B2 (en) Method and system that routes requests for electronic files
CN107707614A (en) App route implementation methods, equipment and the storage medium of agreement are jumped based on system
CN110764748B (en) Code calling method, device, terminal and storage medium
CN110543327B (en) Service component multiplexing method, device, computer equipment and storage medium
US9910724B2 (en) Fast and accurate identification of message-based API calls in application binaries
CN113076502A (en) Parameter control method and system based on request identification
CN103139260B (en) For reusing the method and system of HTML content
CN110221877B (en) Application program running method and device, electronic equipment and storage medium
CN111741010B (en) Docker operation request processing method and device based on proxy and computing equipment
CN111158777A (en) Component calling method and device and computer readable storage medium
CN114168937A (en) Resource access method, computing device and readable storage medium
US11010346B2 (en) Methods and apparatus for managing access to file content
CN113867780A (en) Service integration method, device and storage medium
CN109194734B (en) Message pushing method and device, server and readable storage medium
CN113904962B (en) Resource access method and device and computing equipment
CN112380480A (en) Page jump method, computing device and storage medium
CN110309000B (en) Application update prompting method and terminal equipment
JP2014229114A (en) OSGi SERVICE REGISTRATION DEVICE, REGISTRATION METHOD AND REGISTRATION PROGRAM
CN111475226B (en) Electronic device, micro-service calling method, and computer-readable storage medium
CN111132121B (en) Information processing method and network warehouse function NRF network element
WO2021233042A1 (en) Page data loading method, apparatus, and system

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
CB02 Change of applicant information

Address after: Room 311501, Unit 1, Building 5, Courtyard 1, Futong East Street, Chaoyang District, Beijing 100102

Applicant after: Beijing Zhichuangyu Information Technology Co., Ltd.

Address before: 100097 Jinwei Building 803, 55 Lanindichang South Road, Haidian District, Beijing

Applicant before: Beijing Knows Chuangyu Information Technology Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant