CN104283947A - Java script dynamic consolidated server and work process thereof - Google Patents

Java script dynamic consolidated server and work process thereof Download PDF

Info

Publication number
CN104283947A
CN104283947A CN201410508935.0A CN201410508935A CN104283947A CN 104283947 A CN104283947 A CN 104283947A CN 201410508935 A CN201410508935 A CN 201410508935A CN 104283947 A CN104283947 A CN 104283947A
Authority
CN
China
Prior art keywords
file
source
server
configuration
java script
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.)
Pending
Application number
CN201410508935.0A
Other languages
Chinese (zh)
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.)
SHENZHEN ZHONGKEWU SOFTWARE Co Ltd
Original Assignee
SHENZHEN ZHONGKEWU SOFTWARE 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 SHENZHEN ZHONGKEWU SOFTWARE Co Ltd filed Critical SHENZHEN ZHONGKEWU SOFTWARE Co Ltd
Priority to CN201410508935.0A priority Critical patent/CN104283947A/en
Publication of CN104283947A publication Critical patent/CN104283947A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Abstract

Provided is a Java script dynamic consolidated server. The server dynamically combines and compresses multiple java scripts files stored in a background into a java script file by means of a configuration file and different parameters of requests, and the java script file is fed back. The Java script dynamic consolidated server structurally comprises a http file server, a target file, a target file parameter, the configuration file, a source file and a file analyzer. The server is simple and clear in structure, a java script program does not need to be modified, and logics of the programs are not influenced. Configuration is flexible, people only need to modify the configuration file to achieve combination of different modules and different versions. Use is convenient, .js files of different versions and combinations can be obtained by adding parameters into the path of the requests, and errors are conveniently positioned during debugging.

Description

