Application running method, system and equipment and storage medium
Through unified middleware implementation interface and multi-runtime adaptation framework MRF, the problem of the differences in middleware APIs of service applications in different operating environments is solved, and the common middleware adaptation and multi-run environment deployment of JAVA applications are realized, which simplifies adaptation and adaptation Process of matching.
Patent Information
- Application Number
- CN202310755119.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2024-12-27
AI Technical Summary
Existing service applications are difficult to implement multiple operation deployment in different operating environments. This is mainly due to differences in middleware APIs that require self-built or other adaptation frameworks. These adaptation frameworks are usually too customized and cannot be applied to general middleware adaptations. It matches the scene and is not friendly to JAVA development.
By obtaining the middleware implementation interface unified for different operating environments, identifying the current running environment, obtaining middleware implementation classes and instances, introducing middleware dependency packages based on preset plug-ins, and instantiating middleware implementation classes through encapsulation classes to achieve pre-order Set the middleware adaptation of service applications, block middleware differences, and realize the deployment of a set of code multiple running environments.
It realizes the general middleware adaptation of service applications in different operating environments, isolates the impact of the application running system, achieves the purpose of deploying a set of codes and multiple running environments, simplifies the middleware adaptation process, and is suitable for multi-running time of JAVA applications. environment.
Smart Images

