Method for integrating OSLC specifications based on springboot framework

By introducing OSLC-related dependencies and writing converters into the Spring Boot project, the integration of OSLC specifications is achieved, solving integration problems, providing efficient microservice architecture solutions, supporting RDF format interface responses, and reducing engineering code transformation costs.

CN118550508APending Publication Date: 2024-08-27AVICIT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410882477.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

It is difficult to integrate OSLC specifications into the Spring Boot microservice framework with existing technology, resulting in the inability to realize the requirements for full life cycle management and digital clue services in the microservice architecture in the industrial field.

Method used

By introducing OSLC related dependencies into the Spring Boot project, turning on the service interface business mode, writing the OslcMessageConverter converter, and adding the ServiceProvider to the registrar, the response data processing and registration of the OSLC standard interface are implemented, and the interface response in RDF format is supported.

Benefits of technology

It realizes the non-invasive integration of OSLC specifications into existing Spring Boot projects, provides RDF format interface responses that comply with OSLC specifications, reduces the cost of engineering code transformation, and provides an efficient microservice architecture solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550508A
    Figure CN118550508A
Patent Text Reader

Abstract

The invention provides a method for integrating OSLC specifications based on a springboot framework, and belongs to the field of system engineering, and the method comprises the following steps: S1, introducing OSLC related dependency into a pom.xml file of a springboot project; s2, a service interface statement quotient mode is started in. Yml / . Properts; s3, compiling an OslcMessage Converter converter, and adding an interface response data processing method in an rdf format; the method comprises the following steps of: adding the OslcMessage Converter into a ConfigureMessage Converter, and adding the OslcMessage Converter into the ConfigureMessage Converter; and S4, according to the requirements of the project, compiling an interface which needs to be opened to the outside and needs to meet the OSLC specification or transforming the existing interface, and adding the serviceProvider into the register. According to the method provided by the invention, a project adopting a springboot development framework can quickly adapt to the OSLC specification, so that a service interface in an RDF format meeting the requirements of the OSLC specification is provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of system engineering, and in particular relates to a method for integrating OSLC specifications based on a springboot framework. Background Art

[0002] With the current technological development, the microservice framework has become popular as a mainstream development framework due to its independent deployment, strong scalability and continuous integration. The springboot development framework, as a typical framework, is also widely used in the industrial field.

[0003] RDF is the Resource Description Framework, a W3C standard for describing network resources, such as the title, author, modification date, content, and copyright information of a web page. It is designed to provide a common method for describing information so that it can be read and understood by computer applications. It is a triple data, which consists of resources, attributes, and attribute values. By returning data in RDF format and combining it with the RESUFUL interface specification, OSLC can expose its own interface URL and business data for other docking parties to call and operate on the data, so that all single services can be combined into a meshed whole, thereby providing digital clue services and managing the entire life cycle of products.

[0004] OSLC (Open Service Layer for Containers) is an open standard that uses the RDF data model and RESTful interface specifications to provide a machine-readable way to discover and call services. By returning data in RDF format, OSLC allows service providers to expose their service interface URLs and business data so that other services or applications can interact with the services through these interfaces to query, update, or perform other operations on the data. This OSLC-based approach can connect multiple independent services to form a meshed service ecosystem. In this system, each service can act as a node to communicate and exchange data with other services through standardized interfaces. Such an architecture helps to realize the concept of Digital Thread and achieve the goal of managing the entire life cycle of products.

[0005] Spring Boot microservice framework, as the mainstream choice of current technology development, has been widely adopted by many ongoing or newly launched projects / products, becoming the preferred technology base for individuals or enterprises to build infrastructure. This phenomenon highlights the strong market demand for flexible and efficient microservice solutions. Therefore, how to integrate OSLC into Spring Boot has become an urgent problem to be solved. Summary of the invention

[0006] To solve the above technical problems, the present invention provides a method for integrating OSLC specifications based on the springboot framework, comprising the following steps: Step S1: Prepare the OSLC specifications and springboot projects that need to be integrated, and introduce OSLC-related dependencies in the pom.xml file of the springboot project; Step S2: Enable the service interface business model in the .yml / .properties of the springboot project to support returning both json and rdf interface formats; Step S3: Write the OslcMessageConverter converter, add the RDF format interface response data processing method; and add the OslcMessageConverter to configureMessageConverter; Step S4: According to the needs of the project, write the interface that needs to be open to the outside world and meet the OSLC specification or modify the existing interface, add the serviceProvider to the registrar, and after the project is started, query the catalog service list according to the registrar and expand the OSLC related interfaces layer by layer.

