CN111221572B - Method, device, medium and equipment for automatically adapting to running environment - Google Patents
Method, device, medium and equipment for automatically adapting to running environment Download PDFInfo
- Publication number
- CN111221572B CN111221572B CN202010032136.6A CN202010032136A CN111221572B CN 111221572 B CN111221572 B CN 111221572B CN 202010032136 A CN202010032136 A CN 202010032136A CN 111221572 B CN111221572 B CN 111221572B
- Authority
- CN
- China
- Prior art keywords
- environment
- domain name
- http request
- request class
- variable
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 39
- 238000013507 mapping Methods 0.000 claims abstract description 30
- 238000011161 development Methods 0.000 claims abstract description 19
- 230000002194 synthesizing effect Effects 0.000 claims abstract description 15
- 238000004590 computer program Methods 0.000 claims description 9
- 239000002131 composite material Substances 0.000 claims description 3
- 238000010276 construction Methods 0.000 claims description 2
- 230000006978 adaptation Effects 0.000 abstract description 8
- 230000006870 function Effects 0.000 description 20
- 238000010586 diagram Methods 0.000 description 7
- 230000004044 response Effects 0.000 description 4
- 238000012360 testing method Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000001771 impaired effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 230000001737 promoting effect Effects 0.000 description 1
- 230000008439 repair process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/955—Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Stored Programmes (AREA)
Abstract
The present disclosure provides a method, apparatus, medium and device for automatically adapting to an operating environment, where the method includes: constructing a mapping between the running environment and the corresponding domain name and instantiating an HTTP request class; dynamically acquiring an environment variable based on the HTTP request class, obtaining a corresponding domain name according to the environment variable, and assigning the domain name attribute to the HTTP request class; and synthesizing the domain name attribute of the HTTP request class and the path transmitted by the developer into a URL, sending an HTTP request, and automatically adapting to the running environment. According to the method provided by the embodiment of the disclosure, when a developer issues a new code, the code to be issued can automatically identify the variable of the running environment by automatically obtaining the variable of the running environment, so that the front-end program can automatically adapt to different running environments, the development efficiency is effectively improved, and the adaptation error is reduced.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and a device for automatically adapting to an operating environment.
Background
As technology advances, current web applications become more and more powerful. Accordingly, the code logic becomes more and more complex, and the probability of Bug occurrence becomes higher and higher. If the Bug code is directly released on-line, the user experience is seriously impaired.
In order to ensure the quality of the network application program, the program development needs to adopt a standard development flow. In a mature development process, development of a function generally requires four steps of local development and debugging, testing environment testing, gray environment observation and formal environment use. By layer-by-layer examination, the Bug of the repair program can be discovered and repaired as early as possible. Different steps require the use of different operating environments. The four steps use a development environment, a test environment, a gray scale environment and a formal environment respectively. The resources of different running environments are related and isolated, so that mutual influence is avoided.
Web applications are generally divided into front-end and back-end portions. The front end and the back end are independently developed and deployed. The front end and the back end cooperate through HTTP requests. The back end provides an interface and the front end uses the interface. When the back-end programs are deployed on different running environments, the URLs corresponding to the interfaces provided by the back-end programs are different. Thus, the code of the request interface also differs. And the front-end program contains many codes that request interfaces. That is, the front-end programs deployed in different operating environments are not identical. Each time the front-end code is issued to a different operating environment, the code of the request interface portion needs to be modified. This manual adaptation increases the amount of work and is also prone to error. If the front-end program can automatically adapt to different running environments, the development efficiency can be effectively improved and the adaptation errors can be reduced.
BRIEF SUMMARY OF THE PRESENT DISCLOSURE
The present disclosure aims to provide a method, an apparatus, a medium and a device for automatically adapting an operating environment, which can solve at least one technical problem mentioned above. The specific scheme is as follows:
according to a specific embodiment of the present disclosure, in a first aspect, the present disclosure provides a method for automatically adapting an operating environment, including:
constructing a mapping between the running environment and the corresponding domain name and instantiating an HTTP request class;
dynamically acquiring an environment variable based on the HTTP request class, obtaining a corresponding domain name according to the environment variable, and assigning the domain name attribute to the HTTP request class;
and synthesizing the domain name attribute of the HTTP request class and the path transmitted by the developer into a URL, sending an HTTP request, and automatically adapting to the running environment.
Optionally, the building the mapping between the running environment and the corresponding domain name and instantiating the HTTP request class includes:
determining a domain name corresponding to the operation environment, and constructing a mapping relation between the operation environment and the domain name to form domain name mapping;
and using the domain name mapping as an input parameter, and calling a constructor of the HTTP request class by using a new operator to obtain an HTTP request class instance.
Optionally, the dynamically acquiring the environment variable based on the HTTP request class, obtaining a corresponding domain name according to the environment variable, and assigning the domain name attribute to the HTTP request class includes:
reading the appointed attribute mounted on the global variable in the constructor of the HTTP request class, and assigning the appointed attribute to the environment variable;
the environment variable is used as a key, and a corresponding domain name is obtained from the domain name mapping;
and assigning the obtained domain name to the domain name attribute of the HTTP request class.
Optionally, in the constructor of the HTTP request class, reading the contract attribute mounted on the global variable, and assigning the contract attribute to the environment variable, and then includes:
when reading the contract attributes mounted on the global variable fails, the environment variable is equal to the development environment variable.
Optionally, the synthesizing the domain name attribute of the HTTP request class and the path imported by the developer into the URL, sending the HTTP request, and automatically adapting to the running environment, including:
taking the path, the method and the data as input parameters, and calling a request function of an HTTP request class instance;
synthesizing a URL according to the domain name attribute of the HTTP request class and the path in the request function;
the request function initiates an HTTP request to the composite URL and automatically adapts the runtime environment.
Optionally, based on the HTTP request class, dynamically acquiring an environment variable, obtaining a corresponding domain name according to the environment variable, and assigning the domain name attribute to the HTTP request class, and before the dynamically acquiring, further includes:
the publishing system injects the environment variable of the running environment into the front-end program code to be published, and publishes the front-end program code to be published to different running environments.
Optionally, the publishing system injects the environment variable of the running environment into the front-end program code to be published, and publishes the front-end program code to be published to a different running environment, including:
uploading front-end program codes to be published to a publishing system, and selecting an operating environment to publish, wherein the front-end program codes to be published comprise: HTML, JS, and CSS code;
the release system assigns the selected running environment to the appointed attribute of the global variable, and realizes assignment logic by using JS codes wrapped in script labels;
inserting script labels wrapping the JS codes into the HTML in a character string replacement mode;
and publishing the HTML inserted into the script tag to a server cluster corresponding to the selected running environment.
According to a second aspect of the present disclosure, there is provided an apparatus for automatically adapting an operating environment, comprising:
the construction unit is used for constructing the mapping between the running environment and the corresponding domain name and instantiating an HTTP request class;
the acquisition unit is used for dynamically acquiring an environment variable based on the HTTP request class, acquiring a corresponding domain name according to the environment variable and assigning the domain name attribute to the HTTP request class;
and the sending unit is used for synthesizing the domain name attribute of the HTTP request class and the path imported by the developer into a URL, sending the HTTP request and automatically adapting to the running environment.
According to a third aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor implements a method as claimed in any one of the above.
According to a fourth aspect of the present disclosure, there is provided an electronic device comprising: one or more processors; storage means for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the method of any of the preceding claims.
Compared with the prior art, the scheme of the embodiment of the disclosure has at least the following beneficial effects:
according to the method provided by the embodiment of the disclosure, when a developer issues a new code, the code to be issued can automatically identify the variable of the running environment by automatically obtaining the variable of the running environment, so that the front-end program can automatically adapt to different running environments, the development efficiency is effectively improved, and the adaptation error is reduced.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure. It will be apparent to those of ordinary skill in the art that the drawings in the following description are merely examples of the disclosure and that other drawings may be derived from them without undue effort. In the drawings:
FIG. 1 illustrates a flow chart of a method of automatically adapting a runtime environment, in accordance with an embodiment of the present disclosure;
FIG. 2 illustrates a schematic diagram of an auto-adapt runtime environment device architecture, according to an embodiment of the present disclosure;
fig. 3 illustrates a schematic diagram of an electronic device connection structure according to an embodiment of the present disclosure.
Detailed Description
For the purpose of promoting an understanding of the principles and advantages of the disclosure, reference will now be made in detail to the drawings, in which it is apparent that the embodiments described are only some, but not all embodiments of the disclosure. Based on the embodiments in this disclosure, all other embodiments that a person of ordinary skill in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
The terminology used in the embodiments of the disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure of embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, the "plurality" generally includes at least two.
It should be understood that the term "and/or" as used herein is merely one relationship describing the association of the associated objects, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe … … in the presently disclosed embodiments, these … … should not be limited to these terms. These terms are only used to distinguish … …. For example, the first … … may also be referred to as the second … …, and similarly the second … … may also be referred to as the first … …, without departing from the scope of the disclosed embodiments.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a product or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such product or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a commodity or device comprising such element.
Alternative embodiments of the present disclosure are described in detail below with reference to the drawings.
After the code is compiled, the code needs to be released through a release system, and usually, the code needs to be subjected to four steps of development environment, test environment, gray scale environment and formal environment after the code is compiled. The resources of different running environments are isolated, so that mutual influence is avoided.
Web applications are generally divided into front-end and back-end portions. The front end and the back end are independently developed and deployed. The front end and the back end cooperate through HTTP requests. The back end provides an interface and the front end uses the interface. When the back-end programs are deployed on different running environments, the URLs corresponding to the interfaces provided by the back-end programs are different. The method aims at solving automatic adaptation under different running environments, so that development efficiency is improved and adaptation errors are reduced. The specific implementation mode is as follows:
as shown in fig. 1, according to a specific embodiment of the present disclosure, in a first aspect, the present disclosure provides a method for automatically adapting an operating environment, which specifically includes the following method steps:
step S102: and constructing a mapping between the running environment and the corresponding domain name and instantiating an HTTP request class.
Optionally, the building the mapping between the running environment and the corresponding domain name and instantiating the HTTP request class includes:
step S102-1: and determining the domain name corresponding to the operation environment, and constructing the mapping relation between the operation environment and the domain name to form domain name mapping.
For example, the internet identifies devices on the network with IP addresses, but IP addresses are inconvenient to remember and cannot display the name and nature of the address organization. The domain name and IP address are mapped to each other by constructing the domain name and by a domain name system (DNS, domain Name System). The domain name is a set of character type address scheme, which is easier to memorize.
Also, different running environments need to use different domain names and resources, such as a server and a database, and the running environments and the domain names are in one-to-one correspondence, so that a mapping can be formed, and the corresponding resources can be accessed through the domain names of the different running environments.
Step S102-2: and using the domain name mapping as an input parameter, and calling a constructor of the HTTP request class by using a new operator to obtain an HTTP request class instance.
Sending HTTP requests is a generic function that can be packaged into a library and organized into code in a class fashion. Before sending the HTTP request, the HTTP request class needs to be instantiated first, and domain name mapping can be input during instantiation.
Step S103: the publishing system injects the environment variable of the running environment into the front-end program code to be published, and publishes the front-end program code to be published to different running environments.
The front-end program code implementing the web application typically contains HTML, JS, and CSS code. Program code is typically published through a publication system. The release is to replace the code in the designated server with a new code. After release, when the user accesses the server via the internet, the updated code is obtained, and a new application program is seen.
When code is released, a developer needs to upload the relevant code file while selecting the type of the released running environment. Different operating environments use different clusters of servers. The publishing system finds a corresponding server cluster according to the operating environment and then publishes the code to the cluster.
HTML has a < script > tag that defines the client script. When the browser exposes the HTML file, the code in the < script > tag is parsed and run. In the browser, window is a global variable representing the window in which the script is running, exposed to the JS code. That is, all relevant JS codes in an HTML file can modify and access the global variable window. Thus, the runtime environment can be mounted on the window for other JS code access. After the code file uploaded by the developer is obtained, the release system can modify the code file as required and then release the code file to the server. HTML code is a segment of a string that can be modified by string substitution.
Optionally, the publishing system injects the environment variable of the running environment into the front-end program code to be published, and publishes the front-end program code to be published to a different running environment, including:
step S103-1: uploading front-end program codes to be published to a publishing system, and selecting an operating environment to publish, wherein the front-end program codes to be published comprise: HTML, JS, and CSS code.
Step S103-2: and the release system assigns the selected running environment to the appointed attribute of the global variable, and realizes assignment logic by using JS codes wrapped in script labels.
Step S103-3: and inserting script labels wrapping the JS codes into the HTML in a character string replacement mode.
Step S103-4: and publishing the HTML inserted into the script tag to a server cluster corresponding to the selected running environment.
Step S104: based on the HTTP request class, dynamically acquiring an environment variable, obtaining a corresponding domain name according to the environment variable, and assigning the domain name attribute to the HTTP request class.
The environment variables representing the type of the operating environment are indeterminate at the time of development, but the release system can determine the type of the operating environment at the time of release of the program code. Thus, the program needs to dynamically acquire the environment variables determined by the distribution system at the time of running. For ease of handling, the agreed attributes of the global variable window (such as "run_env") are used as a carrier for data transfer. The release system assigns the running environment type to the appointed attribute of the window, and the HTTP request class dynamically acquires the running environment type from the appointed attribute of the window.
In the case of local development, since the system is not published, the value of the contract attribute of the window does not exist. Thus, the default value of the environment variable should be the local development environment, generally represented by the character 'dev'. After determining the specific value of the environment variable, the corresponding domain name can be obtained from the domain name mapping. Since the domain name is data common to sending different HTTP requests, the domain name is taken as a property of the class for better multiplexing.
Optionally, the dynamically acquiring the environment variable based on the HTTP request class, obtaining a corresponding domain name according to the environment variable, and assigning the domain name attribute to the HTTP request class includes:
step S104-1: reading a contract attribute (such as 'RUN_ENV') mounted on a global variable window in a constructor of the HTTP request class, and assigning the contract attribute to an environment variable; when reading the contract attributes mounted on the global variable fails, the environment variable is equal to the development environment variable.
Step S104-2: and taking the environment variable as a key, and obtaining a corresponding domain name from the domain name mapping.
Step S104-3: and assigning the obtained domain name to the domain name attribute of the HTTP request class.
Step S106: and synthesizing the domain name attribute of the HTTP request class and the path transmitted by the developer into a URL, sending an HTTP request, and automatically adapting to the running environment.
The HTTP request class contains member functions for realizing the request function, which are called request functions for short. When a developer calls a request function, information of a necessary HTTP request, such as a path, a method, data, and the like, needs to be transmitted. The uniform resource locator (uniform resource locator, URL) is a representation method for specifying the location of information on a web service program of the internet. The URL must be determined when sending the HTTP request. The domain name and path are the main components of the URL from which the URL can be synthesized. After synthesizing the URL, the request function may successfully initiate an HTTP request.
Optionally, the synthesizing the domain name attribute of the HTTP request class and the path imported by the developer into the URL, sending the HTTP request, and automatically adapting to the running environment, including:
step S106-1: the path, the method and the data are used as input parameters to call the request function of the HTTP request class instance.
Step S106-2: and in the request function, synthesizing the URL according to the domain name attribute of the HTTP request class and the path.
Step S106-3: the request function initiates an HTTP request to the composite URL and automatically adapts the runtime environment.
According to the method provided by the embodiment of the disclosure, when a developer issues a new code, the code to be issued can automatically identify the variable of the running environment by automatically obtaining the variable of the running environment, so that the front-end program can automatically adapt to different running environments, the development efficiency is effectively improved, and the adaptation error is reduced.
As shown in fig. 2, the present disclosure provides an apparatus for automatically adapting to an operating environment, which is configured to execute the method described in the second embodiment, where the same content in the embodiment has the same technical effects as the second embodiment, and is not described herein. The method specifically comprises the following steps: acquisition unit 202, acquisition unit 204, and transmission unit 206.
The acquisition unit 202: and the HTTP request class is used for constructing the mapping between the running environment and the corresponding domain name and instantiating the HTTP request class.
Optionally, the obtaining unit 202 is further configured to:
first, determining a domain name corresponding to the operation environment, and constructing a mapping relation between the operation environment and the domain name to form domain name mapping.
Secondly, the domain name mapping is used as an input parameter, and a new operator is used for calling a constructor of the HTTP request class to obtain an HTTP request class instance.
Issue unit (not shown): the publishing system is used for injecting environment variables of the running environment into the front-end program codes to be published, and publishing the front-end program codes to be published to different running environments.
Optionally, the issuing unit is further configured to:
uploading front-end program codes to be published to a publishing system, and selecting an operating environment to publish, wherein the front-end program codes to be published comprise: HTML, JS, and CSS code.
And secondly, the release system assigns the selected running environment to the appointed attribute of the global variable, and the assignment logic is realized by using JS codes wrapped in script labels.
Thirdly, inserting script labels wrapping the JS codes into the HTML in a character string replacement mode.
Fourthly, issuing the HTML inserted into the script tag to a server cluster corresponding to the selected running environment.
The acquisition unit 204: and the domain name attribute is used for dynamically acquiring the environment variable based on the HTTP request class, obtaining the corresponding domain name according to the environment variable and assigning the domain name attribute to the HTTP request class.
Optionally, the obtaining unit 204 is further configured to:
first, in the constructors of HTTP request classes, reading the appointed attribute (such as 'RUN_ENV') mounted on the global variable window, and assigning to the environment variable; when reading the contract attributes mounted on the global variable fails, the environment variable is equal to the development environment variable.
And secondly, taking the environment variable as a key, and obtaining a corresponding domain name from the domain name mapping.
Thirdly, assigning the obtained domain name to the domain name attribute of the HTTP request class.
Transmission section 206: and the server is used for synthesizing the domain name attribute of the HTTP request class and the path imported by the developer into a URL, sending the HTTP request and automatically adapting to the running environment.
Optionally, the sending unit 206 is further configured to:
first, the path, method and data are used as input parameters to call the request function of the HTTP request class instance.
Secondly, in the request function, synthesizing a URL according to the domain name attribute of the HTTP request class and the path.
Thirdly, the request function initiates an HTTP request to the synthesized URL and automatically adapts to the running environment.
According to the device provided by the embodiment of the disclosure, when a developer issues a new code, the code to be issued can automatically identify the variable of the running environment by automatically obtaining the variable of the running environment, so that the front-end program can automatically adapt to different running environments, the development efficiency is effectively improved, and the adaptation error is reduced.
As shown in fig. 3, the present embodiment provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the one processor to enable the at least one processor to perform the method steps described in the embodiments above.
The disclosed embodiments provide a non-transitory computer storage medium storing computer executable instructions that perform the method steps described in the embodiments above.
Referring now to fig. 3, a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 3 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 3, the electronic device may include a processing means (e.g., a central processor, a graphics processor, etc.) 301 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage means 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 305. An input/output (I/O) interface 305 is also connected to the bus 305.
In general, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 305 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 305. The communication means 305 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While fig. 3 shows an electronic device having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via the communications device 305, or from the storage device 308, or from the ROM 302. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing means 301.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
Claims (8)
1. A method for automatically adapting an operating environment, comprising:
constructing a mapping between the running environment and the corresponding domain name and instantiating an HTTP request class;
the publishing system injects environment variables of the running environment into front-end program codes to be published, and publishes the front-end program codes to be published to different running environments;
dynamically acquiring an environment variable based on the HTTP request class, obtaining a corresponding domain name according to the environment variable, and assigning the domain name attribute to the HTTP request class, wherein the environment variable is used for representing an operation environment type;
synthesizing the domain name attribute of the HTTP request class and the path transmitted by the developer into a URL, sending an HTTP request, and automatically adapting to the running environment;
the dynamically acquiring the environment variable based on the HTTP request class, obtaining the corresponding domain name according to the environment variable and assigning the domain name attribute to the HTTP request class comprises the following steps:
reading the appointed attribute mounted on the global variable in the constructor of the HTTP request class, and assigning the appointed attribute to the environment variable;
the environment variable is used as a key, and a corresponding domain name is obtained from the domain name mapping;
and assigning the obtained domain name to the domain name attribute of the HTTP request class.
2. The method of claim 1, wherein constructing a mapping of a runtime environment to a corresponding domain name and instantiating an HTTP request class comprises:
determining a domain name corresponding to the operation environment, and constructing a mapping relation between the operation environment and the domain name to form domain name mapping;
and using the domain name mapping as an input parameter, and calling a constructor of the HTTP request class by using a new operator to obtain an HTTP request class instance.
3. The method according to claim 1, wherein in the constructor of the HTTP request class, reading the contract attribute mounted on the global variable and assigning the contract attribute to the environment variable, and then comprising:
when reading the contract attributes mounted on the global variable fails, the environment variable is equal to the development environment variable.
4. The method of claim 1, wherein the synthesizing the domain name attribute of the HTTP request class and the path entered by the developer into the URL, sending the HTTP request, and automatically adapting the runtime environment, comprises:
taking the path, the method and the data as input parameters, and calling a request function of an HTTP request class instance;
synthesizing a URL according to the domain name attribute of the HTTP request class and the path in the request function;
the request function initiates an HTTP request to the composite URL and automatically adapts the runtime environment.
5. The method of claim 1, wherein the publishing system injects the environment variables of the operating environment in the front-end program code to be published, publishing the front-end program code to be published to a different operating environment, comprising:
uploading front-end program codes to be published to a publishing system, and selecting an operating environment to publish, wherein the front-end program codes to be published comprise: HTML, JS, and CSS code;
the release system assigns the selected running environment to the appointed attribute of the global variable, and realizes assignment logic by using JS codes wrapped in script labels;
inserting script labels wrapping the JS codes into the HTML in a character string replacement mode;
and publishing the HTML inserted into the script tag to a server cluster corresponding to the selected running environment.
6. An apparatus for automatically adapting an operating environment, comprising:
the construction unit is used for constructing the mapping between the running environment and the corresponding domain name and instantiating an HTTP request class;
the publishing unit is used for injecting environment variables of the running environment into the front-end program codes to be published by the publishing system and publishing the front-end program codes to be published to different running environments;
the acquisition unit is used for dynamically acquiring an environment variable based on the HTTP request class, acquiring a corresponding domain name according to the environment variable and assigning the domain name attribute to the HTTP request class, wherein the environment variable is used for representing an operation environment type;
the sending unit is used for synthesizing the domain name attribute of the HTTP request class and the path transmitted by the developer into a URL, sending the HTTP request and automatically adapting to the running environment;
the acquisition unit is used for reading the appointed attribute mounted on the global variable in the constructor of the HTTP request class and assigning the appointed attribute to the environment variable; the environment variable is used as a key, and a corresponding domain name is obtained from the domain name mapping; and assigning the obtained domain name to the domain name attribute of the HTTP request class.
7. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any one of claims 1 to 5.
8. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which when executed by the one or more processors cause the one or more processors to implement the method of any of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010032136.6A CN111221572B (en) | 2020-01-13 | 2020-01-13 | Method, device, medium and equipment for automatically adapting to running environment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010032136.6A CN111221572B (en) | 2020-01-13 | 2020-01-13 | Method, device, medium and equipment for automatically adapting to running environment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111221572A CN111221572A (en) | 2020-06-02 |
CN111221572B true CN111221572B (en) | 2023-09-01 |
Family
ID=70828344
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010032136.6A Active CN111221572B (en) | 2020-01-13 | 2020-01-13 | Method, device, medium and equipment for automatically adapting to running environment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111221572B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111880801A (en) * | 2020-06-19 | 2020-11-03 | 北京三快在线科技有限公司 | Application program dynamic method and device and electronic equipment |
CN112256326B (en) * | 2020-10-27 | 2023-07-07 | 北京字跳网络技术有限公司 | Information processing method, device, equipment and storage medium |
CN113239346B (en) * | 2021-05-20 | 2021-11-09 | 南京瑞师信息科技有限公司 | Method and system for operation maintenance based on information security |
CN113411219B (en) * | 2021-06-29 | 2023-04-21 | 山东派盟网络科技有限公司 | Front-end service publishing method, device and equipment |
CN114553966B (en) * | 2022-01-21 | 2024-08-27 | 浪潮通用软件有限公司 | Method, device, equipment and medium for constructing Http request at front end |
CN117811920B (en) * | 2024-02-29 | 2024-06-11 | 粤港澳大湾区数字经济研究院(福田) | Intelligent contract management method, system, terminal and medium based on blockchain |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105391811A (en) * | 2014-08-29 | 2016-03-09 | 腾讯科技(深圳)有限公司 | DNS (domain name resolution) method, access method for application server, and terminal |
CN105528297A (en) * | 2016-01-29 | 2016-04-27 | 广州酷狗计算机科技有限公司 | Method and device for testing web page |
CN106020877A (en) * | 2016-05-16 | 2016-10-12 | 乐视控股(北京)有限公司 | Automatic update method and apparatus for system environment configuration |
CN107402880A (en) * | 2016-05-20 | 2017-11-28 | 腾讯科技(北京)有限公司 | A kind of method of testing and electronic equipment |
CN107688730A (en) * | 2017-07-28 | 2018-02-13 | 宁波保税区攀峒信息科技有限公司 | A kind of executable file method for safe operation |
CN109814877A (en) * | 2018-12-14 | 2019-05-28 | 深圳壹账通智能科技有限公司 | Project deployment method and device based on environmental management |
CN110149423A (en) * | 2019-07-04 | 2019-08-20 | 深圳市珍爱捷云信息技术有限公司 | Domain name processing method, device, readable storage medium storing program for executing and electronic equipment |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100023955A1 (en) * | 2008-07-28 | 2010-01-28 | Marcottage | Method and system and apparatus for dynamic software environment |
US9432426B2 (en) * | 2013-02-04 | 2016-08-30 | Qualcomm Incorporated | Determining available media data for network streaming |
-
2020
- 2020-01-13 CN CN202010032136.6A patent/CN111221572B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105391811A (en) * | 2014-08-29 | 2016-03-09 | 腾讯科技(深圳)有限公司 | DNS (domain name resolution) method, access method for application server, and terminal |
CN105528297A (en) * | 2016-01-29 | 2016-04-27 | 广州酷狗计算机科技有限公司 | Method and device for testing web page |
CN106020877A (en) * | 2016-05-16 | 2016-10-12 | 乐视控股(北京)有限公司 | Automatic update method and apparatus for system environment configuration |
CN107402880A (en) * | 2016-05-20 | 2017-11-28 | 腾讯科技(北京)有限公司 | A kind of method of testing and electronic equipment |
CN107688730A (en) * | 2017-07-28 | 2018-02-13 | 宁波保税区攀峒信息科技有限公司 | A kind of executable file method for safe operation |
CN109814877A (en) * | 2018-12-14 | 2019-05-28 | 深圳壹账通智能科技有限公司 | Project deployment method and device based on environmental management |
CN110149423A (en) * | 2019-07-04 | 2019-08-20 | 深圳市珍爱捷云信息技术有限公司 | Domain name processing method, device, readable storage medium storing program for executing and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN111221572A (en) | 2020-06-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111221572B (en) | Method, device, medium and equipment for automatically adapting to running environment | |
CN110489101B (en) | Interface simulation method, system, medium and electronic equipment | |
CN111338623B (en) | Method, device, medium and electronic equipment for developing user interface | |
CN111309304B (en) | Method, device, medium and electronic equipment for generating IDL file | |
GB2589658A (en) | Method and apparatus for running an applet | |
CN111400172B (en) | Program debugging method and device | |
CN111367516B (en) | Application interface generation method and device and electronic equipment | |
CN112395253B (en) | Index file generation method, terminal device, electronic device and medium | |
CN111414154A (en) | Method and device for front-end development, electronic equipment and storage medium | |
CN113391860B (en) | Service request processing method and device, electronic equipment and computer storage medium | |
CN112631590A (en) | Component library generation method and device, electronic equipment and computer readable medium | |
CN112558933B (en) | Component rendering method and device, readable medium and electronic equipment | |
CN109800378A (en) | Content processing method, device and electronic equipment based on custom browser | |
CN111783010B (en) | Webpage blank page monitoring method, device, terminal and storage medium | |
CN109408057B (en) | Method, device, medium and computing equipment for automatically generating codes | |
CN117931219A (en) | Front-end project implementation method and device, electronic equipment and storage medium | |
CN113704079A (en) | Interface testing method and device based on Protobuf | |
CN114928556B (en) | Interface service testing method and related equipment | |
CN111338928A (en) | Chrome-based browser testing method and device | |
CN111400623B (en) | Method and device for searching information | |
CN113590483A (en) | Case operation method and device | |
CN112596838A (en) | Display method, device and equipment of general Web page and storage medium | |
CN116561015B (en) | Map application testing method, electronic device and computer readable medium | |
CN112506781A (en) | Test monitoring method, test monitoring device, electronic device, storage medium, and program product | |
CN114047922B (en) | Transcoding method, device, medium and equipment for precompiled device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |