CN111736921A - Service configuration method, device, equipment and computer readable storage medium - Google Patents

Service configuration method, device, equipment and computer readable storage medium Download PDF

Info

Publication number
CN111736921A
CN111736921A CN202010597475.9A CN202010597475A CN111736921A CN 111736921 A CN111736921 A CN 111736921A CN 202010597475 A CN202010597475 A CN 202010597475A CN 111736921 A CN111736921 A CN 111736921A
Authority
CN
China
Prior art keywords
environment
configuration
service
switch
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010597475.9A
Other languages
Chinese (zh)
Inventor
余东杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202010597475.9A priority Critical patent/CN111736921A/en
Publication of CN111736921A publication Critical patent/CN111736921A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/442Shutdown
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to the technical field of financial technology (Fintech), and discloses a service configuration method, which comprises the following steps: when detecting that a container is started, acquiring an environment attribute file associated with the container; traversing the environment attribute file, and acquiring an environment switch configured in the environment attribute file and the state of the environment switch; and loading the configuration class associated with the environment switch according to the state of the environment switch, and providing configured services through a target object in the configuration class. The invention also discloses a service configuration device, equipment and a computer readable storage medium. According to the invention, the environment attribute file is configured in advance, the configuration classes of different environments are configured in the environment attribute file, the environment switch is arranged on the configuration classes, the configuration classes of different environments can be loaded to provide configuration services by configuring the state of the environment switch, and the code does not need to be changed according to the environment invasion, so that the code maintenance is convenient.

Description

Service configuration method, device, equipment and computer readable storage medium
Technical Field
The present invention relates to the field of financial technology (Fintech), and in particular, to a service configuration method, apparatus, device, and computer-readable storage medium.
Background
With the rapid development of internet technologies, especially internet financial technology (Fintech), more and more technologies (big data, distributed, Blockchain, artificial intelligence, etc.) are applied in the financial field.
The current digital financial service is realized through codes, different types of codes need to be compiled under different operation environments for the same financial service function, so that the development cost of the codes is high, in order to reduce the development cost of the codes, part of development, operation and maintenance personnel create a technical scheme for performing service configuration according to environmental information, and when the service configuration is performed based on the environment at present: development, operation and maintenance personnel monitor the service of each environment, determine the differential service under different environments, then manually write codes to create objects under different environments, and under the condition that the objects are missing, inject the objects according to environment selection through a Spring (Spring is a lightweight Java development framework of an open source code) framework.
Disclosure of Invention
The invention mainly aims to provide a service configuration method, a service configuration device, service configuration equipment and a computer readable storage medium, and aims to solve the technical problems that in the current service configuration method in different environments, different services in each environment need to be checked, the code intrusiveness is high by adopting an object injection mode, and the code maintenance is difficult in different environments.
In order to achieve the above object, the present invention provides a service configuration method, including the following steps:
when detecting that a container is started, acquiring an environment attribute file associated with the container;
traversing the environment attribute file, and acquiring an environment switch configured in the environment attribute file and the state of the environment switch;
and loading the configuration class associated with the environment switch according to the state of the environment switch, and providing configured services through a target object in the configuration class.
Optionally, before the step of traversing the environment attribute file, acquiring the environment switch configured in the environment attribute file, and the state of the environment switch, the method includes:
outputting an environment creation page when receiving an environment creation request;
acquiring difference process information input based on the environment creation page, and packaging the difference process information to form a target object;
combining the target objects to form a configuration class, creating an environment switch at the front end of the configuration class, and storing the environment switch and the configuration class in a preset environment attribute file in a related manner;
when a service configuration request is received, outputting the environment attribute file to prompt development, operation and maintenance personnel to configure the state of an environment switch in the environment attribute file;
and saving the configured state of the environment switch to complete service configuration.
Optionally, the step of loading the configuration class associated with the environmental switch according to the state of the environmental switch, and providing the configured service through the target object in the configuration class includes:
acquiring the state of the environment switch;
when the environment switch is in a closed state, determining a configuration class corresponding to the environment switch, simulating a difference object in the configuration class to generate a proxy object, and handing the proxy object to a container for hosting;
and when the environment switch is in an opening state, loading the configuration class associated with the environment switch, and providing configured services through a target object in the configuration class.
Optionally, when the environment switch is in an off state, the step of determining a configuration class corresponding to the environment switch, simulating a differential object in the configuration class to generate a proxy object, and submitting the proxy object to a container for hosting includes:
when the environment switch is in a closed state, determining a configuration class corresponding to the environment switch;
acquiring a difference object in the configuration class, and judging whether the difference object is associated with a missing prompt or not;
if the difference object is not associated with the missing prompt, prompting configuration;
if the difference object is associated with the missing prompt, simulating the difference object in the configuration class to generate a proxy object, and submitting the proxy object to a container for hosting.
Optionally, after the step of loading the configuration class associated with the environmental switch according to the state of the environmental switch and providing the configured service through the target object in the configuration class, the method includes:
when a service query request is received, acquiring an environment attribute file associated with the service query request;
acquiring an environment switch marked in the environment attribute file and a configuration class corresponding to the environment switch;
and acquiring an object identifier of a target object in the configuration class, inputting the object identifier into a preset data table and outputting the object identifier so that a user can check the object identifier in the preset data table to determine the configured service.
Optionally, the step of loading the configuration class associated with the environmental switch according to the state of the environmental switch, and providing the configured service through the target object in the configuration class includes:
loading the configuration class associated with the environment switch according to the state of the environment switch, and judging whether the service provided by the target object in the configuration class conflicts;
if the service provided by the target object has conflict, a conflict prompt is output;
and if the service provided by the target object does not have conflict, providing the configured service through the target object in the configuration class.
Optionally, after the step of loading the configuration class associated with the environmental switch according to the state of the environmental switch and providing the configured service through the target object in the configuration class, the method includes:
when a service call request is received, acquiring a container associated with the call request and a configuration class loaded in the container;
acquiring a calling object in the configuration class, and judging whether the calling object is a proxy object;
and when the calling object is the proxy object, prompting an environment abnormal log to enable development, operation and maintenance personnel to adjust service configuration according to the environment abnormal log.
In addition, to achieve the above object, the present invention further provides a service configuration apparatus, including:
the request receiving module is used for acquiring an environment attribute file associated with the container when the container is detected to be started;
the traversal output module is used for traversing the environment attribute file, and acquiring the environment switch configured in the environment attribute file and the state of the environment switch;
and the acquisition loading module is used for loading the configuration class associated with the environmental switch according to the state of the environmental switch and providing configured services through the target object in the configuration class.
In addition, to achieve the above object, the present invention further provides a service configuration device, including: a memory, a processor and a service configuration program stored on the memory and executable on the processor, the service configuration program when executed by the processor implementing the steps of the service configuration method as described above.
Furthermore, to achieve the above object, the present invention also provides a computer readable storage medium, having stored thereon a service configuration program, which when executed by a processor, implements the steps of the service configuration method as described above.
The invention provides a service configuration method, a service configuration device, service configuration equipment and a computer readable storage medium. In the embodiment of the invention, when the container is detected to be started, the environment attribute file associated with the container is obtained; traversing the environment attribute file, and acquiring an environment switch configured in the environment attribute file and the state of the environment switch; and loading the configuration class associated with the environment switch according to the state of the environment switch, and providing configured services through a target object in the configuration class. In the embodiment of the invention, an environment attribute file is configured in advance, configuration classes of different environments are configured in the environment attribute file, an environment switch is arranged on the configuration classes, and the state of the environment switch configured in the environment attribute file by operation and maintenance personnel is developed; according to the state of the configured environment switch, the configuration classes of different environments can be loaded, configured services are provided through objects in the configuration classes, and service configuration operation under different environments is achieved, so that development, operation and maintenance personnel are not required to detect differential service definition differential codes under different environments, codes are not required to be changed by a user in an invasive manner, code maintenance is convenient for service configuration operation, and workload of the development, operation and maintenance personnel is reduced.
Drawings
FIG. 1 is a schematic diagram of an apparatus architecture of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a service configuration according to a first embodiment of the service configuration method of the present invention;
FIG. 3 is a flowchart illustrating a service provisioning method according to a first embodiment of the present invention;
fig. 4 is a schematic view of a specific scenario of service configuration in a first embodiment of the service configuration method according to the present invention;
fig. 5 is a functional block diagram of an embodiment of a service provisioning apparatus according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, fig. 1 is a schematic device structure diagram of a hardware operating environment according to an embodiment of the present invention.
The service configuration device of the embodiment of the invention can be a PC or a server.
As shown in fig. 1, the service configuration apparatus may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 1 is not intended to be limiting of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a service configuration program.
In the device shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be configured to call a service configuration program stored in the memory 1005 and perform operations in the service configuration method described below.
When service configuration is currently performed based on the environment: the development, operation and maintenance personnel monitor the service of each environment, determine the difference service under different environments, manually write codes to create objects under different environments, and select and inject the objects according to the environments through a spring framework under the condition that the objects are missing, for example, an A project needs to be deployed in A, B, C three different environments, the services loaded under each environment are different, for example, the A project loads the distributed full-text retrieval service, the database access service and the authority management service under the A environment; the project loads the distributed full-text retrieval service in the environment A without loading a database access service and an authority management service; in the current method for service configuration based on the environment, the difference services in each environment need to be checked, and the code intrusion by adopting an object injection mode is high, and the code maintenance is difficult in different environments.
Based on the above hardware structure and the deficiencies of the prior art, the first embodiment of the service configuration method of the present invention comprises:
when detecting that a container is started, acquiring an environment attribute file associated with the container;
traversing the environment attribute file, and acquiring an environment switch configured in the environment attribute file and the state of the environment switch;
and loading the configuration class associated with the environment switch according to the state of the environment switch, and providing configured services through a target object in the configuration class.
The service configuration method in this embodiment is applied to service configuration equipment in financial institutions (banking institutions, insurance institutions, security institutions, and the like) in the financial industry, the service configuration equipment is a hardware carrier of a computer program corresponding to service configuration, and an information sending function is set in the service configuration equipment in this embodiment.
Referring to fig. 2, fig. 2 is a schematic flow chart of service configuration in a first embodiment of the service configuration method of the present invention, and before the steps of the first embodiment of the service configuration method of the present invention are executed, the method for pre-configuring the environment attribute file in the service configuration device specifically includes:
step S01, when receiving the environment creation request, outputting an environment creation page;
in this embodiment, a service configuration device receives an environment creation request, where the environment creation request may be understood as an environment addition request, for example, an a project may be currently deployed in an environment a and an environment B, and an environment C is currently added, so that the a project may be deployed in the environment C, and a development operation and maintenance worker triggers the environment creation request at the service configuration device, where a triggering manner of the environment creation request in this embodiment is not specifically limited, that is, the environment creation request may be actively triggered by a user, for example, the user inputs an environment identifier C on an environment creation page, and clicks a virtual key of "environment configuration" to trigger the environment creation request; the environment creation request may also be triggered automatically by the service configuration device, for example, the service configuration device is preset in the service configuration device, and the environment creation request is triggered automatically when a change in environment is detected, so that the service configuration device triggers the environment creation request automatically when the environment of the item a changes.
When the service configuration equipment receives the environment creation request, the service configuration equipment acquires the environment identifier associated with the environment creation request and outputs an environment creation page, so that a user can input difference information of different environments in the environment creation page.
The difference types corresponding to the difference information are three types, namely resource difference, service difference and process difference; resource differences may be understood as differences in the various context-dependent DB instances; the service difference can be understood as that the functions provided by projects in different environments are different, for example, the service functions such as distributed full-text retrieval and the like are provided in the xxx financial project environment a, and the service functions such as distributed full-text retrieval and the like are not required to be provided in the environment B; flow differences are understood to mean that under different circumstances, the variable processing logic processes, for example, the flow performs steps 1, 2 to 3 in circumstance a, and under circumstance B: the steps performed are 1 to 3.
In the prior art, resource difference configuration under different environments is realized by a Spring configuration file activation (Profile Active) or script replacement mode, the resource difference configuration in the prior art is similar to the resource difference configuration in the embodiment of the present invention, and details are not repeated in the embodiment; in the prior art, service difference needs to be developed, operation and maintenance personnel detect service difference of different environments, then required service modes are injected in corresponding environments through spring condition injection to realize service difference configuration, the service difference configuration in the prior art needs to be developed, the operation and maintenance personnel to carry out monitoring operation, environment difference codes are compiled according to detection results, intrusion operation is realized, the workload of the development, operation and maintenance personnel is large, and code maintenance is not facilitated; in the prior art, flow differences are handled separately by writing if branches on the service code. In the prior art, service difference and flow difference configuration under different environments all involve code change, so that operation and maintenance personnel need to compile different codes according to different environments, code intrusiveness is achieved, and code maintenance is inconvenient. Based on the service configuration method provided by the invention, the service configuration method in the embodiment of the invention is realized based on the preset environment attribute file, and specifically comprises the following steps:
and step S02, acquiring the difference flow information input based on the environment creation page, and packaging the difference flow information to form a target object.
Compared with a differentiation processing method for judging the current environment through an if branch in the prior art, the prior art needs to perform an if judgment on environment differences scattered at all positions of a project code once, and the newly added or deleted environment is changed a lot.
Step S03, combining the target objects to form a configuration class, creating an environment switch at the front end of the configuration class, and storing the environment switch and the configuration class in a preset environment attribute file in a related manner;
the service configuration equipment combines the target objects to form a configuration class, creates an environment switch (the environment switch can be understood as an entry called by the configuration class) at the front end of the configuration class, and stores the environment switch and the configuration class into a preset environment attribute file in an associated manner; and completing environment creation, namely updating the environment attribute file by the development operation and maintenance personnel every time one environment is newly added.
And step S04, outputting the environment attribute file when receiving the service configuration request, so as to prompt the development, operation and maintenance personnel to configure the state of the environment switch in the environment attribute file.
When the service configuration equipment receives the service configuration request, outputting an environment attribute file to prompt development, operation and maintenance personnel to configure the state of an environment switch in the environment attribute file, namely, if the state of the environment switch configured in the environment attribute file by a user is on, indicating that a configuration class associated with the environment switch needs to be loaded so as to provide configured services through objects in the configuration class; if the user configures the environment switch in the environment attribute file to be closed, it indicates that the configuration class associated with the environment switch needs not to be loaded.
And step S05, saving the configured state of the environment switch, and completing service configuration.
The service configuration equipment stores the state of the configured environment switch, so as to complete service configuration according to the state of the environment switch. In this embodiment, the environment attribute file is preset, the development operation and maintenance personnel encapsulate the environment difference information in the environment attribute configuration file and provide a corresponding environment switch, and when the service configuration device receives the service configuration request, the development operation and maintenance personnel complete the service configuration by configuring the state of the environment switch, so that the operation of the service configuration is more convenient.
In the prior art, the complexity will be increased when there are multiple environment-differentiated services. The development, operation and maintenance personnel can possibly cause environmental problems such as resource matching disorder, flow branch difference, service object dependence loss and the like due to switching in different environments, and the actual development and maintenance occupy larger time and labor cost.
Referring to fig. 3, fig. 3 is a flowchart illustrating a service configuration method according to a first embodiment of the present invention, where the service configuration method includes:
step S10, when detecting the container start, acquiring an environment attribute file associated with the container.
The service configuration equipment is internally provided with a monitor, the monitor is used for detecting the state of the container, and when the container is detected to be started, the service configuration equipment acquires an environment attribute file associated with the container so as to load and configure service according to the environment attribute file.
The embodiment of the invention is based on a Spring framework and based on IoC container managed proxy objects, programming configuration and condition injection characteristics. With the starting of the Spring Ioc container, automatically scanning the environment attribute file, and loading an object according to the configured state of the environment switch, specifically:
step S20, traversing the environment attribute file, and acquiring the environment switch configured in the environment attribute file and the state of the environment switch.
The service configuration device traverses the environment attribute file, and the service configuration device obtains the environment switch configured in the environment attribute file and the state of the environment switch, that is, when the service configuration device receives the service configuration request in this embodiment, the service configuration device outputs the environment attribute file, and the development operation and maintenance personnel can set the switch state in the environment switch of the environment attribute file to complete the configuration of the corresponding configuration class of the environment switch, and then the service configuration device traverses the environment attribute file, and the service configuration device obtains the environment switch configured in the environment attribute file and the state of the environment switch.
Step S30, loading the configuration class associated with the environmental switch according to the state of the environmental switch, and providing configured service through the target object in the configuration class.
The service configuration equipment loads the configuration class associated with the environment switch according to the state of the environment switch so as to provide configured services through a target object in the configuration class; specifically, the method comprises the following steps:
step b1, acquiring the state of the environment switch;
b2, when the environment switch is in the closed state, determining the configuration class corresponding to the environment switch, simulating the difference object in the configuration class to generate the proxy object, and handing the proxy object to a container for hosting;
step b3, loading the configuration class associated with the environment switch when the environment switch is in the on state, and providing the configured service through the target object in the configuration class.
Namely, the service configuration equipment acquires the state of the environment switch; when the environment switch is in a closed state, the service configuration equipment determines a configuration class corresponding to the environment switch, simulates a difference object in the configuration class to generate a proxy object, and delivers the proxy object to a container for hosting; when the proxy object is called, the service configuration equipment outputs prompt information; and when the environment switch is in the on state, the service configuration equipment loads the configuration class associated with the environment switch so as to provide the configured service through the target object in the configuration class.
In the embodiment of the invention, when the container is detected to be started, the environment attribute file associated with the container is obtained; traversing the environment attribute file, and acquiring an environment switch configured in the environment attribute file and the state of the environment switch; and loading the configuration class associated with the environment switch according to the state of the environment switch, and providing configured services through a target object in the configuration class. In the embodiment of the invention, an environment attribute file is configured in advance, configuration classes of different environments are configured in the environment attribute file, an environment switch is arranged on the configuration classes, and the state of the environment switch configured in the environment attribute file by operation and maintenance personnel is developed; according to the state of the configured environment switch, the configuration classes of different environments can be loaded, configured services are provided through objects in the configuration classes, and service configuration operation under different environments is achieved, so that development, operation and maintenance personnel are not required to detect differential service definition differential codes under different environments, codes are not required to be changed by a user in an invasive manner, code maintenance is convenient for service configuration operation, and workload of the development, operation and maintenance personnel is reduced.
Referring to fig. 4, fig. 4 is a schematic view of a specific scenario of service configuration in a first embodiment of a service configuration method according to the present invention, where the specific embodiment of the service configuration method according to the present invention includes:
1. creating environment attribute files (properties), wherein the name of the environment attribute files is mulEnv.
2. Environment a switch variable envA true of one boolean value is defined in the mulenv.
3. Declaring a configuration class environment configuration, wherein an annotation MulEnvConfiguration mark is defined in the configuration class environment configuration, a property FileName in the annotation specifies a read property file name, and a switchPropertyField attribute is filled in as an environment switch variable envA, namely the configuration class environment configuration is loaded only when the mulEnv.
4. Declare injectProxyObjClassesWhenClose attribute in the MulEnvConfiguration annotation, if the switch is set to be closed, the environment generates a proxy object of a specified class, and a dependent party acquires the proxy object from a spring IoC container to avoid the start of the dependent party to report errors;
5. the notification mode for the user when the notifiationofmisbetantype in the annotation is configured as the proxy object supports the notification modes of abnormal error reporting, log printing and self-definition at present. The self-defined notification mode is realized by self-defining notification and returning through an interface method of the interface CustomActionWhenMissBean defined by the invention, and the notification and the return are put into a Spring IoC container;
it can be understood that, in this embodiment, information in mulenv.
The embodiment of the invention is based on a Spring framework and based on IoC container managed proxy objects, programming configuration and condition injection characteristics. With the activation of the Spring Ioc container, the components under the basic package are automatically scanned, and when the class identified by the MulConfiguration annotation is detected, the following two steps are performed. Firstly, it will be determined that the class identified by the MulConfiguration is a configuration class, and secondly, whether the configuration class is loaded or not is determined by the conditional injection logic implemented by the present invention, and the core flow of loading is as shown in fig. 4. And searching the variable name of the specified environment switch by reading the environment attribute file, acquiring the value of the switch variable, and loading the Bean object set defined in the configuration class if the switch is started.
If the switch in the properties file is in the off state, all defined beans on the configuration class are not injected into the Spring Ioc container at this time, which may cause the dependent party to throw the nosuch beans definition exception at the time of loading. When the switch is turned off, the embodiment of the present invention dynamically generates a proxy object for a class set specified by an injproxyobjclassesswenclose attribute in MulConfiguration through a bytecode generation framework, and injects the proxy object into an Ioc container of Spring to replace an object originally required by a dependent party. The dynamically generated object can inform the user that the call under the environment is an abnormal dependent object at the moment through some behaviors, the notifiationOfMissBeanType attribute defines the behavior of the proxy object, such as abnormal throwing, log printing and the like, if the notification mode of the user is not satisfied, a CustomActionWhenMissBean interface can be realized and the proxy object is injected into a Spring Ioc container, the invention can realize the CustomActionWhenMissBean interface by scanning all CustomActionWhenMissBean objects in the Spring Ioc container and inform the generated proxy objects one by one and then the generated proxy objects are managed to the Spring IoC container, and the dependent party does not need to modify codes and does not induct and introduce the proxy object.
Further, based on the first embodiment of the service configuration method of the present invention, a second embodiment of the service configuration method of the present invention is proposed.
In this embodiment, when the environment switch is in an on state, the configuration class associated with the environment switch is loaded, and the step refinement of providing configured services through the target object in the configuration class is performed, where the difference between this embodiment and the above embodiments is:
when the environment switch is in a closed state, determining a configuration class corresponding to the environment switch;
acquiring a difference object in the configuration class, and judging whether the difference object is associated with a missing prompt or not;
if the difference object is not associated with the missing prompt, prompting configuration;
if the difference object is associated with the missing prompt, simulating the difference object in the configuration class to generate a proxy object, and submitting the proxy object to a container for hosting.
When the environment switch is in a closed state, the service configuration equipment determines a configuration class corresponding to the environment switch; acquiring a difference object in the configuration class, and judging whether the difference object is associated with a missing prompt or not; if the difference object is not associated with the missing prompt, prompting configuration; if the difference object is associated with the missing prompt, simulating the difference object in the configuration class to generate a proxy object, and submitting the proxy object to a container for hosting.
In this embodiment, the service configuration device determines, according to the configuration state of the environment switch in the environment attribute file, that no difference object is configured in the environment and a service corresponding to the difference object cannot be provided, and the service configuration device acquires the difference object in the configuration class and determines whether the difference object is associated with a loss prompt; if the difference object is not associated with the missing prompt, the service configuration equipment prompts configuration, so that development, operation and maintenance personnel can flexibly prompt equipment missing; if the difference object is associated with the missing prompt, the service configuration equipment simulates the difference object in the configuration class to generate a proxy object, the proxy object is delivered to a container for hosting, and if the user calls the difference object, the service configuration equipment outputs the missing prompt, so that the waiting of the user is reduced, and meanwhile, the development, operation and maintenance personnel can conveniently perform service configuration adjustment in time.
Further, based on the first embodiment of the service configuration method of the present invention, a third embodiment of the service configuration method of the present invention is proposed.
This embodiment is a refinement of step S30 in the first embodiment, and is different from the above embodiments in that it includes:
loading the configuration class associated with the environment switch according to the state of the environment switch, and judging whether the service provided by the target object in the configuration class conflicts;
if the service provided by the target object has conflict, a conflict prompt is output;
and if the service provided by the target object does not have conflict, providing the configured service through the target object in the configuration class.
After the service configuration equipment loads the configuration class associated with the environment switch according to the state of the environment switch, the service configuration equipment detects and judges whether the service provided by the target object in the configuration class conflicts or not in real time; if the service provided by the target object has conflict, the service configuration equipment outputs a conflict prompt to prompt development, operation and maintenance personnel to reconfigure; and if the service provided by the target object does not have conflict, outputting a configuration completion prompt, and providing the configured service through the target object in the configuration class.
In this embodiment, the service configuration device, according to the Spring framework principle, determines whether a conflict exists in the service configured by the development operation and maintenance personnel after the configuration class associated with the environment switch is loaded, so as to implement detection of service configuration, and when the conflict does not exist in the service configuration, the configured service is provided through a target object in the configuration class, and the service configuration device can perform configuration detection in real time, so as to ensure the correctness of the configuration of the development operation and maintenance personnel and reduce service failures caused by configuration errors.
Further, based on the foregoing embodiment of the service configuration method of the present invention, a fourth embodiment of the service configuration method of the present invention is provided.
The steps in the present embodiment are the steps after step S30 in the first embodiment, and the present embodiment is different from the above-described embodiments in that:
when a service call request is received, acquiring a container associated with the call request and a configuration class loaded in the container; acquiring a calling object in the configuration class, and judging whether the calling object is a proxy object;
and when the calling object is the proxy object, prompting an environment abnormal log to enable development, operation and maintenance personnel to adjust service configuration according to the environment abnormal log.
After the service configuration device completes service configuration, a user can call a service, the service configuration device reversely monitors whether the service configuration has errors according to service call conditions, specifically, when the service configuration device receives a service call request, the service configuration device obtains a call object associated with the call request, the service configuration device judges whether the call object is a proxy object, and when the call object is not the proxy object, the service configuration device provides a response service according to the call object.
When the calling object is the proxy object, the calling is judged to be abnormal, the service configuration is wrong, the service configuration equipment configures the started environmental switch to be closed, and at the moment, the service configuration equipment outputs a prompt environmental abnormal log so that development, operation and maintenance personnel can adjust the service configuration according to the environmental abnormal log.
In this embodiment, the service configuration device detects a service invocation request of a user in real time, and reversely adjusts the service configuration according to the service invocation condition, so that when the service configuration is wrong, the service configuration can be quickly adjusted.
Further, based on the foregoing embodiment of the service configuration method of the present invention, a fifth embodiment of the service configuration method of the present invention is provided.
The steps in the present embodiment are the steps after step S30 in the first embodiment, and the present embodiment is different from the above-described embodiments in that:
when a service query request is received, acquiring an environment attribute file associated with the service query request;
acquiring an environment switch marked in the environment attribute file and a configuration class corresponding to the environment switch;
and acquiring an object identifier of a target object in the configuration class, inputting the object identifier into a preset data table and outputting the object identifier so that a user can check the object identifier in the preset data table to determine the configured service.
When the service configuration equipment receives the service query request, the service configuration equipment acquires an environment attribute file associated with the service query request; acquiring an environment switch marked in an environment attribute file and a configuration class corresponding to the environment switch; the service configuration equipment acquires an object identifier of a target object in the configuration class, inputs the object identifier into a preset data table (the preset data table refers to a preset data table for storing the object identifier) and outputs the object identifier, so that a user can check the object identifier in the preset data table to determine the configured service.
In the embodiment, the service configuration equipment outputs the preset data table, so that operation and maintenance personnel can conveniently detect the service configuration, and the condition of service configuration errors is prevented.
Referring to fig. 5, fig. 5 is a schematic diagram of functional modules of an embodiment of a service configuration apparatus according to the present invention, and the present invention further provides an embodiment of a service configuration apparatus, where the service configuration apparatus includes:
a request receiving module 10, configured to, when it is detected that a container is started, obtain an environment attribute file associated with the container;
a traversal output module 20, configured to traverse the environment attribute file, and obtain an environment switch configured in the environment attribute file and a state of the environment switch;
the acquiring and loading module 30 is configured to load the configuration class associated with the environmental switch according to the state of the environmental switch, and provide the configured service through the target object in the configuration class.
In an embodiment, the service configuration apparatus includes:
the detection acquisition module is used for outputting an environment creation page when receiving an environment creation request;
the information acquisition module is used for acquiring the difference flow information input based on the environment creation page, and packaging the difference flow information to form a target object;
the association storage module is used for combining the target objects to form a configuration class, creating an environment switch at the front end of the configuration class, and associating and storing the environment switch and the configuration class to a preset environment attribute file;
the configuration prompting module is used for outputting the environment attribute file when receiving a service configuration request so as to prompt development, operation and maintenance personnel to configure the state of an environment switch in the environment attribute file;
and the configuration completion module is used for storing the configured state of the environment switch to complete service configuration.
In one embodiment, the get load module 30 includes:
the state acquisition unit is used for acquiring the state of the environment switch;
the object hosting unit is used for determining a configuration class corresponding to the environment switch when the environment switch is in a closed state, simulating a differential object in the configuration class to generate a proxy object, and handing the proxy object to a container for hosting;
and the configuration loading unit is used for loading the configuration class associated with the environment switch when the environment switch is in the opening state, and providing configured services through the target object in the configuration class.
In an embodiment, the object hosting unit is further configured to:
when the environment switch is in a closed state, determining a configuration class corresponding to the environment switch;
acquiring a difference object in the configuration class, and judging whether the difference object is associated with a missing prompt or not;
if the difference object is not associated with the missing prompt, prompting configuration;
if the difference object is associated with the missing prompt, simulating the difference object in the configuration class to generate a proxy object, and submitting the proxy object to a container for hosting.
In an embodiment, the service configuration apparatus includes:
the request query module is used for acquiring an environment attribute file associated with a service query request when the service query request is received;
the information acquisition module is used for acquiring the environment switch marked in the environment attribute file and the configuration class corresponding to the environment switch;
and the information output module is used for acquiring the object identifier of the target object in the configuration class, inputting the object identifier into a preset data table and outputting the object identifier so that a user can check the object identifier in the preset data table to determine the configured service.
In an embodiment, the acquire load module includes:
the conflict judging unit is used for loading the configuration class associated with the environmental switch according to the state of the environmental switch and judging whether the service provided by the target object in the configuration class conflicts or not;
the conflict prompting unit is used for outputting a conflict prompt if the service provided by the target object has a conflict;
and the service providing unit is used for providing the configured service through the target object in the configuration class if the service provided by the target object does not have conflict.
In an embodiment, the service configuration apparatus includes:
the system comprises an acquisition calling module, a configuration module and a processing module, wherein the acquisition calling module is used for acquiring a container associated with a calling request and a configuration class loaded in the container when the service calling request is received;
the obtaining and judging module is used for obtaining the calling object in the configuration class and judging whether the calling object is a proxy object;
and the abnormity prompting module is used for prompting an environment abnormity log when the calling object is the proxy object so as to enable development, operation and maintenance personnel to adjust service configuration according to the environment abnormity log.
In the embodiment of the invention, when the container is detected to be started, the environment attribute file associated with the container is obtained; traversing the environment attribute file, and acquiring an environment switch configured in the environment attribute file and the state of the environment switch; and loading the configuration class associated with the environment switch according to the state of the environment switch, and providing configured services through a target object in the configuration class. In the embodiment of the invention, an environment attribute file is configured in advance, configuration classes of different environments are configured in the environment attribute file, an environment switch is arranged on the configuration classes, and the state of the environment switch configured in the environment attribute file by operation and maintenance personnel is developed; according to the state of the configured environment switch, the configuration classes of different environments can be loaded, configured services are provided through objects in the configuration classes, and service configuration operation under different environments is achieved, so that development, operation and maintenance personnel are not required to detect differential service definition differential codes under different environments, codes are not required to be changed by a user in an invasive manner, code maintenance is convenient for service configuration operation, and workload of the development, operation and maintenance personnel is reduced.
The method executed by each program module can refer to each embodiment of the service configuration method of the present invention, and is not described herein again.
The invention also provides a computer readable storage medium.
The computer readable storage medium of the present invention has stored thereon a service configuration program, which when executed by a processor implements the steps of the service configuration method as described above.
The method implemented when the service configuration program running on the processor is executed may refer to each embodiment of the service configuration method of the present invention, and details are not described here.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A service configuration method, characterized in that the service configuration method comprises the steps of:
when detecting that a container is started, acquiring an environment attribute file associated with the container;
traversing the environment attribute file, and acquiring an environment switch configured in the environment attribute file and the state of the environment switch;
and loading the configuration class associated with the environment switch according to the state of the environment switch, and providing configured services through a target object in the configuration class.
2. The service configuration method of claim 1, wherein before the step of traversing the environment property file, obtaining the environment switches configured in the environment property file, and the states the environment switches are in, the method comprises:
outputting an environment creation page when receiving an environment creation request;
acquiring difference process information input based on the environment creation page, and packaging the difference process information to form a target object;
combining the target objects to form a configuration class, creating an environment switch at the front end of the configuration class, and storing the environment switch and the configuration class in a preset environment attribute file in a related manner;
when a service configuration request is received, outputting the environment attribute file to prompt development, operation and maintenance personnel to configure the state of an environment switch in the environment attribute file;
and saving the configured state of the environment switch to complete service configuration.
3. The service configuration method of claim 1, wherein the step of loading the configuration class associated with the environmental switch according to the state of the environmental switch and providing the configured service through the target object in the configuration class comprises:
acquiring the state of the environment switch;
when the environment switch is in a closed state, determining a configuration class corresponding to the environment switch, simulating a difference object in the configuration class to generate a proxy object, and handing the proxy object to a container for hosting;
and when the environment switch is in an opening state, loading the configuration class associated with the environment switch, and providing configured services through a target object in the configuration class.
4. The service configuration method according to claim 3, wherein the step of determining the configuration class corresponding to the environment switch, simulating a difference object in the configuration class to generate a proxy object, and delivering the proxy object to a container for hosting includes:
when the environment switch is in a closed state, determining a configuration class corresponding to the environment switch;
acquiring a difference object in the configuration class, and judging whether the difference object is associated with a missing prompt or not;
if the difference object is not associated with the missing prompt, prompting configuration;
if the difference object is associated with the missing prompt, simulating the difference object in the configuration class to generate a proxy object, and submitting the proxy object to a container for hosting.
5. The service configuration method of claim 1, wherein after the step of loading the configuration class associated with the context switch according to the state of the context switch and providing the configured service through the target object in the configuration class, the method comprises:
when a service query request is received, acquiring an environment attribute file associated with the service query request;
acquiring an environment switch marked in the environment attribute file and a configuration class corresponding to the environment switch;
and acquiring an object identifier of a target object in the configuration class, inputting the object identifier into a preset data table and outputting the object identifier so that a user can check the object identifier in the preset data table to determine the configured service.
6. The service configuration method of claim 1, wherein the step of loading the configuration class associated with the environmental switch according to the state of the environmental switch and providing the configured service through the target object in the configuration class comprises:
loading the configuration class associated with the environment switch according to the state of the environment switch, and judging whether the service provided by the target object in the configuration class conflicts;
if the service provided by the target object has conflict, a conflict prompt is output;
and if the service provided by the target object does not have conflict, providing the configured service through the target object in the configuration class.
7. The service configuration method according to any one of claims 1 to 6, wherein after the step of loading the configuration class associated with the context switch according to the state of the context switch and providing the configured service through the target object in the configuration class, the method comprises:
when a service call request is received, acquiring a container associated with the call request and a configuration class loaded in the container;
acquiring a calling object in the configuration class, and judging whether the calling object is a proxy object;
and when the calling object is the proxy object, prompting an environment abnormal log to enable development, operation and maintenance personnel to adjust service configuration according to the environment abnormal log.
8. A service configuration apparatus, characterized in that the service configuration apparatus comprises:
the request receiving module is used for acquiring an environment attribute file associated with the container when the container is detected to be started;
the traversal output module is used for traversing the environment attribute file, and acquiring the environment switch configured in the environment attribute file and the state of the environment switch;
and the acquisition loading module is used for loading the configuration class associated with the environmental switch according to the state of the environmental switch and providing configured services through the target object in the configuration class.
9. A service configuration device, characterized in that the service configuration device comprises: memory, a processor and a service configuration program stored on the memory and executable on the processor, the service configuration program, when executed by the processor, implementing the steps of the service configuration method according to any one of claims 1 to 7.
10. A computer-readable storage medium, having stored thereon a service configuration program which, when executed by a processor, implements the steps of the service configuration method according to any one of claims 1 to 7.
CN202010597475.9A 2020-06-28 2020-06-28 Service configuration method, device, equipment and computer readable storage medium Pending CN111736921A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010597475.9A CN111736921A (en) 2020-06-28 2020-06-28 Service configuration method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010597475.9A CN111736921A (en) 2020-06-28 2020-06-28 Service configuration method, device, equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN111736921A true CN111736921A (en) 2020-10-02

Family

ID=72651389

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010597475.9A Pending CN111736921A (en) 2020-06-28 2020-06-28 Service configuration method, device, equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111736921A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112269738A (en) * 2020-10-26 2021-01-26 杭州光通天下网络科技有限公司 CTF target range debugging method, device, electronic equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112269738A (en) * 2020-10-26 2021-01-26 杭州光通天下网络科技有限公司 CTF target range debugging method, device, electronic equipment and medium
CN112269738B (en) * 2020-10-26 2023-04-07 杭州光通天下网络科技有限公司 CTF target range debugging method, device, electronic equipment and medium

Similar Documents

Publication Publication Date Title
US11726828B2 (en) Managing a virtualized application workspace on a managed computing device
CN109558320B (en) System testing method, device, system, equipment and computer readable storage medium
CN105307195B (en) A kind of method and device updating access point name parameter
US20050251719A1 (en) Test case inheritance controlled via attributes
CN111090592A (en) Automatic testing method of buried point, terminal and readable storage medium
CN111522849A (en) Database dynamic access method, server and storage medium
CN111737334A (en) Data reporting method, device, equipment and storage medium
US10459698B2 (en) Framework for generating adapters in an integrated development environment
CN113672353A (en) Container-based task execution method and device
CN110531984B (en) Code compiling method, device, system, computer equipment and storage medium
CN105447383A (en) Browser operating environment detection method, client, server and browser operating environment detection system
CN111736921A (en) Service configuration method, device, equipment and computer readable storage medium
CN112035163B (en) Software development kit configuration method, device and storage medium
CN110727477B (en) Component loading method and device, computer equipment and storage medium
CN110362309B (en) Front-end project development method, device, equipment and computer readable storage medium
CN111563260B (en) Android application program-oriented Web injection code execution vulnerability detection method and system
CN114697232A (en) Skywalking probe index data acquisition system and method and electronic equipment
CN115129348A (en) Resource updating method, device and equipment of application program and readable storage medium
CN106855804B (en) Code change management and control method and device
CN111475783B (en) Data detection method, system and equipment
CN111797016A (en) Application program testing method, device, storage medium and device
CN111427941A (en) Bonded storage management method
CN111078571A (en) Test method for simulation response, terminal device and computer readable storage medium
CN105160240A (en) Terminal password protection method and apparatus
CN117056030B (en) Method and device for determining escape of container

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