[0007] Beneficial effects: The present invention provides a method for integrating OSLC specifications based on the springboot framework, innovatively proposes a method for integrating open service lifecycle collaboration services (OSLC) with Spring Boot, and creatively utilizes the business model and OSLC specifications to transcribe the response data format. This method not only gives full play to the advantages of both, but also achieves the lowest transformation cost in the existing technology. The method of the present invention follows industry standards and shows a high degree of feasibility at the practical level, which can help more enterprises and developers enjoy cost-effective and easy-to-implement technical solutions in the process of building and optimizing microservice architecture.

[0008] The method of the present invention has little intrusion on the original engineering code, and the developed interface is not affected. It also provides an interface response in RDF format that complies with the OSLC specification, and provides assistance for projects that adopt the springboot development framework and need to integrate OSLC. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 A schematic diagram of a method for integrating OSLC specifications based on the springboot framework of the present invention; Figure 2 A diagram of the OSLC vision; Figure 3 This is a schematic diagram of the core components of OSLC; Figure 4 The figure is a schematic diagram of the implementation principle of the method of the present invention. DETAILED DESCRIPTION

[0010] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0011] The scope of application of the present invention and the problems to be solved are: The present invention is applicable to projects that use springboot as a development framework, and can be applied to projects that have been developed or are in the initial stage of development.

[0012] Using the springboot framework, the use of OSLC in the developed projects will inevitably affect the interface layer, because OSLC is a Restful interface specification based on JAX-RS, and Jersey implements this specification, so OSLC uses Jersey as a servlet container, and the servlet containers supported by springboot include Tomcat, jetty, Undertow, etc., and the cost of replacing the existing container with the Jersey container or replacing Jersey with the container supported by springboot is huge and unrealistic. Replacing the servlet will inevitably affect the interface URL that has been developed, and the interface open to the outside world by OSLC is also closely related to the URL, so the purpose of the present invention is to make the two coexist and not affect each other.

[0013] The underlying principle of the RDF format response data provided by OSLC is to scan the @OslcXXX annotation on the entity and the RDF data format it specifies when returning HttpMessageBody, obtain the annotation on the get method through the reflection mechanism, and then add different RDF tag attributes and content according to the annotation. The RDF document format is actually the implementation of Jena called. OSLC has implemented the reader and writer of Jena in detail, so the response data finally written to Response is the result of processing with its custom annotations and RDF format tags.

[0014] After clarifying the processing logic of OSLC, the springboot framework also has a corresponding specific processing solution. First, the business model of the springboot interface response is enabled, which can support the same interface to support response results in multiple formats. In addition, a response body converter needs to be written to match the RDF format added by the business model, and the converter needs to reference the Jena reader and writer so that it can be used to convert and process the specific response body in RDF format. In addition, specific @OslcXXX annotations need to be added to the response entity and interface, and RootService, ServiceProviderCatalog, ServiceProvider, etc. need to be written to register and assemble the OSLC interface, so that the integration can meet the OSLC specification. The following implementation examples will specifically explain the implementation steps.

[0015] Embodiment 1 like Figure 1 As shown, a method for integrating OSLC specifications based on the springboot framework provided by an embodiment of the present invention includes the following steps: Step S1: Prepare the OSLC specifications and springboot projects that need to be integrated, and introduce OSLC-related dependencies in the pom.xml file of the springboot project; Step S2: Enable the service interface business model in the .yml / .properties of the springboot project to support returning both json and rdf interface formats; Step S3: Write the OslcMessageConverter converter, add the RDF format interface response data processing method; and add the OslcMessageConverter to configureMessageConverter; Step S4: According to the needs of the project, write the interfaces that need to be open to the outside world and meet the OSLC specification or modify the existing interfaces, add the serviceProvider to the registrar, and after the project is started, query the catalog service list according to the registrar and expand the OSLC related interfaces layer by layer.

[0016] In one embodiment, the above step S1: prepare the OSLC specification and springboot project that need to be integrated, and introduce OSLC related dependencies in the pom.xml file of the springboot project.

[0017] In one embodiment, the above step S2: enables the service interface language business mode in the .yml / .properties of the springboot project to support returning both json and rdf interface formats.

