CN114035900A - A startup method, server and storage medium based on Spring and CXF applications - Google Patents
A startup method, server and storage medium based on Spring and CXF applications Download PDFInfo
- Publication number
- CN114035900A CN114035900A CN202111347199.1A CN202111347199A CN114035900A CN 114035900 A CN114035900 A CN 114035900A CN 202111347199 A CN202111347199 A CN 202111347199A CN 114035900 A CN114035900 A CN 114035900A
- Authority
- CN
- China
- Prior art keywords
- spring
- cxf
- container
- service
- application
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/955—Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45575—Starting, stopping, suspending or resuming virtual machine instances
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Stored Programmes (AREA)
Abstract
The invention provides a starting method based on Spring and CXF application, wherein the method comprises the following steps: defining specific annotations for REST services developed under the CXF framework; responding to the application starting and scanning all the Javabeans in the system, and not carrying out loading and assembling operation on the Javabeans with the specific annotation; and in response to the successful application starting and the receipt of the service request, loading the corresponding Javabean based on the preset container generation strategy to assemble the generated container so as to respond to the service request by the container. The beneficial effects of the invention include: by defining specific annotations for REST services developed under the CXF framework; responding to the application starting and scanning all the Javabeans in the system, and not carrying out loading and assembling operation on the Javabeans with the specific annotation; responding to the application starting success and receiving the service request, loading a corresponding Javabean based on a preset container generation strategy, assembling the Javabean to generate a container so as to respond to the service request by the container, and realizing lazy loading of an Apcache CXF REST service layer.
Description
Technical Field
The invention relates to the technical field of Java service development, in particular to a starting method based on Spring and CXF application, a server and a readable storage medium.
Background
For the Spring system, all heavy work is completed when the Spring system is started, so that the application has good performance during running. The IoC container is the most core part in Spring, and during the starting process of the application program, all beans in the system are scanned and assembled according to a certain relation, which in turn wastes a great deal of time. While the Spring note can be counted as a "murder" that is time-consuming to start, it can greatly simplify the development process, but it also introduces additional complexity to the program execution. For example, the @ transfational and @ EnableCaching annotations need to be scanned and identified by a program in the starting process, and then an agent class is generated for the annotation class or processed by AOP interception, so that the starting performance of the system is further influenced.
The Spring system is built with a lazy loading attribute, however, due to project requirements, it is often necessary to replace part of the Spring framework with another framework compatible with the Spring system, for example, an cxf framework is used to replace a Spring mvc framework, but the cxf framework does not support the lazy loading function, so that the starting speed of applications developed based on the Spring and cxf frameworks is slow.
Disclosure of Invention
In order to solve the technical problem that the CXF framework does not support the lazy loading function, so that the starting speed of the application developed based on the Spring and CXF frameworks is slow, in a first aspect of the present invention, a starting method based on the Spring and CXF application is provided, the method includes: defining specific annotations for REST services developed under the CXF framework; in response to the application starting and scanning all Javabeans in the system, no loading and assembling operation is carried out on the Javabeans with the specific annotation; and in response to the successful application starting and the receipt of the service request, loading the corresponding Javabean based on a preset container generation strategy to assemble a generated container so as to respond to the service request by the container.
In one or more embodiments, the specific annotation is to identify a corresponding REST service, and the specific annotation includes: REST Service base path and Service.
In one or more embodiments, the method further comprises: the system comprises a user-defined loader, a data processing unit and a data processing unit, wherein the user-defined loader is used for scanning all REST services under a specified path and generating a packet path corresponding to the REST services; and the user-defined request filtering mechanism is used for matching the packet path according to the URL path in the service request when the service request reaches the server.
In one or more embodiments, in response to successful application startup and receiving a service request, loading a corresponding java bean based on a preset container generation policy to assemble a generated container, and providing a service to the service request by the container, including: responding to a service request received by a system, and acquiring a REST service base path and a URL path in the service request; starting the user-defined loader, scanning all REST service definitions under the path based on the REST service base path, and generating a packet path corresponding to the REST service; starting a user-defined request filtering mechanism, matching a packet path based on the URL path and determining a corresponding REST service definition; and loading and assembling the corresponding Javabeans to generate a corresponding container according to the dependency of the REST service and the lower layer, and responding the service request by the container.
In one or more embodiments, the method further comprises: before the service request is responded by the container, the container is started and initialization, verification and metadata analysis operations of Javabeans of an annotation component are executed.
In one or more embodiments, the method further comprises: and adding a packet path fast matching rule into the URL of the service request.
In one or more embodiments, the method further comprises: in Spring Data JPA of Spring framework, the attribute BootstrapMOde is configured to be in a deferred loading mode.
In one or more embodiments, the method further comprises: in the Springbean of the Spring framework, the lazyinitification of the delay initialization of the configuration application is True.
In a second aspect of the present invention, there is also provided a server, including: at least one processing unit; and a storage unit having stored therein an executable computer program for implementing the steps of the Spring and CXF application based startup method as in any one of the above embodiments when executed.
In a third aspect of the present invention, a readable storage medium is proposed, in which an executable computer program is stored, the computer program, when being executed, is used for implementing the steps of the Spring and CXF application based start-up method in any of the above embodiments.
The beneficial effects of the invention include: by defining specific annotations for REST services developed under the CXF framework; responding to the application starting and scanning all the Javabeans in the system, and not carrying out loading and assembling operation on the Javabeans with the specific annotation; responding to the application starting success and receiving the service request, loading a corresponding Javabean based on a preset container generation strategy to assemble a generated container so as to respond to the service request by the container, realizing lazy loading of an Apcache CXF REST service layer, and enabling the initial starting speed of the REST service to be faster by adding a packet path fast matching rule in a URL (uniform resource locator), thereby being beneficial to improving user experience.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
Fig. 1 is a work flow diagram of a starting method based on Spring and CXF applications according to the present invention;
FIG. 2 is a schematic diagram of a server according to the method of the present invention;
fig. 3 is a schematic structural diagram of a readable storage medium based on the method of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two entities with the same name but different names or different parameters, and it should be noted that "first" and "second" are merely for convenience of description and should not be construed as limitations of the embodiments of the present invention, and they are not described in any more detail in the following embodiments.
Fig. 1 is a work flow chart of the starting method based on Spring and CXF application of the present invention. As shown in fig. 1, the workflow of the starting method based on Spring and CXF application of the present invention includes:
step S1, defining specific annotations for REST service developed under CXF framework;
specifically, the specific annotation itself is constructed in a manner different from annotations under other frameworks, such as in a specific format, with a specific token, and the like; thus, the annotation itself can serve as an identification of the corresponding REST service, such that during the process of launching the loaded instance java bean by the application, the particular annotation and the corresponding REST service are identified. In another alternative embodiment, different packaging types may also be employed to enable differentiated identification of corresponding REST services and annotations.
Step S2, responding to the application starting and scanning all the Javabeans in the system, and not loading and assembling the Javabeans with specific annotations;
specifically, the Spring application loads all instances javabeans of the service which are not configured with the lazy loading attribute in the starting process, assembles the instances javabeans to generate a container, and prepares for providing the service to the outside. Since the cxf framework does not support lazy loading of Spring, the present invention tags the identification by taking specific notes to the service under the cxf framework so that it avoids being loaded and assembled into a production container during application startup.
Step S3, responding to the application starting success and receiving the service request, loading the corresponding Javabean based on the preset container generating strategy to assemble the generated container so as to respond the service request by the container;
specifically, the container may manage a life cycle of the object and a dependency relationship between the objects, may use a configuration file (usually XML), define names of the objects, how to generate the objects (prototypetype or Singleton), which object must be set as an attribute of a certain object after being generated, and the like, and after the container is started, all the objects may be directly used without writing any program code to generate the objects, or establish a dependency relationship between the objects. When a certain service request triggers the generation of a container, all subsequent same service requests can be served by the container.
In one embodiment, the specific annotation for identifying the corresponding REST Service comprises the REST Service base path and the Service; after the application receives the corresponding Service request, the application loads the specific annotation to obtain the corresponding REST Service base path and the Service, so that instantiation can be completed quickly, and a corresponding container is generated to provide the Service.
In another embodiment, in order to realize rapid instantiation based on the REST Service base path and the Service in the specific annotation and generate a corresponding container, the method of the present invention further includes a custom loader, which is configured to scan all REST Service definitions under the specified path and generate a packet path corresponding to the REST Service definition; and the user-defined request filtering mechanism is used for matching a packet path according to a Uniform Resource Locator (URL) path in the Service request to acquire the corresponding Service when the Service request reaches the server.
In another embodiment, in order to complete instantiation more quickly to improve the speed of providing corresponding services for the application for the first time, the method of the present invention further adds a packet path fast matching rule to the URL of the Service request, so that the URL can be matched to a suitable packet path more quickly to obtain the Service under the corresponding packet path.
Based on the above embodiments, step S3, in response to the application being successfully started and receiving the service request, the more detailed step of loading the corresponding java bean based on the preset container generation policy to assemble the generated container so as to respond to the service request by the container includes: responding to a service request received by a system, and acquiring a REST service base path and a URL path in the service request; starting a custom loader, scanning all REST service definitions under the path based on the REST service base path, and generating a packet path corresponding to the REST service; starting a user-defined request filtering mechanism, matching a packet path by adopting a preset packet path fast matching rule based on the URL path and determining a corresponding REST service definition; and according to the dependency of the REST service and the lower layer, loading the corresponding Javabean and carrying out assembly to generate a corresponding container, and responding to the service request by the container.
In another implementation, to ensure that the generated container can provide the service correctly, the method of the present invention further comprises, before responding to the service request by the container, starting the container and performing the initialization, validation, and metadata analysis operations on the java beans of the annotation component to determine that the correct container is generated, thereby providing the correct service.
In another embodiment, in order to enable the Spring frame to support the steps in the foregoing embodiments, the Spring frame needs to be configured, where the configuration includes: in a Spring Data JPA of a Spring framework, configuring an attribute BootsrapMOde into a delayed loading mode; and configuring the attribute LazyInitiation of the delayed initialization of the application to True in the Springbean of the Spring framework.
Through the scheme in each embodiment, the beneficial technical effects of the invention comprise that: by defining specific annotations for REST services developed under the CXF framework; responding to the application starting and scanning all the Javabeans in the system, and not carrying out loading and assembling operation on the Javabeans with the specific annotation; responding to the application starting success and receiving the service request, loading a corresponding Javabean based on a preset container generation strategy to assemble a generated container so as to respond to the service request by the container, realizing lazy loading of an Apcache CXF REST service layer, and enabling the initial starting speed of the REST service to be faster by adding a packet path fast matching rule in a URL (uniform resource locator), thereby being beneficial to improving user experience.
In a second aspect of the present invention, a server is also presented; fig. 2 is a schematic structural diagram of a server based on the method of the present invention. As shown in fig. 2, the server 400 of the present invention includes: at least one processing unit 401; and a storage unit 402, wherein the storage unit 402 stores an executable computer program, and the computer program is used for implementing the steps of the Spring and CXF application-based starting method in any one of the above embodiments when executed. The server 400 is a computer deployed with corresponding services and the method of the present invention.
In a third aspect of the invention, a readable storage medium is presented; fig. 3 is a schematic structural diagram of a readable storage medium based on the method of the present invention. As shown in fig. 3, the readable storage medium 500 of the present invention stores therein an executable computer program 501, and when executed, the computer program 501 is used for implementing the steps of the starting method based on Spring and CXF application in any of the embodiments described above.
Finally, it should be noted that although the invention proposes a starting method based on Spring and cxf applications, it can be understood that the invention essentially provides a quick starting method for an application developed based on Spring and a third-party tool compatible with Spring, so that the application developed based on the Spring third-party tool also supports the lazy loading property of the Spring system.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111347199.1A CN114035900A (en) | 2021-11-15 | 2021-11-15 | A startup method, server and storage medium based on Spring and CXF applications |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111347199.1A CN114035900A (en) | 2021-11-15 | 2021-11-15 | A startup method, server and storage medium based on Spring and CXF applications |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN114035900A true CN114035900A (en) | 2022-02-11 |
Family
ID=80144325
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202111347199.1A Pending CN114035900A (en) | 2021-11-15 | 2021-11-15 | A startup method, server and storage medium based on Spring and CXF applications |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN114035900A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115480842A (en) * | 2022-10-11 | 2022-12-16 | 深圳壹账通智能科技有限公司 | Product application secondary development service method, device, electronic equipment and storage medium |
| CN115562752A (en) * | 2022-09-30 | 2023-01-03 | 重庆长安汽车股份有限公司 | Application module loading method, device, equipment and storage medium |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20030084056A1 (en) * | 2001-10-26 | 2003-05-01 | Deanna Robert | System for development, management and operation of distributed clients and servers |
| US20150293764A1 (en) * | 2014-04-10 | 2015-10-15 | Omprakash VISVANATHAN | Method and system to compose and execute business rules |
| WO2015199748A1 (en) * | 2014-06-25 | 2015-12-30 | Oracle International Corporation | Rest service source code generation |
| CN106503103A (en) * | 2016-10-17 | 2017-03-15 | 济南浪潮高新科技投资发展有限公司 | A kind of lightweight REST service framework implementation method |
| CN107690003A (en) * | 2017-10-12 | 2018-02-13 | 国电南瑞科技股份有限公司 | Web Service service dynamic publishing and management method under a kind of OSGI frameworks based on CXF |
| CN113360212A (en) * | 2021-06-30 | 2021-09-07 | 远光软件股份有限公司 | Application program starting method, computer device and computer readable storage medium |
-
2021
- 2021-11-15 CN CN202111347199.1A patent/CN114035900A/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20030084056A1 (en) * | 2001-10-26 | 2003-05-01 | Deanna Robert | System for development, management and operation of distributed clients and servers |
| US20150293764A1 (en) * | 2014-04-10 | 2015-10-15 | Omprakash VISVANATHAN | Method and system to compose and execute business rules |
| WO2015199748A1 (en) * | 2014-06-25 | 2015-12-30 | Oracle International Corporation | Rest service source code generation |
| CN106503103A (en) * | 2016-10-17 | 2017-03-15 | 济南浪潮高新科技投资发展有限公司 | A kind of lightweight REST service framework implementation method |
| CN107690003A (en) * | 2017-10-12 | 2018-02-13 | 国电南瑞科技股份有限公司 | Web Service service dynamic publishing and management method under a kind of OSGI frameworks based on CXF |
| CN113360212A (en) * | 2021-06-30 | 2021-09-07 | 远光软件股份有限公司 | Application program starting method, computer device and computer readable storage medium |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115562752A (en) * | 2022-09-30 | 2023-01-03 | 重庆长安汽车股份有限公司 | Application module loading method, device, equipment and storage medium |
| CN115480842A (en) * | 2022-10-11 | 2022-12-16 | 深圳壹账通智能科技有限公司 | Product application secondary development service method, device, electronic equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN101065947B (en) | Web service registration and operation method and system | |
| JP5420139B2 (en) | Dynamic service surrogate | |
| CN110046169A (en) | Calculating based on structured query language sentence services implementation | |
| EP3974960B1 (en) | Method and system for automated testing of web service apis | |
| CN109327490B (en) | Method and server for deploying cloud service component | |
| CN107402884A (en) | Generate the method and device of interface testing code | |
| CN111736923B (en) | Data processing method, device, electronic device and readable storage medium | |
| CN114879976B (en) | Version of the environment deployment methods, devices and electronic equipment | |
| CN113971110A (en) | Interface testing method, apparatus, device and computer-readable storage medium | |
| CN114981775A (en) | Cloud-based API metadata management method and system for API integrated management | |
| CN114443215A (en) | Business application deployment method, apparatus, computer equipment and storage medium | |
| CN112698817B (en) | Message access method, device and system based on micro-service architecture and storage medium | |
| US20080235149A1 (en) | Methods and Apparatus for Agreement-Based Automated Service Provisioning | |
| CN113326030A (en) | Service request processing method and device | |
| CN114035900A (en) | A startup method, server and storage medium based on Spring and CXF applications | |
| CN1585948A (en) | Application view component for system integration | |
| US7996840B2 (en) | Method, system, and apparatus for scheduling pattern based web services | |
| CN110874278A (en) | Embedding method of external system, workflow system, device and storage medium | |
| CN116523457A (en) | Workflow processing method, device, equipment and storage medium based on business process | |
| US8972487B2 (en) | Automated framework for testing enterprise services consumer technologies | |
| CN114201213A (en) | Interface document synchronization method, device, electronic device and storage medium | |
| Nguyen et al. | A feature-oriented approach for web service customization | |
| CN117556809B (en) | Parameter verification result generation method and device, verification platform and storage medium | |
| CN116501365B (en) | Resource calling method, device and equipment based on algorithm platform | |
| CN118694819A (en) | Microservice management system, method, device, storage medium and program product |
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 |