Java script Dynamic merge server and the course of work thereof
[technical field]
The present invention relates to web server field, the Internet, particularly relate to large-scale java script Application and Development technical field.
[background technology]
Along with the raising of the performance of browser, the application of java script in the Internet project is more and more extensive, and code quantity and the complexity thereof of java script are also doubled and redoubled thereupon.Due to historical reasons, there is open global variable in java script, the defects such as incomplete Object-Oriented Design, and innately lack external reference mechanism and modularization mechanism, bring many difficulties to developing and debugging large-scale java script program like this.
A lot of technology attempts the technical problem solving the large-scale java script of exploitation.Such as Require.js and sea.js, the method that they all adopt java script dynamically to add document label realizes the asynchronous download of js, by stating the dependence to other library files in java script file, reach the java script documentation of complexity is divided into can be multiplexing multiple modules, thus the modularization of the js file realized.
The common feature of these methods is: the code of user needs to encapsulate by fixed mode, the specification making it meet modularization to call; Need to rely on declaration module; By the dynamic load of the js file of outside.
Such as in Require.js, can be just the module of " logger " with define function definition ID, like this inside other code, just can utilize Require.js function to call " logger " module.Then " logger " module become realize js file can be multiplexing module.
The problem of prior art is to need the modular functionality originally do not possessed to realize java script the java script script to user writes to encapsulate and rewrite, make it to meet modular specification, so that as the module that can arbitrarily call.Extra code and amendment can increase the complexity of program, and encapsulation and the logic that loads likely are brought program and can not be estimated and uncontrollable impact.What not only increase code writes difficulty, simultaneously can bring compatibility issue to original code write.
Another one problem is the difficulty that modular dynamic load can cause debugging.First the loading sequence of code is no longer controlled, due to load mechanism be different for the control of the loading sequence of dependent file, the program called or triggered after needing to have loaded for some, must the problem of extra consideration loading sequence.Secondly the action scope in order to make code meet the rewriting meeting reprogramming internal variable sum functions that modularization is carried out, when debugging, error message will become and be difficult to follow the trail of.
[summary of the invention]
The present invention is directed to above situation and propose a kind of java script Dynamic merge server adapting to complexity that in current the Internet, java script files tend is high, loaded down with trivial details exploitation debugging efforts can be provided.
Java script Dynamic merge server involved in the present invention by the different parameters of configuration file and request, dynamically by be stored in backstage multiple java scripts combination of files, be compressed into a java script file, and to be returned;
The framework of this java script Dynamic merge server comprises http file server, file destination, file destination parameter, configuration file, source file, paper analyzer; Wherein:
Http file server: be responsible for receiving http request to java script file, for file destination and the relevant parameter of each request, send the request of Piece file mergence to paper analyzer, and returned by the destination file buffer memory merged;
File destination: file destination refers to the java script file of the desired request of client, be that the file of ending is called unique identification with .js, client is by url request target file;
File destination parameter: client can bring additional parameter in the url of request target file, for indicating the version of demand file, compressive state;
Configuration file: configuration file comprises source profile and target configuration file, two kinds of configuration files are JSON formatted file;
Source file: source file is the single java script file of composition target, and each file destination will be combined by one or more source file; Source file is stored in the file system of system, and needs to state in source profile, is only used in the source file stating use in former configuration file and just can be used to be combined into file destination;
Paper analyzer: paper analyzer is the core component of server, is responsible for receiving the instruction of http file server and the source file needed for configuration file reading, and after being merged into file destination, returns to client.
Wherein source profile: source profile as the text of a source.js by name, source file ID, version and positional information available in the define system of the inside; Freely source file registered in source profile could be used for being combined into file destination by system.
In this source profile, the id of each source file is unique, its correspondence be store and a source file in system, and id does not need identical with filename.
Wherein target configuration file: target configuration file is the configuration file wanting the target java script file of accessing for each, can have multiple, the corresponding target configuration file of each file destination, target configuration file and file destination of the same name, be with .js be ending text;
This target configuration file comprises version information and source file configuration, and version information refers to for same file destination, can have multiple different version, be distinguished by version number; And source file configuration refers to that being used in reference to bright file destination by those source files is formed, that indicate in configuration file is the id of source file, and must be the id existed in source profile; The source file configuration of the file destination of each version is independently, and each source file can specify its version.
Client subsidiary parameter when request target file follows the url parameter rule of standard, with "? " start, use the form of key=value, and with " & " separation as multiple parameter.
The course of work of this javascript Dynamic merge server comprises following steps:
1, client sends .js file request: client sends a request to java script Dynamic merge server, and file is called XX.js, and subsidiary two parameters;
2, http-server analysis request and parameter: after http file server receives request, can search local cache, if can find satisfactory file at local cache, will directly return this file; If satisfactory file cannot be found in local cache, then the XX.js of request and two parameter is sent to paper analyzer;
3, document parser searches corresponding target configuration file: paper analyzer parsing receives, and from the request that http-server is sent, can search the configuration file of XX.js by name after parsing, if can not find corresponding configuration file, then return 404 mistakes; If after finding corresponding configuration file, resolve, obtain the source file id list forming this file destination, the order of list and the id sequence consensus in configuration file;
4, as requested the source file of needs is assembled, is compressed into file destination: paper analyzer finds source profile, according to id list obtained in the previous step, read the source file of specifying successively, and according to the requirement of parameter, all source files are merged into a file, and writing local cache, the naming method of cache file is name_key_value;
5, http-server returns .js file: after spanned file, and the file of generation is returned to client by system, and whole request process completes.
For client, the mode calling java script file does not have different from traditional file server, is all the java script file that the URL Address requests by specifying is specified.
For developer, division and the combination of multiple self-defining javas cript file bring free and convenient greatly, and use threshold of the present invention is very low, there is no precipitous learning curve, the java script of system is developed all clear controlled from the flow process being designed into coding stage, also can bring very large facility to developer in the amendment of development late stage and debug stage.
[accompanying drawing explanation]
Fig. 1 is the flow chart of the course of work of javascript Dynamic merge server of the present invention;
[embodiment]
Below in conjunction with the drawings and specific embodiments of the present invention, java script Dynamic merge server of the present invention and the course of work thereof are described in further detail.
Java script Dynamic merge server involved in the present invention by the different parameters of configuration file and request, dynamically by be stored in backstage multiple java scripts combination of files, be compressed into a java script file, and to be returned;
The framework of this java script Dynamic merge server comprises http file server, file destination, file destination parameter, configuration file, source file, paper analyzer; Wherein:
Http file server: be responsible for receiving http request to java script file, for file destination and the relevant parameter of each request, send the request of Piece file mergence to paper analyzer, and returned by the destination file buffer memory merged;
File destination: file destination refers to the java script file of the desired request of client, be that the file of ending is called unique identification with .js, client is by url request target file;
File destination parameter: client can bring additional parameter in the url of request target file, for indicating the version of demand file, compressive state;
Configuration file: configuration file comprises source profile and target configuration file, two kinds of configuration files are JSON formatted file;
Source file: source file is the single java script file of composition target, and each file destination will be combined by one or more source file; Source file is stored in the file system of system, and needs to state in source profile, is only used in the source file stating use in former configuration file and just can be used to be combined into file destination;
Paper analyzer: paper analyzer is the core component of server, is responsible for receiving the instruction of http file server and the source file needed for configuration file reading, and after being merged into file destination, returns to client.
Wherein source profile: source profile as the text of a source.js by name, source file ID, version and positional information available in the define system of the inside; Freely source file registered in source profile could be used for being combined into file destination by system.
In this source profile, the id of each source file is unique, its correspondence be store and a source file in system, and id does not need identical with filename.
Wherein target configuration file: target configuration file is the configuration file wanting the target java script file of accessing for each, can have multiple, the corresponding target configuration file of each file destination, target configuration file and file destination of the same name, be with .js be ending text;
This target configuration file comprises version information and source file configuration, and version information refers to for same file destination, can have multiple different version, be distinguished by version number; And source file configuration refers to that being used in reference to bright file destination by those source files is formed, that indicate in configuration file is the id of source file, and must be the id existed in source profile; The source file configuration of the file destination of each version is independently, and each source file can specify its version.
Client subsidiary parameter when request target file follows the url parameter rule of standard, with "? " start, use the form of key=value, and with " & " separation as multiple parameter.
The course of work of this javascript Dynamic merge server comprises following steps:
1, client sends .js file request: client sends a request to java script Dynamic merge server, and file is called XX.js, and subsidiary two parameters;
2, http-server analysis request and parameter: after http file server receives request, can search local cache, if can find satisfactory file at local cache, will directly return this file; If satisfactory file cannot be found in local cache, then the XX.js of request and two parameter is sent to paper analyzer;
3, document parser searches corresponding target configuration file: paper analyzer parsing receives, and from the request that http-server is sent, can search the configuration file of XX.js by name after parsing, if can not find corresponding configuration file, then return 404 mistakes; If after finding corresponding configuration file, resolve, obtain the source file id list forming this file destination, the order of list and the id sequence consensus in configuration file;
4, as requested the source file of needs is assembled, is compressed into file destination: paper analyzer finds source profile, according to id list obtained in the previous step, read the source file of specifying successively, and according to the requirement of parameter, all source files are merged into a file, and writing local cache, the naming method of cache file is name_key_value;
5, http-server returns .js file: after spanned file, and the file of generation is returned to client by system, and whole request process completes.
For client, the mode calling java script file does not have different from traditional file server, is all the java script file that the URL Address requests by specifying is specified.
For developer, division and the combination of multiple self-defining javas cript file bring free and convenient greatly, and use threshold of the present invention is very low, there is no precipitous learning curve, the java script of system is developed all clear controlled from the flow process being designed into coding stage, also can bring very large facility to developer in the amendment of development late stage and debug stage.
The above, it is only present pre-ferred embodiments, not any pro forma restriction is done to the present invention, although the present invention discloses as above with preferred embodiment, but and be not used to limit the present invention, any those skilled in the art, do not departing within the scope of technical solution of the present invention, make a little change when the technology contents of above-mentioned announcement can be utilized or be modified to the Equivalent embodiments of equivalent variations, in every case be do not depart from technical solution of the present invention content, any simple modification that above embodiment is done is referred to according to the technology of the present invention, equivalent variations and modification, all belong in the scope of technical solution of the present invention.