[0018] Add the following code to enable Spring's business model in the .yml / .properties configuration file: spring: mvc: contentnegotiation: media-types: json: application / json xml: application / xml rdf: application / rdf+xml favor-parameter: true # Enable request parameter content mode In one embodiment, the above step S3: writing an OslcMessageConverter converter, adding an RDF format interface response data processing method; and adding OslcMessageConverter to configureMessageConverter specifically includes: Step S31: Use the OslcMessageConverter converter to intercept the request and response of the interface and determine whether it matches the language business model. If it matches, call the OSLC JenaModelHelper processor to convert the response data format into RDF format. The code is as follows: @SneakyThrows @Override public void write(T t, MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { / / outputMessage.getHeaders().setContentType(contentType); / / Custom protocol data writing Object[] objects = null; if (t instanceof List) { objects = ((List<?>) t).toArray(); } else { objects = new Object[]{t}; } Model jenaModel = JenaModelHelper.createJenaModel(objects); jenaModel.setNsPrefixes(buildNsPrefixMap()); javax.ws.rs.core.MediaType mediaType = new javax.ws.rs.core.MediaType(contentType.getType(), contentType.getSubtype(), contentType.getParameters()); RDFWriter writer = getRdfWriter(objects, mediaType, jenaModel); writer.setProperty("showXmlDeclaration", "false"); String xmlDeclaration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; / / Write out OutputStream body = outputMessage.getBody(); body.write(xmlDeclaration.getBytes()); writer.write(jenaModel,body,null); } Step S32: Add the OslcMessageConverter converter to configureMessageConverters and automatically match the request format defined by the speech business model.

[0019] In one embodiment, the above step S4: according to the needs of the project, write the interface that needs to be open to the outside and needs to meet the OSLC specification or modify the existing interface, add the serviceProvider to the registrar, and after the project is started, query the catalog service list according to the registrar, and expand the OSLC related interfaces layer by layer, specifically including: Step S41: Write the serviceProviderCatalog and serviceProviderFactory required for the project, and register the serviceProvider to be processed, as shown in the following code: private static ServiceProvider registerServiceProviderNoSync(finalURI serviceProviderURI,final ServiceProvider serviceProvider,final StringproductId) { final SortedSet <uri>serviceProviderDomains =getServiceProviderDomains(serviceProvider); serviceProvider.setAbout(serviceProviderURI); serviceProvider.setIdentifier(productId); serviceProvider.setCreated(new Date()); serviceProvider.setDetails(new URI[]{serviceProviderURI}); serviceProviderCatalog.addServiceProvider(serviceProvider); serviceProviderCatalog.addDomains(serviceProviderDomains); serviceProviders.put(productId, serviceProvider); return serviceProvider; } Step S42: Add the serviceProvider or OSLC related annotations to the already written interface class and interface method, write a registrar, and add the required serviceProvider registration to the catalog.

[0020] After completing the above configuration transformation, start the service and you can obtain rdf format data that complies with the oslc specification by adding format=rdf after the original request URL.

[0021] Figure 2 The OSLC vision diagram is shown; Figure 3 A schematic diagram of the core components of OSLC is shown; Figure 4 The implementation principle diagram of the method of the present invention is shown.< / uri>

Claims

1. A method for integrating OSLC specifications based on the springboot framework, characterized in that: The steps include: Step S1: Prepare the OSLC specifications and springboot projects that need to be integrated, and introduce OSLC-related dependencies in the pom.xml file of the springboot project; Step S2: Enable the service interface business model in the .yml / .properties of the springboot project to support returning both json and rdf interface formats; Step S3: Write the OslcMessageConverter converter, add the RDF format interface response data processing method; and add the OslcMessageConverter to configureMessageConverter; Step S4: According to the needs of the project, write the interface that needs to be open to the outside world and meet the OSLC specification or modify the existing interface, add the serviceProvider to the registrar, and after the project is started, query the catalog service list according to the registrar and expand the OSLC related interfaces layer by layer.

2. The method for integrating OSLC specifications based on springboot framework according to claim 1, characterized in that: The step S3: writing an OslcMessageConverter converter, adding an RDF format interface response data processing method; and adding OslcMessageConverter to configureMessageConverter, specifically includes: Step S31: intercept the request and response of the interface by using the OslcMessageConverter converter to determine whether they match the language business model. If they match, call the JenaModelHelper processor of OSLC to convert the data format of the response into RDF format; Step S32: Add the OslcMessageConverter converter to configureMessageConverters and automatically match the request format defined by the speech business model.

3. The method for integrating OSLC specifications based on springboot framework according to claim 1, characterized in that: Step S4: According to the needs of the project, write an interface that needs to be open to the outside world and meet the OSLC specification or modify the existing interface, add the serviceProvider to the registrar, and after the project is started, query the catalog service list according to the registrar, and expand the OSLC related interfaces layer by layer, specifically including: Step S41: Write the serviceProviderCatalog and serviceProviderFactory required for the project, and register the serviceProvider to be processed; Step S42: Add the serviceProvider or OSLC related annotations to the already written interface class and interface method, write a registrar, and add the required serviceProvider registration to the catalog.