Figure CN119201221A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to an application running method, a corresponding application running system, a corresponding electronic device, and a corresponding computer-readable storage medium. Background Art
[0002] With the development of Internet services, service applications usually need to be deployed in a variety of different operating environments, that is, they have multi-operation requirements. The multi-operation requirements of service applications refer to the requirements for deployment in different operating environments.
[0003] However, since the middleware used by most service applications in a certain operating environment has different APIs (Application Programming Interface) from the middleware used when running in other operating environments, that is, the service application itself does not have the ability to be deployed in multiple runtimes and usually relies on middleware adaptation implementation. In related technologies, it is mainly manifested in choosing to build an adaptation framework by yourself or asking other teams to build an adaptation framework. The self-built or other-built adaptation framework is coupled with the middleware and cannot be applied to general middleware adaptation scenarios. Summary of the invention
[0004] In view of the above problems, embodiments of the present application are proposed to provide an application running method, a corresponding application running system, a corresponding electronic device and a corresponding computer-readable storage medium that overcome the above problems or at least partially solve the above problems.
[0005] The present application embodiment discloses an application running method, the method comprising:
[0006] Obtain a unified middleware implementation interface for different operating environments;
[0007] Identify the current operating environment, and obtain the middleware implementation class and the middleware implementation class instance through the middleware implementation interface; the middleware implementation class introduces the middleware dependency package corresponding to the current operating environment based on the preset plug-in, and the middleware implementation class instance is obtained based on instantiating the middleware encapsulation class;
[0008] According to the middleware implementation class and the middleware implementation class instance, the preset service application is run in the current running environment.
[0009] Optionally, obtaining the middleware implementation class through the middleware implementation interface includes:
[0010] Obtaining environment configuration information of the current operating environment;
[0011] Dynamically loading a middleware dependency package for the current operating environment based on the environment configuration information;
[0012] Through the middleware implementation interface, the middleware implementation class provided by the middleware dependency package is obtained based on the preset plug-in.
[0013] Optionally, obtaining a middleware implementation class instance through the middleware implementation interface includes:
[0014] Get middleware configuration information;
[0015] A middleware implementation class instance is created based on the middleware configuration information.
[0016] Optionally, the creating a middleware implementation class instance based on the middleware configuration information includes:
[0017] Obtain the original middleware configuration information of the preset service application in different operating environments;
[0018] The original middleware configuration information is uniformly processed according to a preset configuration format to obtain middleware configuration information; wherein the middleware configuration information processed in the preset configuration format includes middleware instances, middleware types and middleware attributes corresponding to each operating environment.
[0019] Optionally, the creating a middleware implementation class instance based on the middleware configuration information includes:
[0020] Get various types of encapsulation classes;
[0021] The encapsulation class is instantiated based on the middleware configuration information to obtain a middleware implementation class instance.
[0022] Optionally, the middleware implementation class is used to provide dependent middleware information and has middleware characteristics; and running the preset service application in the current running environment according to the middleware implementation class and the middleware implementation class instance includes:
[0023] Based on the middleware implementation class, middleware characteristics for the current operating environment are added to the middleware implementation class instance to obtain the middleware implementation class instance after the middleware characteristics are added; the middleware implementation class instance after the middleware characteristics are added conforms to the current operating environment;
[0024] The preset service application is run using the intermediate implementation class instance after the middleware characteristics are added.
[0025] The present application also discloses an application running method, the method comprising:
[0026] In response to a startup instruction of a preset service application, obtaining a software development kit of the preset service application;
[0027] The preset service application is run in the current operating environment based on the software development kit; wherein the software development kit is used to obtain a unified middleware implementation interface for different operating environments, and to obtain a middleware implementation class and a middleware implementation class instance for the current operating environment based on the middleware implementation interface, wherein the middleware implementation class introduces the middleware dependency package corresponding to the current operating environment based on the preset plug-in, and the middleware implementation class instance is obtained based on instantiating the middleware encapsulation class.
[0028] An embodiment of the present application also discloses an application running system, which is configured with a middleware adaptation framework, which includes a middleware adaptation layer, an adapter, middleware, and a computer program executed based on the application running system adaptation layer, and the computer program implements any one of the application running methods when executed by the application running system.
[0029] An embodiment of the present application also discloses an electronic device, which includes: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor, any one of the application running methods is implemented.
[0030] An embodiment of the present application further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, any one of the application running methods is implemented.
[0031] The embodiments of the present application include the following advantages:
[0032] In the embodiment of the present application, the middleware implementation class and the middleware implementation class instance for the current operating environment are obtained through the unified middleware implementation interface for different operating environments, so as to run the preset service application in the current operating environment based on the obtained middleware implementation class and the middleware implementation class instance, and complete the middleware adaptation of the preset service application in the current operating environment. Through the unified middleware implementation interface for different operating environments, the different middleware implementation classes introduced based on different operating environments and the middleware instantiated based on different runtime environment configurations are obtained, thereby realizing the operation of the preset service application in the current operating environment, shielding the middleware differences of the application in multiple runtime environments based on the unified middleware implementation interface, isolating the impact on the application running system, and realizing the general middleware adaptation of the service application in different operating environments, so as to achieve the purpose of implementing a set of code for the service application and deploying in multiple operating environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a flowchart of the steps of an embodiment of an application operation method of the present application;
[0034] Figure 2 Schematic diagram of a multi-runtime adaptation framework MRF provided in an embodiment of the present application;
[0035] Figure 3 It is a schematic diagram of an application scenario of the application running provided by the embodiment of the present application;
[0036] Figure 4 is a flowchart of another embodiment of an application operation method of the present application;
[0037] Figure 5 It is a structural block diagram of an embodiment of an application running device of the present application;
[0038] Figure 6 It is a structural block diagram of another application running device embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0040] To facilitate those skilled in the art to understand the present application, the following explains the terms or nouns involved in the following embodiments of the present application:
[0041] Java: is an object-oriented programming language.
[0042] Java application: refers to an application written in Java.
[0043] Multi-Runtime: Multi-Runtime, in the embodiment of this application, refers to Java applications running in different environments.
[0044] MRF: short for Multi-Runtime Framework, is a multi-runtime adaptation framework proposed in the embodiment of the present application, which is a middleware adaptation framework written in Java language, used to converge the API layer of the Java application middleware technology stack, shield the middleware differences of Java applications in multiple runtime environments, and thus isolate the impact on the application running system based on the isolation of changes in the underlying middleware dependencies.
[0045] Maven: Apache Maven, Maven Project Object Model (POM, Project Object Model), is a project management tool.
[0046] MavenPlugin: Maven project plugin.
[0047] DependencyProvider: Dependency provider refers to the ability to provide corresponding runtime middleware Maven dependencies according to applications configured to depend on MRF at different runtimes.
[0048] Fatjar technology: refers to the technology of packaging the published Java functions into an all-in-one zip package (file package, a file format for data compression and document storage) or jar package (Java Archive File, Java archive file, a document format of Java, a platform-independent file format that can combine multiple files into one file) in Java.
[0049] RPC: Remote Procedure Call, remote procedure call protocol, mainly makes it easier to build distributed computing (applications). The RPC framework usually includes three components: client, server and registration center.
[0050] Dubbo: A high-performance RPC distributed service framework based on Java.
[0051] Nacos: It is a dynamic service discovery, configuration management, and service management platform that makes it easy to build cloud-native applications.
[0052] Redis: RemoteDictionaryServer, remote dictionary service, is a key-value storage system.
[0053] MQ: MessageQueue, message queue, refers to a container for storing messages, which is essentially a queue.
[0054] Cache: Cache or cache memory.
[0055] CONFIG: It is the abbreviation of Configuration, which refers to the configuration file.
[0056] Golang: Go language is an open source programming language.
[0057] Sar package: It is an archive file created with sarextenstion, which is created in the same way as other archive files. It is different from packages in other formats and can be deployed independently without relying on other components.
[0058] SDK: Software Development Kit, software development kit, is a collection of relevant documents, examples and tools to assist in the development of a certain type of software.
[0059] SPI: ServiceProviderInterface, service provider interface or service discovery, is a mechanism for finding service implementations for a certain interface.
[0060] ServiceLoader: Provides a set of SPI frameworks to decouple service providers from service users.
[0061] API: ApplicationProgrammingInterface, application programming interface.
[0062] DB: DataBase, database, a warehouse for storing data.
[0063] Json format: JavaScript Object Notation, is a lightweight data interaction format.
[0064] MetaQProducer: refers to the consumer sending class, where MetaQ is a message middleware based on consumer subscription and publishing mode.
[0065] ONS: Delayed Message is a distributed message middleware based on RocketMQ.
[0066] RocketMQ: is a message queue middleware.
[0067] SpringBootStarter: In SpringBoot, each component appears in the form of a starter, which can discard the configuration in Spring and integrate it into the starter. By introducing the starter dependency in Maven, the user can automatically scan the information to be loaded and start the corresponding default configuration. Among them, SpringBoot is a large integration of the Spring technology stack. Starter is a service that developers who use a certain function do not need to pay attention to the processing of various dependent libraries and do not use specific configuration information.
[0068] PandoraContainer: Pandora container, where Pandora is a lightweight isolation container used to isolate the dependencies of applications and middleware, and also to isolate the dependencies between middleware.
[0069] Impl: refers to the resource package used to store java files.
[0070] With the development of Internet services, service applications usually need to be deployed in a variety of different operating environments, that is, they need to have multiple operations. The multiple operation requirements of service applications refer to the need to deploy in different operating environments, so that a service application can be deployed in multiple locations based on a set of code, so that it can be deployed in other operating environments in addition to a specific operating environment.
[0071] Since most service applications use middleware in a certain runtime environment, there are API differences between the middleware used in other runtime environments. That is, the service application itself does not have the ability to be deployed in multiple runtimes and usually relies on middleware adaptation to be implemented. In related technologies, this is mainly manifested in choosing to build an adaptation framework by yourself or seeking help from other teams to build an adaptation framework.
[0072] Among the relevant adaptation frameworks, there may be some adaptation frameworks developed by some service teams themselves.
[0073] As an example, there is an adaptation framework for the company's products that an adaptation service team is located in. This type of adaptation framework is usually based on the targeted research and development of the company's products. The underlying middleware implementation can be determined by configuration, and it can rely on its own unified middleware API implementation and its own middleware adaptation, so that it can fit seamlessly with the merged deployment solution, and unless the middleware used is consistent, it is allowed to detect inconsistencies in the middleware used by cloud applications and elastic applications in the operation and maintenance system. However, due to its targeted research and development characteristics, it is too customized. When performing middleware adaptation on an arbitrary service application, it usually requires a self-implemented adaptation layer, which requires a slightly large amount of modification, and the overly customized adaptation framework is usually not a common cloud-native solution for shielding the underlying middleware implementation.
[0074] As another example, there is also another adaptation framework for the company's products of the adaptation service team. This type of adaptation framework is usually based on the targeted research and development of its company's products. The underlying middleware implementation can be determined by configuration, and it can rely on its own unified middleware API implementation and rely on itself to implement middleware adaptation, so that it can fit seamlessly with the merged deployment plan, and unless the middleware used is consistent, it is allowed to detect the inconsistency of the middleware used by the cloud application and the bullet-in application of the operation and maintenance system. Although it has the advantages of realizing multi-cloud deployment, it can also be converted from the delivery deployment of the code layer to the delivery deployment (release) of Fatjar, and the source code of the adaptation framework is open, but due to its targeted research and development characteristics, it is too customized. When performing middleware adaptation on an arbitrary service application, it usually requires self-implementation of the adaptation layer, and the amount of modification is slightly large. In addition, the overly customized adaptation framework is usually not the current cloud-native general solution for shielding the underlying middleware implementation.
[0075] As another example, there is also a cloud-native unified adaptation framework - Dapr framework. This type of adaptation framework is highly versatile and can provide the use of open source products, but the Dapr team will not support the construction of this part of the code. It can also lightly implement the transformation of the four basic components (including RPC, MQ, Cache, CONFIG), and the underlying middleware implementation is determined by the configuration. It can use the Dapr solution based on the version upgrade of the simple Sar package; Dapr usually establishes a channel to the APP. For the scenario of merged deployment, it does not support the establishment of channels for multiple logical APPs, and because its middleware is implemented in golang, the detection and operation and maintenance system are quite different. Although it is in line with the cloud-native concept, and Dapr's solution depends on the specified Sar package version, it can be based on Dapr self-implementation to launch middleware, and it can be more convenient to bridge to open source middleware when the middleware on the public cloud cannot be used, but in the middleware adaptation scenario, the implementation of the launch middleware usually uses the go language. At present, Dapr has less construction of go-middle in the bullet, and the operation and maintenance system is relatively weak, and it may also lead to partial support for the advanced features of the middleware, and some advanced features are lost.
[0076] From the above, it can be seen that most of the self-built or other-built adaptation frameworks are coupled with the middleware and cannot be applied to the general middleware adaptation scenarios. The API of the general adaptation framework is not very friendly to JAVA development and cannot be applied to the general middleware adaptation scenarios of JAVA applications.
[0077] The embodiments of the present application are based on shielding the middleware differences of applications in multiple runtime environments and isolating the impact on the application running system, thereby realizing the common middleware adaptation of service applications in different running environments, thereby achieving the purpose of realizing multi-running deployment of service applications.
[0078] Reference Figure 1 , shows a flowchart of a method for running an application according to an embodiment of the present application, which may specifically include the following steps:
[0079] Step 101, obtaining a unified middleware implementation interface for different operating environments;
[0080] The multi-operation requirement of a service application refers to the requirement to deploy it in different operating environments, so as to realize multi-location deployment scenarios based on a set of code, so that a service application can be deployed in other operating environments besides a specific operating environment.
[0081] The operating environment usually refers to the operating platform of the service application, including but not limited to the elastic environment and the multi-cloud environment, wherein the elastic environment refers to the elastic computing environment deployed in the intranet production network, and the multi-cloud environment may include but not limited to hybrid cloud, public cloud, private cloud, external cloud, etc. Different operating environments may affect the different configuration information of the service application at runtime, which can be specifically manifested as different codes. Correspondingly, for the use of middleware in different operating environments, the middleware implementation of the corresponding environment is usually adopted. In the embodiment of the present application, the middleware implementation interface can be unified, that is, the middleware implementation interface of different operating environments can be set to the same middleware implementation interface, and the middleware corresponding to different operating environments can be uniformly adapted based on the unified middleware implementation interface, and the differences in middleware applications in multiple runtime environments can be shielded based on the unified middleware implementation interface. The unification mainly refers to the unification of standards.
[0082] Specifically, the unification of the middleware implementation interface can be manifested as not coupling with a specific middleware, abstractly defining the middleware defined by the interface, and defining the adaptability of the middleware. Specifically, it can be defined and implemented through the MRF framework to remove middleware dependencies, such as Maven dependencies within the bullet, and achieve the same use of middleware on the bullet cloud. It should be noted that the middleware handled by the middleware implementation interface is mainly considered from the perspective of user use and versatility, making it as convenient for users to use as possible and able to adapt to more implementations. For scenarios where there may be conflicts or incompatibilities between different middleware implementations, the abstract definition of the middleware can be adjusted based on the intersection of the interface definition and the interface definition that conforms to the user's usage habits. This is not limited in the embodiments of the present application.
[0083] In one embodiment of the present application, a unified middleware implementation interface for different operating environments can be obtained, and the current operating environment can be identified, so as to obtain the middleware that conforms to the current operating environment based on the unified middleware implementation interface, and realize the middleware adaptation of the preset service application to the current operating environment. In actual applications, the acquisition of the middleware implementation interface can be mainly provided based on the multi-runtime adaptation framework MRF provided in the embodiment of the present application.
[0084] Step 102, identifying the current operating environment, and obtaining the middleware implementation class and the middleware implementation class instance through the middleware implementation interface;
[0085] In an embodiment of the present application, a unified middleware implementation interface for different operating environments can be used to obtain different middleware implementation classes introduced based on different operating environments and middleware instantiated based on different runtime environment configurations. The intermediate dependency package can be introduced mainly based on the preset plug-in provided within the multi-runtime adaptation framework MRF, thereby achieving the acquisition of the middleware implementation class and then running the preset service application in the current operating environment.
[0086] Among them, the difference between the middleware implementation class and the middleware implementation class instance is that the middleware implementation class is the class before instantiation. Since the middleware implementation class can provide the middleware information it depends on based on the preset plug-in, it has the middleware characteristics; and the middleware implementation class instance is the class after instantiation, but it is not a direct instantiation of the class with middleware characteristics. The middleware implementation class instance is an SDK instance, which is mainly an instantiation of the encapsulation class and does not depend on the content of the middleware, that is, it does not have the middleware characteristics.
[0087] In one embodiment of the present application, the middleware implementation class can be used to introduce the middleware dependency package corresponding to the current operating environment, that is, the specific middleware implementation class and the middleware implementation class instance can be loaded through the intermediate instantiation configuration of the current environment.
[0088] Specifically, to obtain the middleware implementation class, the environment configuration information of the current running environment can be obtained, and then the middleware dependency package for the current running environment can be dynamically loaded based on the environment configuration information, and the middleware implementation class provided by the middleware dependency package can be obtained based on the preset plug-in through the middleware implementation interface. In actual applications, to introduce the middleware implementation class, after the project is quickly started, the corresponding parameters can be added through packaging, such as -DCLOUDPATH_MID_IMPL=ons, so as to realize the introduction of the middleware dependency package corresponding to the running environment, such as the ons package.
[0089] The middleware implementation class instance can be mainly obtained by instantiating the middleware encapsulation class to configure and instantiate the required middleware based on different runtime environments. Specifically, the middleware implementation class instance can be obtained by obtaining the middleware configuration information and creating it based on the middleware configuration information.
[0090] In actual applications, the obtained middleware configuration information is the middleware configuration information obtained after unified processing through the preset configuration format, so as to converge the differentiated configurations for different operating environments. The unified processing process is manifested as obtaining the original middleware configuration information of the preset service application in different operating environments, and then uniformly processing the original middleware configuration information according to the preset configuration format to obtain the middleware configuration information.
[0091] Exemplarily, the configuration format of the middleware configuration information before convergence may include but is not limited to Json, properties, etc. Assuming that the preset configuration format is Json format, then the format of the original middleware configuration information can be unified according to the Json format. The middleware configuration information processed in the Json format can be expressed in a unified format: ABC=D. Among them, part A can refer to the middleware instance corresponding to each operating environment, part B can refer to the middleware type corresponding to each operating environment, part C can refer to the middleware property, and part D can refer to
[0092] For example:
[0093] gloudpath.onsproducer.ons.AccessKey=xxxxxx
[0094] goudpath.onsproducer.ons.SecretKey=xxxxxx
[0095] goudpath.onsconsumer.ons.NAMESRV_ADDR=http: / / xxxxxx-mq-intermet-access.mq-internet
[0096] goudpath.onsconsumer.ons.GROUP_ID=GID_CLOUDPATH_CONSUMER
[0097] It should be noted that the middleware configuration of the corresponding environment can be configured through the above configuration specifications, and then the configuration can be parsed at the framework layer to load the corresponding middleware.
[0098] In the process of creating a middleware implementation class instance based on the middleware configuration information, you can obtain various types of encapsulation classes, usually through ServiceLoader, load the implementation class of each type of Factory to execute the creation logic, instantiate the encapsulation class based on the middleware configuration information, and obtain the middleware implementation class instance. Specifically, the middleware configuration information is parsed, and the corresponding configuration is set in the adaptation layer to create the corresponding middleware implementation class instance, that is, the SDK instance, that is, the encapsulation class written in the adaptation layer can be instantiated based on the configuration information.
[0099] Step 103: Run the preset service application in the current running environment according to the middleware implementation class and the middleware implementation class instance.
[0100] The middleware implementation class can be used to provide the middleware information it depends on, and it has middleware characteristics. The middleware implementation class instance does not depend on the content of the middleware, that is, it does not have middleware characteristics. At this time, the preset service application can be run in the current running environment based on the middleware implementation class with middleware characteristics and the middleware implementation class instance without middleware characteristics to complete the middleware adaptation of the preset service application in the current running environment.
[0101] In the specific implementation, the middleware features for the current operating environment can be added to the middleware implementation class instance based on the middleware implementation class to obtain the middleware implementation class instance with the added middleware features. The middleware implementation class instance with the added middleware features conforms to the current operating environment.
[0102] In actual applications, the intermediate implementation class instance after adding middleware features can be integrated into the user's application as an SDK. At this time, based on the loading of the intermediate implementation class instance after adding middleware features, the preset service application can be run in the current running environment to complete the middleware adaptation of the preset service application in the current running environment.
[0103] Specifically, it can be manifested as responding to the startup instruction of the preset service application, obtaining a software development kit, and then obtaining a unified middleware implementation interface for different operating environments based on the software development kit, and then obtaining the intermediate implementation class instance after adding the middleware characteristics, and based on loading the obtained intermediate implementation class instance after adding the middleware characteristics, the preset service application is run in the current operating environment. That is, the preset service application uses a unified middleware interface, based on the loaded middleware implementation class and the middleware implementation class instance, so as to shield the middleware differences of the application in multiple operating environments, isolate the impact of the middleware differences on the application operating system, and achieve the purpose of deploying a set of code in multiple operating environments.
[0104] In the embodiment of the present application, the middleware implementation class and the middleware implementation class instance for the current operating environment are obtained through the unified middleware implementation interface for different operating environments, so as to run the preset service application in the current operating environment based on the obtained middleware implementation class and the middleware implementation class instance, and complete the middleware adaptation of the preset service application in the current operating environment. Through the unified middleware implementation interface for different operating environments, the different middleware implementation classes introduced based on different operating environments and the middleware instantiated based on different runtime environment configurations are obtained, thereby realizing the operation of the preset service application in the current operating environment, shielding the middleware differences of the application in multiple runtime environments based on the unified middleware implementation interface, isolating the impact on the application running system, and realizing the general middleware adaptation of the service application in different operating environments, so as to achieve the purpose of implementing a set of code for the service application and deploying in multiple operating environments.
[0105] In one embodiment of the present application, the embodiment of the present application proposes a multi-runtime adaptation framework MRF, converges the API layer of the Java application middleware technology stack, shields the middleware differences of Java applications in multiple runtime environments, and thereby isolates the impact on the application running system based on the isolation of changes in underlying middleware dependencies, thereby realizing a universal middleware adaptation framework for JAVA applications, which is suitable for general service application multi-running adaptation scenarios, and can be deployed in multiple locations based on a set of JAVA application codes, thereby achieving the purpose of being able to deploy a service application in other operating environments in addition to a specific operating environment.
[0106] Reference Figure 2 , showing a framework diagram of the multi-runtime adaptation framework MRF provided in an embodiment of the present application. The MRF framework may include a user layer (i.e., AutoConfig layer), a proxy layer (i.e., Proxy layer), a strategy layer (i.e., Builder layer), a factory layer (i.e., Factory layer), an adaptation layer (i.e., ClientImpl layer), and a dependency provider (i.e., DependencyProvider), etc.
[0107] Specifically, the user layer, that is, the AutoConfig layer, can be mainly based on the configuration of the SpringBootStarter specification provided by MRF, such as the preset configuration format "ABC=D" shown above. When the service application starts, the instance can be automatically loaded into the Spring container. For example, MQSpringBootStarter, RPCSpringBootStarter, CacheSpringBootStarter, etc. are loaded in the container based on the corresponding AutoConfig. Subsequent configuration convergence and middleware instances can be loaded in the Spring container.
[0108] The proxy layer refers to the user-oriented usage entrance, which is mainly responsible for the middleware log output, etc. For different service functions, there may be corresponding proxies, such as MQProxy, RPCProxy, Cache Proxy, etc.
[0109] The strategy layer, i.e., the Builder layer, is mainly responsible for converging configuration information and loading the factory SPI. The process of converging configuration information can be specifically manifested as processing the middleware configuration information according to a unified preset configuration format. Specifically, for different service functions, there are corresponding builders for processing, such as MQBuilder, RPCBuilder, CacheBuilder, etc.; the process of loading the factory SPI can be specifically manifested as loading the implementation class of each type of Factory through ServiceLoader, and executing the creation logic of the Factory. It can also add the logic of listening to configuration changes. The logic of listening to configuration changes is manifested in the creation of the Factory based on the user configuration mentioned above. When the configuration changes, the factory layer will have different performances for different middleware instances. Different performances depend on the specific implementation. For example, when the configuration is updated, the instance is dynamically destroyed, and then the strategy of the instance based on the new configuration information is reloaded.
[0110] The factory layer, i.e., the Factory layer, can include consumer and sender factories, such as MetaQProducerFactory, ONSProducerFactory, RocketMqProducerFactory, etc., which can instantiate the adaptation layer based on the configuration to generate the encapsulation class without relying on the content of any middleware client. Specifically, a factory class creates a corresponding SDK instance based on the configuration. The core logic is mainly to parse the configuration and set the corresponding configuration to the adapter Adapter, that is, it can obtain various types of encapsulation classes, usually through ServiceLoader, load the implementation class of each type of Factory to execute the creation logic, parse the middleware configuration information, and set the corresponding configuration in the adaptation layer to create the corresponding middleware implementation class instance, i.e., the SDK instance.
[0111] The adaptation layer, namely the ClientImpl layer, depends on the middleware client, which can be mainly manifested as the dynamic loading of the middleware, such as MetaQProducer, ONSProducer, RocketMqProducer, etc. It is specifically manifested in the use of a unified middleware implementation interface to obtain the intermediate implementation class instance of the current operating environment in the adaptation layer, which is mainly manifested in the middleware implementation class instance (ie, SDK instance) built based on the factory layer and the middleware implementation dependency package provided by the dependency provider. It should be noted that for the adapter layer of each middleware, try to ensure that the adaptation SDK facade is consistent with the original one. As for maintaining the specific strategy adopted, the embodiment of the present application does not limit this.
[0112] Dependency providers, i.e. DependencyProvider, such as PandoraContainer, MavenPlugin, etc., can dynamically load the required middleware dependency packages based on the environment configuration. Specifically, they can be implemented based on preset plug-ins. Preset plug-ins include but are not limited to pandora / maven plug-ins to provide middleware implementation dependency packages, such as Redis, Dubbo, MetaQ, Nacos, etc., as the basis for middleware implementation, and then introduce the dependent middleware information into the adaptation layer to obtain the resource package for loading application services, such as MetaQProducerImpl, ONSProducerImpl, RocketMqProducerImpl, etc.
[0113] Reference Figure 3 , which shows a schematic diagram of an application scenario of the application running provided by the embodiment of the present application, which can be used as follows Figure 2 The multi-runtime adaptation framework MRF shown in the figure can be presented as an application running system in actual application scenarios. The application running system is configured with a middleware adaptation framework, which includes a middleware adaptation layer, an adapter, middleware, and a computer program executed based on the application running system adaptation layer. When the computer program is executed by the application running system, the aforementioned middleware adaptation method or application running method is implemented.
[0114] Among them, Figure 3 The middleware adaptation layer shown is Figure 2The adaptation layer in the multi-runtime adaptation framework MRF shown in the figure can specifically shield different operating environments based on the intermediate adaptation layer, such as the middleware differences of multiple clouds (including hybrid clouds, public clouds, external clouds, etc.) when running service applications in different operating environments, such as service applications deployed in the shell, public clouds, and private clouds. Specifically, the intermediate adaptation layer can integrate the interfaces used by different operating environments, such as ConfigAPI, PRCAPI, CacheAPI, DB&SequenceAPI, SchedulerAPI, SearchAPI, BigtableAPI, Cypt API, etc., based on the middleware implementation interface MiddleWareAPI unified for different operating environments; in the adapter layer, it is mainly manifested as the SPI layer instantiating the required middleware according to the configuration information of the current operating environment, and the middleware implementation class corresponding to the current operating environment can be loaded and configured through a unique middleware class loading method, such as through the middleware configuration MiddleWareConfiguration based on the configuration information Global Config, MDImplConfig load the corresponding middleware adapter MiddleWareAdapter to obtain the in-popup resource adapter, cloud resource adapter or open source resource adapter, etc. Among them, it can also realize the functions of precipitation isolation detection tool, automatic configuration support and fast pop-up. The fast pop-up is mainly manifested in providing some Maven plug-ins, so that users do not need to pay too much attention to too much configuration; the middleware can provide a variety of middleware adaptation support, and can also allow the maintenance of the ecology through open source co-construction. In some embodiments of the present application, middleware implementations of in-shell and cloud standards can be precipitated, that is, relevant middleware resource packages MiddleWareImpl are provided, such as resource packages "HSFServiceA:100", "MetaQTopic1", "DiamondGroup1", "DB_App1", etc. for in-shell resources; resource packages "EdasServiceA:10.0-a", "ONSTopic1-a", "ACMGroup1.a", "DB_App1_a", etc. for cloud resources; resource packages "DubboServiceA:10.0-a", "RocketMQTopic1-a", "Nacos Group1.a", "DB_App1_a", etc. for open source resources, and the functions of other cloud vendors' middleware can also be provided based on the open open source mechanism, which is not limited by the embodiments of the present application.
[0115] It should be noted that for the middleware adaptation method implemented by the application running system, reference may be made to the above content, and the embodiments of the present application are not limited thereto.
[0116] For the application running method implemented by the application running system, please refer to Figure 4 The steps shown are as follows:
[0117] 401, responding to the startup instruction of the preset service application and obtaining the software development kit of the preset service application;
[0118] like Figure 2 The software development kit SDK generated by the multi-runtime adaptation framework MRF shown can be applied to the preset service application. After responding to the startup instruction of the preset service application, the software development kit of the preset service application can be obtained so as to obtain the middleware implementation interface based on the software development kit.
[0119] Among them, different operating environments may affect the different configuration information of the service application during runtime, which can be specifically manifested as different codes. Correspondingly, for the use of middleware in different operating environments, the middleware implementation of the corresponding environment is usually adopted. In the embodiment of the present application, the middleware implementation interface can be unified, that is, the middleware implementation interface of different operating environments can be set to a unified middleware implementation interface, and the middleware corresponding to different operating environments can be uniformly adapted based on the unified middleware implementation interface, and the differences in middleware applications in multiple runtime environments can be shielded based on the unified middleware implementation interface.
[0120] Specifically, the unification of the middleware implementation interface can be manifested as not coupling with a specific middleware, abstractly defining the middleware defined by the interface, and defining the adaptability of the middleware. Specifically, it can be defined and implemented through the MRF framework to remove middleware dependencies, such as Maven dependencies within the bullet, and achieve the same use of middleware on the bullet cloud. It should be noted that the middleware handled by the middleware implementation interface is mainly considered from the perspective of user use and versatility, making it as convenient for users to use as possible and able to adapt to more implementations. For scenarios where there may be conflicts or incompatibilities between different middleware implementations, the abstract definition of the middleware can be adjusted based on the intersection of the interface definition and the interface definition that conforms to the user's usage habits. This is not limited in the embodiments of the present application.
[0121] 402, running the preset service application in the current running environment based on the software development kit.
[0122] Among them, the software development kit can be used to obtain a unified middleware implementation interface for different operating environments, and to obtain a middleware implementation class and a middleware implementation class instance for the current operating environment based on the middleware implementation interface. The middleware implementation class can be used to introduce the middleware dependency package corresponding to the current operating environment, and the middleware implementation class instance can be obtained by instantiating the middleware encapsulation class.
[0123] In some embodiments of the present application, a unified middleware implementation interface for different operating environments can be used to obtain the middleware implementation class and the middleware implementation class instance for the current operating environment, and the intermediate implementation class instance with added middleware characteristics can be obtained. The preset service application can be run in the current operating environment with the intermediate implementation class instance that conforms to the current operating environment, thereby completing the middleware adaptation of the preset service application in the current operating environment.
[0124] In the specific implementation, the preset service application uses a unified middleware interface based on the loaded middleware implementation class and middleware implementation class instance to shield the middleware differences of the application in multiple runtime environments, isolate the impact of the middleware differences on the application running system, and achieve the purpose of deploying a set of code in multiple running environments.
[0125] In the embodiment of the present application, in the case of using other middleware, the specific middleware can be decoupled through interaction through internal modules, and there is no coupling with a certain runtime; and by adopting the API definition paradigm that Java developers are accustomed to, and through the self-developed DependencyProvider, the service application can be connected to the MRF without coupling to a specific implementation, but automatically load the specific middleware implementation through configuration. That is, through the unified middleware implementation interface for different operating environments, the different middleware implementation classes introduced based on different operating environments and the middleware instantiated based on different runtime environment configurations are obtained, and then the preset service application is run in the current operating environment, that is, the middleware differences of the application in multiple runtime environments can be shielded based on the unified middleware implementation interface, and the impact on the application running system can be isolated, so as to achieve the purpose of implementing a set of code for the service application and deploying in multiple operating environments.
[0126] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0127] Reference Figure 5 , shows a structural block diagram of an application running device embodiment of the present application, which may specifically include the following modules:
[0128] The middleware implementation interface acquisition module 501 is used to acquire a unified middleware implementation interface for different operating environments;
[0129] The middleware acquisition module 502 is used to identify the current operating environment and obtain the middleware implementation class and the middleware implementation class instance through the middleware implementation interface; the middleware implementation class introduces the middleware dependency package corresponding to the current operating environment based on the preset plug-in, and the middleware implementation class instance is obtained based on the instantiation of the middleware encapsulation class;
[0130] The service application running module 503 is used to run the preset service application in the current running environment according to the middleware implementation class and the middleware implementation class instance.
[0131] In one embodiment of the present application, the middleware acquisition module 502 may include the following submodules:
[0132] An environment configuration information acquisition submodule is used to acquire the environment configuration information of the current operating environment;
[0133] A middleware dependency package loading submodule, used for dynamically loading the middleware dependency package for the current running environment based on the environment configuration information;
[0134] The middleware implementation class acquisition submodule is used to obtain the middleware implementation class provided by the middleware dependency package based on the preset plug-in through the middleware implementation interface.
[0135] In one embodiment of the present application, the middleware acquisition module 502 may include the following submodules:
[0136] The middleware configuration information acquisition submodule is used to obtain the middleware configuration information;
[0137] The class instance creation submodule is used to create a middleware implementation class instance based on the middleware configuration information.
[0138] In one embodiment of the present application, the middleware configuration information acquisition submodule may include the following units:
[0139] The middleware configuration information generation unit is used to obtain the original middleware configuration information of the preset service application in different operating environments; the original middleware configuration information is uniformly processed according to the preset configuration format to obtain the middleware configuration information; wherein the middleware configuration information processed in the preset configuration format includes the middleware instance, middleware type and middleware attribute corresponding to each operating environment.
[0140] In one embodiment of the present application, the class instance creation submodule may include the following units:
[0141] Encapsulation class acquisition unit, used to acquire various types of encapsulation classes;
[0142] The class instantiation unit is used to instantiate the encapsulation class based on the middleware configuration information to obtain a middleware implementation class instance.
[0143] In one embodiment of the present application, the middleware implementation class is used to provide the dependent middleware information and has middleware characteristics; the service application running module 503 may include the following submodules:
[0144] The service application running submodule is used to add middleware characteristics for the current running environment to the middleware implementation class instance based on the middleware implementation class, so as to obtain the middleware implementation class instance after the middleware characteristics are added; the middleware implementation class instance after the middleware characteristics are added conforms to the current running environment; and the preset service application is run by using the middleware implementation class instance after the middleware characteristics are added.
[0145] In the embodiment of the present application, the middleware adaptation device provided in the embodiment of the present application obtains the middleware implementation class and the middleware implementation class instance for the current operating environment through the unified middleware implementation interface for different operating environments, so as to run the preset service application in the current operating environment based on the obtained middleware implementation class and the middleware implementation class instance, and complete the middleware adaptation of the preset service application in the current operating environment. Through the unified middleware implementation interface for different operating environments, the different middleware implementation classes introduced based on different operating environments and the middleware instantiated based on different operating environment configurations are obtained, thereby realizing the operation of the preset service application in the current operating environment, shielding the middleware differences of the application in multiple operating environments based on the unified middleware implementation interface, isolating the impact on the application operating system, and realizing the general middleware adaptation of the service application in different operating environments, so as to achieve the purpose of implementing a set of code for the service application and deploying in multiple operating environments.
[0146] Reference Figure 6 , shows a structural block diagram of another embodiment of an application running device of the present application, which may specifically include the following modules:
[0147] The service application startup module 601 is used to respond to the startup instruction of the preset service application and obtain the software development kit of the preset service application;
[0148] The service application running module 602 is used to run the preset service application in the current running environment based on the software development kit; wherein the software development kit is used to obtain a unified middleware implementation interface for different running environments, and to obtain a middleware implementation class and a middleware implementation class instance for the current running environment based on the middleware implementation interface, wherein the middleware implementation class introduces the middleware dependency package corresponding to the current running environment based on the preset plug-in, and the middleware implementation class instance is obtained based on instantiating the middleware encapsulation class.
[0149] In the embodiment of the present application, the application running device provided by the embodiment of the present application, through a unified middleware implementation interface for different operating environments, obtains different middleware implementation classes introduced based on different operating environments and middleware instantiated based on different runtime environment configurations, thereby realizing the operation of a preset service application in the current operating environment, and shields the middleware differences of the application in multiple runtime environments based on the unified middleware implementation interface, isolates the impact on the application running system, and realizes the general middleware adaptation of the service application in different operating environments, thereby achieving the purpose of implementing a set of code for the service application and deploying it in multiple operating environments.
[0150] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0151] The present application also provides an electronic device, including:
[0152] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned application running method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0153] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned application running method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0154] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referenced to each other.
[0155] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0156] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0157] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0158] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0159] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and changes and modifications that fall within the scope of the embodiments of the present application.
[0160] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0161] It should also be noted that, in this article, relational terms such as first and second, etc. are used to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0162] The above is a detailed introduction to an application running method, a corresponding application running system, a corresponding electronic device and a corresponding computer-readable storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for running an application, the method comprising: Obtain a unified middleware implementation interface for different operating environments; Identify the current operating environment, and obtain the middleware implementation class and the middleware implementation class instance through the middleware implementation interface; the middleware implementation class introduces the middleware dependency package corresponding to the current operating environment based on the preset plug-in, and the middleware implementation class instance is obtained based on instantiating the middleware encapsulation class; According to the middleware implementation class and the middleware implementation class instance, the preset service application is run in the current running environment.
2. The method according to claim 1, obtaining the middleware implementation class through the middleware implementation interface, comprises: Obtaining environment configuration information of the current operating environment; Dynamically loading a middleware dependency package for the current operating environment based on the environment configuration information; Through the middleware implementation interface, the middleware implementation class provided by the middleware dependency package is obtained based on the preset plug-in.
3. The method according to claim 1, obtaining a middleware implementation class instance through the middleware implementation interface comprises: Get middleware configuration information; A middleware implementation class instance is created based on the middleware configuration information.
4. The method according to claim 3, wherein the step of creating a middleware implementation class instance based on the middleware configuration information comprises: Obtain the original middleware configuration information of the preset service application in different operating environments; The original middleware configuration information is uniformly processed according to a preset configuration format to obtain middleware configuration information; wherein the middleware configuration information processed in the preset configuration format includes middleware instances, middleware types and middleware attributes corresponding to each operating environment.
5. The method according to claim 3 or 4, wherein the step of creating a middleware implementation class instance based on the middleware configuration information comprises: Get various types of encapsulation classes; The encapsulation class is instantiated based on the middleware configuration information to obtain a middleware implementation class instance.
6. According to the method of claim 1, 2 or 3, the middleware implementation class is used to provide the dependent middleware information and has middleware characteristics; and the running of the preset service application in the current running environment according to the middleware implementation class and the middleware implementation class instance comprises: Based on the middleware implementation class, middleware characteristics for the current operating environment are added to the middleware implementation class instance to obtain the middleware implementation class instance after the middleware characteristics are added; the middleware implementation class instance after the middleware characteristics are added conforms to the current operating environment; The preset service application is run using the intermediate implementation class instance after the middleware characteristics are added.
7. A method for running an application, the method comprising: In response to a startup instruction of a preset service application, obtaining a software development kit of the preset service application; The preset service application is run in the current operating environment based on the software development kit; wherein the software development kit is used to obtain a unified middleware implementation interface for different operating environments, and to obtain a middleware implementation class and a middleware implementation class instance for the current operating environment based on the middleware implementation interface, wherein the middleware implementation class introduces the middleware dependency package corresponding to the current operating environment based on the preset plug-in, and the middleware implementation class instance is obtained based on instantiating the middleware encapsulation class.
8. An application running system, wherein the application running system is configured with a middleware adaptation framework, the middleware adaptation framework includes a middleware adaptation layer, an adapter, middleware, and a computer program executed based on the application running system adaptation layer, and when the computer program is executed by the application running system, it implements the application running method as described in any one of claims 1 to 6 or claim 7.
9. An electronic device, comprising: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the application running method according to any one of claims 1 to 6 or claim 7 is implemented.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the application running method according to any one of claims 1 to 6 or claim 7.