Claims (7)

1. a java script Dynamic merge server, this server by the different parameters of configuration file and request, dynamically by be stored in backstage multiple java scripts combination of files, be compressed into a java script file, and to be returned; The framework of this java script Dynamic merge server comprises http file server, file destination, file destination parameter, configuration file, source file, paper analyzer; Wherein:
Http file server: be responsible for receiving http request to java script file, for file destination and the relevant parameter of each request, send the request of Piece file mergence to paper analyzer, and returned by the destination file buffer memory merged;
File destination: file destination refers to the java script file of the desired request of client, be that the file of ending is called unique identification with .js, client is by url request target file;
File destination parameter: client can bring additional parameter in the url of request target file, for indicating the version of demand file, compressive state;
Configuration file: configuration file comprises source profile and target configuration file, two kinds of configuration files are JSON formatted file;
Source file: source file is the single java script file of composition target, and each file destination will be combined by one or more source file; Source file is stored in the file system of system, and needs to state in source profile, is only used in the source file stating use in former configuration file and just can be used to be combined into file destination;
Paper analyzer: paper analyzer is the core component of server, is responsible for receiving the instruction of http file server and the source file needed for configuration file reading, and after being merged into file destination, returns to client.
2. java script Dynamic merge server according to claim 1, is characterized in that, this source profile as the text of a source.js by name, source file ID, version and positional information available in the define system of the inside; Freely source file registered in source profile could be used for being combined into file destination by system.
3. javascript Dynamic merge server according to claim 2, it is characterized in that, in this source profile, the id of each source file is unique, its correspondence be store and a source file in system, and id does not need identical with filename.
4. javascript Dynamic merge server according to claim 1, it is characterized in that, client subsidiary parameter when request target file follows the url parameter rule of standard, with "? " start, use the form of key=value, and with " & " separation as multiple parameter.
5. java script Dynamic merge server according to claim 1, it is characterized in that, wherein target configuration file is the configuration file wanting the target java script file of accessing for each, can have multiple, the corresponding target configuration file of each file destination, target configuration file and file destination of the same name, be with .js be ending text.
6. java script Dynamic merge server according to claim 5, it is characterized in that, this target configuration file comprises version information and source file configuration, and version information refers to for same file destination, multiple different version can be had, distinguished by version number; And source file configuration refers to that being used in reference to bright file destination by those source files is formed, that indicate in configuration file is the id of source file, and must be the id existed in source profile; The source file configuration of the file destination of each version is independently, and each source file can specify its version.
7. the course of work of javascript Dynamic merge server comprises the following steps according to claim 1:
1), client sends .js file request: client sends a request to java script Dynamic merge server, and file is called XX.js, and attaches two parameters;
2), http-server analysis request and parameter: after http file server receives request, can local cache be searched, if satisfactory file can be found at local cache, will directly return this file; If satisfactory file cannot be found in local cache, then the XX.js of request and two parameter is sent to paper analyzer;
3), document parser searches corresponding target configuration file: paper analyzer parsing receives, from the request that http-server is sent, the configuration file of XX.js by name can be searched after parsing, if can not find corresponding configuration file, then return 404 mistakes; If after finding corresponding configuration file, resolve, obtain the source file id list forming this file destination, the order of list and the id sequence consensus in configuration file;
4), as requested the source file of needs is assembled, is compressed into file destination: paper analyzer finds source profile, according to id list obtained in the previous step, read the source file of specifying successively, and according to the requirement of parameter, all source files are merged into a file, and writing local cache, the naming method of cache file is name_key_value;
5), http-server returns .js file: after spanned file, the file of generation is returned to client by system, and whole request process completes.
CN201410508935.0A 2014-09-28 2014-09-28 Java script dynamic consolidated server and work process thereof Pending CN104283947A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410508935.0A CN104283947A (en) 2014-09-28 2014-09-28 Java script dynamic consolidated server and work process thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410508935.0A CN104283947A (en) 2014-09-28 2014-09-28 Java script dynamic consolidated server and work process thereof

