The content of the invention
The embodiments of the invention provide a kind of method and apparatus of dynamic configuration application program, for realizing according to actual fortuneRow environment obtains correspondence configuration file, and then dynamic configuration application program.
In a first aspect, the invention provides a kind of method of dynamic configuration application program, including:
When needing configuration application program, the current environment mark of electronic equipment where obtaining the application program is describedCurrent environment mark represents the current operating environment of the electronic equipment;
Identified, obtained and the corresponding target configuration file of current environment mark according to the current environment;
The application program is configured based on the target configuration file.
Optionally, the current environment mark of electronic equipment where obtaining the application program, including:
The current operating environment of the electronic equipment is detected, joined with the environment for obtaining the electronic equipmentNumber;
Based on the ambient parameter, the current environment mark is determined.
Optionally, the current environment mark of electronic equipment where obtaining the application program, including:
One program message is sent to the corresponding server of the application program by the application program;The server pointThe ambient parameter of the current operating environment for the electronic equipment that described program message is carried is analysed, based on the ambient parameterDetermine the current environment mark;
Receive the current environment mark that the server is sent.
Optionally, the running environment that the electronic equipment is supported includes N kinds, one environment of every kind of running environment correspondenceMark, N is positive integer, is identified according to the current environment, obtains target configuration text corresponding with current environment markBefore part, methods described also includes:
Storage and the one-to-one N number of alternative configurations file of running environment described in N kinds, each alternative configurations file pairAnswer the environmental labelses;Or
The program file of the application program is obtained, described program file includes corresponding with running environment described in N kindsN number of alternative configurations file, one environmental labels of each alternative configurations file correspondence.
Optionally, acquisition and the corresponding target configuration file of current environment mark, including:
The target configuration file will be defined as corresponding to the alternative configurations file that the current environment is identified.
Optionally, the application program is configured based on the target configuration file, including:
The original configuration file in the configuration file of the application program is covered with the target configuration file, it is described originalConfiguration file is the target configuration file of last time or the default configuration file of the application program;
Run the configuration file of the application program.
Optionally, the original configuration file in the configuration file of the application program is covered with the target configuration file,Including:
The Part I of the original configuration file is covered with the Part I of the target configuration file, the target is matched somebody with somebodyThe Part I for putting file is different from the Part I of the original configuration file.
Second aspect, the invention provides a kind of device of dynamic configuration application program, including:
Identifier acquisition module, for when needing configuration application program, obtaining application program place electronic equipmentCurrent environment is identified, and the current environment mark represents the current operating environment of the electronic equipment;
File obtains module, for being identified according to the current environment, obtains and the corresponding mesh of current environment markMark configuration file;
Configuration module, for being configured based on the target configuration file to the application program.
Optionally, the identifier acquisition module is used to detect the current operating environment of the electronic equipment,To obtain the ambient parameter of the electronic equipment;Based on the ambient parameter, the current environment mark is determined.
Optionally, the mark obtains module and is used for by the application program to the corresponding server of the application programSend a program message;The current operating environment for the electronic equipment that the server analysis described program message is carriedAmbient parameter, current environment mark is determined based on the ambient parameter;Receive the described current of the server transmissionEnvironmental labelses.
Optionally, the running environment that the electronic equipment is supported includes N kinds, one environment of every kind of running environment correspondenceMark, N is positive integer, and described device also includes:
Memory module, for being identified according to the current environment, is obtained and the corresponding target of current environment markBefore configuration file, storage and the one-to-one N number of alternative configurations file of running environment described in N kinds, each alternative configurationsFile one environmental labels of correspondence;Or
Program file obtains module, and the program file for obtaining the application program, described program file includes and N kindsThe one-to-one N number of alternative configurations file of the running environment, one ring of each alternative configurations file correspondenceBorder is identified.
Optionally, the file obtains the alternative configurations file that module is used to identify corresponding to the current environmentIt is defined as the target configuration file.
Optionally, the configuration module is used for in the configuration file of the target configuration file covering application programOriginal configuration file, the original configuration file is silent for the last target configuration file or the application programRecognize configuration file;Run the configuration file of the application program.
Optionally, the configuration module is used to cover the original configuration text with the Part I of the target configuration fileThe Part I of part, the Part I of the target configuration file is different from the Part I of the original configuration file.
Said one or multiple technical schemes in the embodiment of the present application, are at least imitated with following one or more technologiesReally:
In the technical scheme of the embodiment of the present invention, when needing configuration application program, the application program is obtained firstThe current environment mark of place electronic equipment, the current environment mark represents the current operating environment of the electronic equipment, soAcquisition and the corresponding target configuration file of current environment mark, and then based on the target configuration file to the application afterwardsProgram is configured.It can be seen that, by above-mentioned Dynamic Configuration Process, due to obtaining target configuration corresponding with current operating environmentFile, so avoiding due to without configuration file of the download right version without correct correspondence running environment, Jin ErwuThe problem of method runs application program.Further, even if the running environment change of electronic equipment, according to the environmental labelses of new environment justThe configuration file suitable for new running environment can be dynamically obtained, so that application program can continue in new running environmentMiddle operation.So, the embodiment of the present invention realizes the technique effect according to actual motion environment dynamic configuration application program.
Embodiment
The embodiments of the invention provide a kind of method and apparatus of dynamic configuration application program, for realizing according to actual fortuneRow environment obtains correspondence configuration file, and then dynamic configuration application program.
In order to solve the above-mentioned technical problem, the technical scheme general thought that the present invention is provided is as follows:
In the technical scheme of the embodiment of the present invention, when needing configuration application program, the application program is obtained firstThe current environment mark of place electronic equipment, the current environment mark represents the current operating environment of the electronic equipment, soAcquisition and the corresponding target configuration file of current environment mark, and then based on the target configuration file to the application afterwardsProgram is configured.It can be seen that, by above-mentioned Dynamic Configuration Process, due to obtaining target configuration corresponding with current operating environmentFile, so avoiding due to without configuration file of the download right version without correct correspondence running environment, Jin ErwuThe problem of method runs application program.Further, even if the running environment change of electronic equipment, according to the environmental labelses of new environment justThe configuration file suitable for new running environment can be dynamically obtained, so that application program can continue in new running environmentMiddle operation.So, the embodiment of the present invention realizes the technique effect according to actual motion environment dynamic configuration application program.
Technical solution of the present invention is described in detail below by accompanying drawing and specific embodiment, it should be understood that the applicationSpecific features in embodiment and embodiment are the detailed description to technical scheme, rather than to present techniquesThe restriction of scheme, in the case where not conflicting, the technical characteristic in the embodiment of the present application and embodiment can be mutually combined.
The terms "and/or", only a kind of incidence relation for describing affiliated partner, represents there may be three kinds of passesSystem, for example, A and/or B, can be represented:Individualism A, while there is A and B, these three situations of individualism B.In addition, hereinMiddle character "/", it is a kind of relation of "or" to typically represent forward-backward correlation object.
First aspect present invention provides a kind of method of dynamic configuration application program, refer to Fig. 1, is implementation of the present inventionThe method flow diagram of example dynamic configuration application program.This method includes:
S101:When needing configuration application program, the current environment mark of electronic equipment where obtaining the application program,The current environment mark represents the current operating environment of the electronic equipment;
S102:Identified, obtained and the corresponding target configuration file of current environment mark according to the current environment;
S103:The application program is configured based on the target configuration file.
Specifically, in embodiments of the present invention, it is necessary to when configuring application program, including but not limited to install and apply journeyWhen sequence with operation application program etc., the present invention is not particularly limited.When configuration application program is needed,In S101, the current environment mark of electronic equipment where obtaining application program.
Specifically, application program is installed and operated in an electronic equipment in the embodiment of the present invention, and electronic equipment is for exampleFor mobile phone, tablet personal computer or desktop computer etc., also, electronic equipment in the embodiment of the present invention can be specially client device,Can also be server, the present invention is not particularly limited.The running environment that electronic equipment is supported has N number of, N number of positive integer.So,Electronic equipment may operate in any one running environment of N number of running environment.Environmental labelses represent running environment, different fortuneThe corresponding different environmental labelses of row environment.Current environment mark then represents the current operating environment of electronic equipment.
Obtain after current environment mark, next, in S102, being identified according to current environment, obtain and current environment markKnow corresponding target configuration file.Finally, application program is configured based on target configuration file in S103.Due to currentEnvironmental labelses illustrate the current operating environment of electronic equipment, so be exactly with the corresponding target configuration file of current environment markIt is adapted to the configuration file of current operating environment, then application program is configured based on target configuration file, can to apply journeySequence is adapted to current operation, and then can be run under current operating environment.
Seen from the above description, due to obtaining target configuration file corresponding with current operating environment, so avoidingDue to corresponding to the configuration file of running environment without correct without download right version, and then application program can not be runProblem.Further, even if the running environment change of electronic equipment, it is obtained with being applied to newly according to the environmental labelses of new environmentThe configuration file of running environment, so that application program can continue to run in new running environment.So, the present invention is implementedExample realizes the technique effect according to actual motion environment dynamic configuration application program.
The current environment that electronic equipment how is obtained in S101 is identified below and described in detail.In the embodiment of the present inventionIn, obtaining the embodiment of current environment mark has two kinds.
In the first embodiment, the current environment mark for obtaining electronic equipment is realized especially by following process:
The current operating environment of the electronic equipment is detected, joined with the environment for obtaining the electronic equipmentNumber;
Based on the ambient parameter, the current environment mark is determined.
Specifically, ambient parameter is with including but is not limited to electronic equipment IP (Internet protocol, Internet Protocol)Location, place network, operating system and user name etc..When needing to configure application program, to the current fortune of electronic equipmentRow environment is detected, for example, read electronic equipment IP address and place network, and detection operating system and acquisition are set in electronicsUser name of standby upper login etc., the present invention is to ambient parameter and detects that the method for ambient parameter is not particularly limited.
Then, determine that current environment is identified based on ambient parameter.Specifically, electronic equipment prestore ambient parameter withThe corresponding relation of environmental labelses, or can also be corresponding with environmental labelses including ambient parameter in the program file of application programRelation, and then, after the ambient parameter for detecting electronic equipment current operating environment, control ambient parameter is corresponding with environmental labelsesRelation, it is possible to determine that current environment is identified.
For convenience of explanation, with ambient parameter it is specially below IP address, place network and operating system, running environment isDevelopment environment, production environment and use environment, and corresponding environmental labelses are to be introduced exemplified by 1,2 and 3 respectively.It refer toTable 1, is an ambient parameter and the corresponding relation schematic table of environmental labelses.
Table 1
The above-mentioned row of table 1 second represents that, if IP address is in 11.0.0.0~11.255.255.255 scopes, place network isDOUYU1 or DOUYU2, and operating system is DOS systems, then the running environment of electronic equipment where application program is exploitation ringBorder, correspondence environmental labelses 1;The third line of table 1 is represented, if IP address is in 12.0.0.0~12.255.255.255, place network isDOUYU1 or DOUYU2, and operating system is DOS systems, then the running environment of electronic equipment where application program is exploitation ringBorder, correspondence environmental labelses 1;The row of table 1 the 6th is represented, if IP address is in 192.168.0.0-192.168.255.255, place networkFor other networks beyond DOUYU1 or DOUYU2, and operating system is Android Android, apple mobile device operation systemIos, win XP, win 7 or the systems of win 10, then the running environment of electronic equipment where application program is use environment, correspondenceEnvironmental labelses 3.The fourth line of table 1 is similar with the implication that fifth line is represented, is not just described in detail one by one here.
Assuming that when needing to configure application program, the ambient parameter detected is specially IP address 11.1.1.1,Place network DOUYU1, operating system DOS.The corresponding relation of ambient parameter and environmental labelses according to table 1, due to11.1.1.1 in 11.0.0.0~11.255.255.255 scopes, and place network is DOUYU1, and operating system is DOS, becauseThe current operating environment of this determination electronic equipment is development environment, and current environment is designated 1.
In second of embodiment, the current environment mark for obtaining electronic equipment is realized especially by following process:
One program message is sent to the corresponding server of the application program by the application program;The server pointThe ambient parameter of the current operating environment for the electronic equipment that described program message is carried is analysed, based on the ambient parameterDetermine the current environment mark;
Receive the current environment mark that the server is sent.
Specifically, program message is any message that application program is sent to the corresponding server of application program, for exampleRequest message, return message, connection message or notification message etc., the present invention is not particularly limited.Application program is arranged on electronicsIn equipment, application program will be sent out to server transmission program message by the transmitter of electronic equipment, interface and place network etc.Send, therefore, according to general protocol, the parameter of electronic equipment can be included in program message, and these parameters can reflect electronicsThe current operating environment of equipment.In other words, program message will carry the ambient parameter of electronic equipment.
So, by application program to server transmission program message, server can just parse program message carryingAmbient parameter, thus analyze the current operating environment of electronic equipment, and then determine current environment mark.
Can also in advance can be with storage environment parameter and environmental labelses similar to the first above-mentioned embodiment, in serverCorresponding relation, and then the corresponding relation based on ambient parameter and environmental labelses and the ambient parameter that parses determine that electronics is setStandby current environment mark.How it had been discussed in detail in the first embodiment based on ambient parameter and environmental labelsesCorresponding relation determines that current environment is identified, and just it is no longer repeated here.
Or, server receives program message and simultaneously parsed after ambient parameter, can also be on the administrative staff of serverAmbient parameter is reported, administrative staff is carried out more comprehensive and accurate analysis to ambient parameter, so that it is determined that current environmentMark.
Next, the current environment mark that electronic equipment the reception server is determined and sent, is derived from current environment markKnow.
Below, it is introduced to how to be obtained in S102 with the corresponding target configuration file of current environment mark.
The configuration file in the embodiment of the present invention is introduced first.
In embodiments of the present invention, the running environment that electronic equipment is supported includes N kinds, and N kind running environment is differed,In other words, electronic equipment may operate in a variety of running environment of N.N is positive integer.In one embodiment, existBefore S102, in addition to:
Storage and the one-to-one N number of alternative configurations file of running environment described in N kinds, each alternative configurations file pairAnswer the environmental labelses.
Specifically, alternative configurations file be application program in configuration file used in each running environment, with operationEnvironment is corresponded, and is had N number of.In embodiments of the present invention, alternative configurations file can be specially complete configuration file, i.e.,Include all configuration items in each alternative configurations file.Or, alternative configurations file can also only include different piece.
Specifically, although application program needs different configurations, difference operation ring in different running environmentThe configuration in border may also include identical part, such as rendering same background color and display identical application name,Therefore, in order to reduce the data volume of alternative configurations file, alternative configurations file can only include different piece.
For example, operating in the application program of development environment needs the first database of connection and first port, operates inThe application program of production environment needs the second database of connection and second port, and operating in the application program of use environment needs companyThe 3rd database and the 3rd port are connect, and for the configuration all same in development environment, production environment and use environment, then,The address of the first database and first port can only be included corresponding to the standby configuration file of development environment, corresponding to production ringThe standby configuration file in border can only include the address of the second database and second port, corresponding to the standby configuration of use environmentFile can only include the address of the 3rd database and the 3rd port.
In addition, each alternative configurations file is corresponding with an environmental labelses, and specific corresponding environmental labelses are its correspondenceRunning environment environmental labelses.During implementing, the corresponding environmental labelses of alternative configurations file can be arranged onProperty parameters or filename etc., the present invention is not particularly limited.
In another embodiment, before S102, in addition to:
The program file of the application program is obtained, described program file includes corresponding with running environment described in N kindsN number of alternative configurations file, one environmental labels of each alternative configurations file correspondence.
Specifically, it is no longer repeated for the something in common of this kind of embodiment and aforementioned embodiments.Different from above-mentionedEmbodiment stores standby configuration file in the electronic device, and in this kind of embodiment, N number of standby configuration file is arranged onIn program file, so obtaining the program file of application program, N number of standby configuration file is just obtained.ImplementingCheng Zhong, those skilled in the art can be according to the above-mentioned any embodiment of actual selection, and the present invention is not doneConcrete restriction.
Next, being introduced to how to be obtained in S102 with the corresponding target configuration file of current environment mark.With reference toTarget configuration file is obtained especially by following mistake in the embodiment of any one above-mentioned storage standby configuration file, S102Journey:
The target configuration file will be defined as corresponding to the alternative configurations file that the current environment is identified.
Specifically, because each standby configuration file is corresponding with an environmental labelses, therefore, identified with current environmentCorresponding standby configuration file, is just the configuration file for being adapted to current operating environment, so identified according to current environment, will be rightThe alternative configurations file that should be identified in current environment is defined as target configuration file.
It is introduced below to how to carry out configuration based on target configuration file in S103.In embodiments of the present invention,S103 can be realized by following process:
The original configuration file in the configuration file of the application program is covered with the target configuration file, it is described originalConfiguration file is the target configuration file of last time or the default configuration file of the application program;
Run the configuration file of the application program.
Specifically, electronic equipment needs to read application program according to specified path when being configured for application programContent in configuration file, before S103 is configured based on target configuration file to application program, the configuration text of application programContent in part is the content of original configuration file.Specifically, if being specifically when the application is installed to application programConfigured, then original configuration file is specially just the default configuration file of application program, default configuration file can be to appointThe integrated configuration file of one standby configuration file or acquiescence, the present invention is not particularly limited.And should in operation if being specificallyApplication program is configured during with program, then original configuration file be specially just it is last according to embodiments of the present invention in skillThe target configuration file that art scheme is determined.
When the target configuration file based on this determination configures application program, with the target configuration file of this determinationContent covers the content of the original configuration file in the configuration file of application program, and then electronic equipment runs matching somebody with somebody for application programFile is put, is achieved that and application program is configured according to the target configuration file of this determination.
Whether a kind of embodiment wherein, can contrast target configuration file that this determines and original configuration fileIt is identical.If this target configuration file determined is identical with original configuration file, in order to save device resource, it can be not required toAgain original configuration file is covered, the configuration file of application program is run.
In another embodiment, target configuration file and original configuration file that this is determined can not also be contrastedIt is whether identical, original configuration file is directly covered with the target configuration file of this determination.
In addition, being described above, alternative configurations file can be specially complete configuration file, can also only includeDifferent piece.Therefore, just specifically there are two kinds of embodiments when covering original configuration file with target configuration file.A kind of realApply in mode, standby configuration file is complete configuration file, then when covering original configuration file, text will be configured with whole targetPart covers whole original configuration file.
In another embodiment, standby configuration file can be complete configuration file, can also only include differencePart, in this kind of embodiment, is covered in the following way:
The Part I of the original configuration file is covered with the Part I of the target configuration file, the target is matched somebody with somebodyThe Part I for putting file is different from the Part I of the original configuration file.
Specifically, the Part I of target configuration file and the Part I of original configuration file are different, i.e., firstIt is divided to the different piece for referring to two configuration files.In order to reduce overlay capacity, less configuration used time, with the of target configuration fileThe Part I of part covering original configuration file, and then cause the original configuration file after covering to change into target configurationFile.
Example above is continued to use, the application program for operating in development environment, production environment and use environment is only to connectThe database connect is different with port, and other configurations are identical.It is therefore assumed that target configuration file is the standby of correspondence production environmentDatabase address in original configuration file, then be covered as the address of the first database by configuration file, and port address is covered asFirst port address, other configurations then need not be covered or changed.
Based on the inventive concept same with the method for dynamic configuration application program in previous embodiment, second aspect of the present inventionA kind of device of dynamic configuration application program is also provided, as shown in Fig. 2 including:
Identifier acquisition module 101, for when needing configuration application program, obtaining electronic equipment where the application programCurrent environment mark, current environment mark represents the current operating environment of the electronic equipment;
File obtains module 102, for being identified according to the current environment, obtains corresponding with current environment markTarget configuration file;
Configuration module 103, for being configured based on the target configuration file to the application program.
Optionally, identifier acquisition module 101 is used to detect the current operating environment of the electronic equipment, withObtain the ambient parameter of the electronic equipment;Based on the ambient parameter, the current environment mark is determined.
Optionally, mark obtains module 101 and is used for by the application program to the corresponding server of the application programSend a program message;The current operating environment for the electronic equipment that the server analysis described program message is carriedAmbient parameter, current environment mark is determined based on the ambient parameter;Receive the described current of the server transmissionEnvironmental labelses.
Optionally, the running environment that the electronic equipment is supported includes N kinds, one environment of every kind of running environment correspondenceMark, N is positive integer, and described device also includes:
Memory module, for being identified according to the current environment, is obtained and the corresponding target of current environment markBefore configuration file, storage and the one-to-one N number of alternative configurations file of running environment described in N kinds, each alternative configurationsFile one environmental labels of correspondence;Or
Program file obtains module, and the program file for obtaining the application program, described program file includes and N kindsThe one-to-one N number of alternative configurations file of the running environment, one ring of each alternative configurations file correspondenceBorder is identified.
Optionally, file obtains the alternative configurations file that module 102 is used to identify corresponding to the current environmentIt is defined as the target configuration file.
Optionally, configuration module 103 is used for in the configuration file of the target configuration file covering application programOriginal configuration file, the original configuration file is silent for the last target configuration file or the application programRecognize configuration file;Run the configuration file of the application program.
Optionally, configuration module 103 is used to cover the original configuration text with the Part I of the target configuration fileThe Part I of part, the Part I of the target configuration file is different from the Part I of the original configuration file.
The various change mode and instantiation of the method for dynamic configuration application program in the embodiment of earlier figures 1 are equally fittedFor the device of the dynamic configuration application program of the present embodiment, pass through retouching in detail for the foregoing method to dynamic configuration application programState, those skilled in the art are clear that the implementation of the device of dynamic configuration application program in the present embodiment, instituteWith succinct for specification, it will not be described in detail herein.
Said one or multiple technical schemes in the embodiment of the present application, are at least imitated with following one or more technologiesReally:
In the technical scheme of the embodiment of the present invention, when needing configuration application program, the application program is obtained firstThe current environment mark of place electronic equipment, the current environment mark represents the current operating environment of the electronic equipment, soAcquisition and the corresponding target configuration file of current environment mark, and then based on the target configuration file to the application afterwardsProgram is configured.It can be seen that, by above-mentioned Dynamic Configuration Process, due to obtaining target configuration corresponding with current operating environmentFile, so avoiding due to without configuration file of the download right version without correct correspondence running environment, Jin ErwuThe problem of method runs application program.Further, even if the running environment change of electronic equipment, according to the environmental labelses of new environment justThe configuration file suitable for new running environment can be dynamically obtained, so that application program can continue in new running environmentMiddle operation.So, the embodiment of the present invention realizes the technique effect according to actual motion environment dynamic configuration application program.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer programProduct.Therefore, the present invention can be using the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardwareApply the form of example.Moreover, the present invention can be used in one or more computers for wherein including computer usable program codeThe computer program production that usable storage medium is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.)The form of product.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program productFigure and/or block diagram are described.It should be understood that can be by every first-class in computer program instructions implementation process figure and/or block diagramJourney and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be providedThe processor of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produceA raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for realThe device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spyDetermine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which is produced, to be included referring toMake the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram orThe function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that in meterSeries of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, thus in computer orThe instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram oneThe step of function of being specified in individual square frame or multiple square frames.
Obviously, those skilled in the art can carry out the essence of various changes and modification without departing from the present invention to the present inventionGod and scope.So, if these modifications and variations of the present invention belong to the scope of the claims in the present invention and its equivalent technologiesWithin, then the present invention is also intended to comprising including these changes and modification.