Publications (1)

Publication Number Publication Date
CN104283947A true CN104283947A (en) 2015-01-14

Family

ID=52258420

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410508935.0A Pending CN104283947A (en) 2014-09-28 2014-09-28 Java script dynamic consolidated server and work process thereof

Country Status (1)

Country Link
CN (1) CN104283947A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105045598A (en) * 2015-08-07 2015-11-11 北京思特奇信息技术股份有限公司 Java-based web front-end performance optimization and online method and system
CN105512324A (en) * 2015-12-21 2016-04-20 用友网络科技股份有限公司 Front end module loader for partial renewal of package file
CN106547527A (en) * 2015-09-22 2017-03-29 阿里巴巴集团控股有限公司 A kind of JavaScript file construction method and device
CN108984189A (en) * 2017-05-31 2018-12-11 北京京东尚科信息技术有限公司 The method and apparatus of module parsing
CN109408103A (en) * 2018-09-17 2019-03-01 西安闻泰电子科技有限公司 Setting method, device, equipment and the medium of configuration file
CN112068875A (en) * 2020-08-04 2020-12-11 广州太平洋电脑信息咨询有限公司 System and method for realizing thread filtering strategy based on java dynamic loading

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081633A (en) * 2009-11-27 2011-06-01 阿里巴巴集团控股有限公司 JavaScript file management method, device and system
CN102799640A (en) * 2012-06-27 2012-11-28 用友软件股份有限公司 Page loading device and page loading method
CN102902558A (en) * 2012-09-11 2013-01-30 新浪网技术(中国)有限公司 Project script file updating system and method as well as script file merging method and device
CN103092581A (en) * 2011-10-28 2013-05-08 阿里巴巴集团控股有限公司 Method and device for setting up Web front-end local development environment
CN103136290A (en) * 2011-12-05 2013-06-05 金蝶软件(中国)有限公司 Processing method and processing device of web script file
CN103139298A (en) * 2013-02-01 2013-06-05 北京京东世纪贸易有限公司 Method for transmitting network data and device
CN103312803A (en) * 2013-06-17 2013-09-18 杭州华三通信技术有限公司 Method and device for optimizing Web access experience
CN103327033A (en) * 2013-07-16 2013-09-25 星云融创(北京)信息技术有限公司 Method and device for improving accessing speed of network resource
CN103716319A (en) * 2013-12-26 2014-04-09 杭州华三通信技术有限公司 Device and method for Web access optimization

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081633A (en) * 2009-11-27 2011-06-01 阿里巴巴集团控股有限公司 JavaScript file management method, device and system
CN103092581A (en) * 2011-10-28 2013-05-08 阿里巴巴集团控股有限公司 Method and device for setting up Web front-end local development environment
CN103136290A (en) * 2011-12-05 2013-06-05 金蝶软件(中国)有限公司 Processing method and processing device of web script file
CN102799640A (en) * 2012-06-27 2012-11-28 用友软件股份有限公司 Page loading device and page loading method
CN102902558A (en) * 2012-09-11 2013-01-30 新浪网技术(中国)有限公司 Project script file updating system and method as well as script file merging method and device
CN103139298A (en) * 2013-02-01 2013-06-05 北京京东世纪贸易有限公司 Method for transmitting network data and device
CN103312803A (en) * 2013-06-17 2013-09-18 杭州华三通信技术有限公司 Method and device for optimizing Web access experience
CN103327033A (en) * 2013-07-16 2013-09-25 星云融创(北京)信息技术有限公司 Method and device for improving accessing speed of network resource
CN103716319A (en) * 2013-12-26 2014-04-09 杭州华三通信技术有限公司 Device and method for Web access optimization

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105045598A (en) * 2015-08-07 2015-11-11 北京思特奇信息技术股份有限公司 Java-based web front-end performance optimization and online method and system
CN106547527A (en) * 2015-09-22 2017-03-29 阿里巴巴集团控股有限公司 A kind of JavaScript file construction method and device
CN105512324A (en) * 2015-12-21 2016-04-20 用友网络科技股份有限公司 Front end module loader for partial renewal of package file
CN105512324B (en) * 2015-12-21 2019-01-15 用友网络科技股份有限公司 A kind of front-end module loader of packaging file local updating
CN108984189A (en) * 2017-05-31 2018-12-11 北京京东尚科信息技术有限公司 The method and apparatus of module parsing
CN109408103A (en) * 2018-09-17 2019-03-01 西安闻泰电子科技有限公司 Setting method, device, equipment and the medium of configuration file
CN112068875A (en) * 2020-08-04 2020-12-11 广州太平洋电脑信息咨询有限公司 System and method for realizing thread filtering strategy based on java dynamic loading

Similar Documents

Publication Publication Date Title
CN109976761B (en) Software development kit generation method and device and terminal equipment
CN104793946B (en) Dispositions method and system are applied based on cloud computing platform
CN104283947A (en) Java script dynamic consolidated server and work process thereof
CN109284472B (en) Front-end webpage loading method and storage medium based on webpack
CN101470621B (en) Virtual machine configuration system
US9906622B2 (en) Automated service interface optimization
US10318318B2 (en) Extending user interface of a web console
CN112882700B (en) IOS application program construction method and device, electronic equipment and storage medium
CN109684607B (en) JSON data analysis method and device, computer equipment and storage medium
US20130191439A1 (en) Managing script file dependencies and load times
CN110806868B (en) Single-page building and loading method
CN102566984B (en) Method and device for configuring parameters
CN105677302A (en) Application program modularization developing method and device
Fenoy et al. ZOO-Project: the open WPS platform
CN104423961A (en) Method and system for generating testing script
US11474796B1 (en) Build system for distributed applications
CN104375808A (en) Method and device for displaying interfaces
US11328021B2 (en) Automatic resource management for build systems
CN107463421B (en) Compiling and executing method and system of static flow model
KR102141749B1 (en) APP program execution method and device
CN110659022B (en) Method for automatically calling Python script based on Java
CN104866312A (en) ASP.NET-based pseudo static page implementation method
US10713014B2 (en) Multi-platform interface framework
CN116719523A (en) Page rendering method and electronic device
CN115390846A (en) Compiling construction method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20150114

RJ01 Rejection of invention patent application after publication