Skip to content

Commit 806ad5d

Browse files
berezovskyiCopilot
andauthored
docs: style updates for Lyo 101 setup (#41)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c969b4b commit 806ad5d

File tree

1 file changed

+51
-50
lines changed

1 file changed

+51
-50
lines changed

docs-new/eclipse_lyo/setup-an-oslc-provider-consumer-application.md

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# Create an Eclipse Lyo project
22

3-
This document provides step-by-step instructions for creating a Java project with the necessary configurations to develop any OSLC server/client using Lyo. The instructions assume you are using the Eclipse IDE, but should be equally valid for any other development environment.
3+
This document provides step-by-step instructions for creating a Java project with the necessary configurations to develop OSLC server/client applications using Lyo. The instructions assume Eclipse IDE is being used, but are equally valid for other development environments.
44

55
## An alternative to the manual steps below
66

77
An alternative to the instructions on this page is to use [Lyo Designer](./lyo-designer.md) to quickly generate the project, including a very basic code skeleton. The generated project will also include the necessary setup for OpenApi/Swagger support, TRS, etc.
88

9-
1. Make sure your environment is set up for Lyo development as instructed on [Eclipse Setup for Lyo-based Development](./eclipse-setup-for-lyo-based-development.md).
9+
1. Set up the environment for Lyo development as instructed on [Eclipse Setup for Lyo-based Development](./eclipse-setup-for-lyo-based-development.md).
1010
1. Install [Lyo Designer](./install-lyo-designer.md).
1111
1. Follow the [Create a Modelling Project](./toolchain-modelling-workshop.md#create-modelling-project) instructions (*Only this particular section*) to create the Eclipse project.
12-
1. Follow the [Adapter Interface](./toolchain-modelling-workshop.md#adaptor-interface-view) instructions (*Only this particular section*) to create a single Adaptor Interface in the model. You do not need to create any additional elements, such as a Service Provider Catalog, Service Provider, etc. Just make sure you set the generation settings as expected.
13-
1. Follow the [Generate Lyo Java code](./toolchain-modelling-workshop.md#generate-oslc4j-java-code) instructions (*Only this particular section*) to generate your basic project setup.
14-
1. You are done! But of course, you can proceed with Lyo Designer to model your complete OSLC Server/Client and generate even more of your project code.
12+
1. Follow the [Adaptor Interface](./toolchain-modelling-workshop.md#adaptor-interface-view) instructions (*Only this particular section*) to create a single Adaptor Interface in the model. Do not create additional elements, such as a Service Provider Catalog, Service Provider, etc. Set the generation settings as expected.
13+
1. Follow the [Generate Lyo Java code](./toolchain-modelling-workshop.md#generate-oslc4j-java-code) instructions (*Only this particular section*) to generate the basic project setup.
14+
1. The process is complete! Lyo Designer can be used to model the complete OSLC Server/Client and generate additional project code.
1515

1616
## Introduction
1717

18-
In the instructions below, we assume the following parameters, which you will need to adjust for your particular project:
18+
In the instructions below, the following parameters are assumed, which need to be adjusted for the particular project:
1919

20-
* Eclipse Project Name: *adaptor-sample-webapp*
21-
* Base Package Name for Java Classes: *com.sample.adaptor*
20+
* Eclipse Project Name: `adaptor-sample-webapp`
21+
* Base Package Name for Java Classes: `com.sample.adaptor`
2222

23-
We will here only create the code skeleton. The [Toolchain Modelling Workshop](./toolchain-modelling-workshop.md) can then be used to generate the necessary code to become a fully functional server.
23+
These instructions create only the code skeleton. The [Toolchain Modelling Workshop](./toolchain-modelling-workshop.md) can then be used to generate the necessary code to become a fully functional server.
2424

2525
As a complement when following the instructions below, you can find sample projects under the [Lyo Adaptor Sample Modelling](https://github.com/OSLC/lyo-adaptor-sample-modelling) git repository.
2626

@@ -41,41 +41,41 @@ Creating the project consists of these steps:
4141

4242
## Set up Eclipse
4343

44-
Make sure your environment is set up for Lyo development as instructed on [Eclipse Setup for Lyo-based Development](./eclipse-setup-for-lyo-based-development.md).
44+
Set up the environment for Lyo development as instructed on [Eclipse Setup for Lyo-based Development](./eclipse-setup-for-lyo-based-development.md).
4545

4646
## Create a Maven project
4747

4848
To create a Maven project from an archetype via Eclipse:
4949

50-
1. Select *File -> New -> Other*.
51-
1. Then select *Maven Project* under *Maven* group.
52-
1. Leave the *Create a simple project* checkbox unchecked.
53-
1. Uncheck the *Use default Workspace location* option and point it to the project root.
54-
1. Press *Next*.
50+
1. Select **File -> New -> Other**.
51+
1. Then select **Maven Project** under **Maven** group.
52+
1. Leave the **Create a simple project** checkbox unchecked.
53+
1. Uncheck the **Use default Workspace location** option and point it to the project root.
54+
1. Press **Next**.
5555

5656
![](./images/CreateMavenAdaptorProject_Step1.png)
5757

5858
Next, select the `maven-archetype-webapp` archetype:
5959

6060
![](./images/CreateMavenAdaptorProject_Step2.png)
6161

62-
Next, fill in the **Group Id**, **Artefact Id**, and the **Package Base**.
62+
Next, fill in the **Group Id**, **Artifact Id**, and the **Package Base**.
6363

64-
* The **Package Base** value (`com.sample.adaptor` on this page) will be used as a base package for your server code.
64+
* The **Package Base** value (`com.sample.adaptor` on this page) will be used as a base package for the server code.
6565

6666
![](./images/CreateMavenAdaptorProject_Step3.png)
6767

68-
You should now have the project in Eclipse and the following folder structure:
68+
The project is now available in Eclipse with the following folder structure:
6969

7070
![](./images/CreateMavenAdaptorProject_CodeStructure.png)
7171

7272
## Customise the project POM file
7373

74-
We now need to modify the project *pom.xml* file.
74+
Modify the project `pom.xml` file.
7575

7676
### Set up general POM properties
7777

78-
We will also use properties to define a common version for Lyo packages:
78+
Use properties to define a common version for Lyo packages:
7979

8080
```xml
8181
<properties>
@@ -89,9 +89,9 @@ We will also use properties to define a common version for Lyo packages:
8989

9090
### (Optional) Add Lyo repositories
9191

92-
Lyo release artefacts are on Maven central since 4.0.0 - no action needed from your side.
92+
Lyo release artefacts are on Maven central since 4.0.0 - no action needed.
9393

94-
If you wish to use the latest development snapshots, you will need the following entry:
94+
If using the latest development snapshots is required, the following entry is needed:
9595

9696
```xml
9797
<repositories>
@@ -111,7 +111,7 @@ If you wish to use the latest development snapshots, you will need the following
111111

112112
### SLF4J package dependencies
113113

114-
Lyo uses SLF4J for logging, leaving the choice of the actual logging library to use. We will use the simplest option:
114+
Lyo uses SLF4J for logging, leaving the choice of the actual logging library to use. The simplest option:
115115

116116
```xml
117117
<dependency>
@@ -124,7 +124,7 @@ Lyo uses SLF4J for logging, leaving the choice of the actual logging library to
124124

125125
### Servlet dependencies
126126

127-
We require Java EE 6 or higher and JSTL:
127+
Java EE 6 or higher and JSTL are required:
128128

129129
```xml
130130
<dependency>
@@ -146,7 +146,10 @@ Lyo depends on JAX-RS APIs and your application needs to add implementations of
146146

147147
#### For Lyo 5.x
148148

149-
For Lyo release 5.0.0 and above, you will need to choose a JAX-RS 2.0 implementation. If you are using Jersey, you should use version 2.35. *Note that starting with Jersey 2.26, HK2 is not bundled with the core artefacts (see the [Jersey migration guide](https://eclipse-ee4j.github.io/jersey.github.io/documentation/2.35/user-guide.html#mig-2.26)).*
149+
For Lyo release 5.0.0 and above, choose a JAX-RS 2.0 implementation. If using Jersey, use version 2.35.
150+
151+
!!! note
152+
Starting with Jersey 2.26, HK2 is not bundled with the core artefacts (see the [Jersey migration guide](https://eclipse-ee4j.github.io/jersey.github.io/documentation/2.35/user-guide.html#mig-2.26)).
150153

151154
```xml
152155
<dependency>
@@ -211,7 +214,7 @@ If your server needs to support OAuth, include the following:
211214
</dependency>
212215
```
213216

214-
To support OAuth, you will need to add the following JAX-RS Providers to your Application (the `javax.ws.rs.core.Application` subclass):
217+
To support OAuth, add the following JAX-RS Providers to the Application (the `javax.ws.rs.core.Application` subclass):
215218

216219
```java
217220
RESOURCE_CLASSES.add(Class.forName("org.eclipse.lyo.server.oauth.webapp.services.ConsumersService"));
@@ -233,14 +236,14 @@ If your OSLC server also needs to consume resources from another server, a depen
233236

234237
### Configure the Embedded Jetty server for quick debugging
235238

236-
Finally, you should use an embedded servlet container during the debugging to simplify the development process.
239+
Finally, use an embedded servlet container during the debugging to simplify the development process.
237240

238241
Replace the existing `<build>` entry with the Jetty configuration below, using the following customisations:
239242

240-
* *adaptor-sample* is the context path that can be the same as your eclipse project name (or something more appropriate)
241-
* *8080* is the port number you want to run the services on.
243+
* `adaptor-sample` is the context path that can be the same as the eclipse project name (or something more appropriate)
244+
* `8080` is the port number to run the services on.
242245

243-
This will make your server available under the path http://localhost:8080/adaptor-sample.
246+
This will make the server available under the path http://localhost:8080/adaptor-sample.
244247

245248
```xml
246249
<build>
@@ -273,9 +276,9 @@ This will make your server available under the path http://localhost:8080/adapto
273276

274277
Modify the parameters in `/src/main/webapp/WEB-INF/web.xml` according to the template below.
275278

276-
* *Adaptor Sample* could be the same as your eclipse project name (or something more appropriate).
277-
* *com.sample.adaptor* should be the same as the base package name for your project.
278-
* *8080* should match the port number specified in the POM file for Jetty configuration.
279+
* `Adaptor Sample` could be the same as the eclipse project name (or something more appropriate).
280+
* `com.sample.adaptor` should be the same as the base package name for the project.
281+
* `8080` should match the port number specified in the POM file for Jetty configuration.
279282

280283
```xml
281284
<?xml version="1.0" encoding="UTF-8"?>
@@ -317,11 +320,11 @@ The instructions below are based on [Swagger Core JAX RS Project Setup 1.5.X](ht
317320

318321
### Add OpenApi/Swagger Maven dependencies
319322

320-
Add the following Swagger dependency to your maven pom.xml file.
323+
Add the following Swagger dependency to the maven pom.xml file.
321324

322325
#### For Lyo 5.0.0
323326

324-
Assuming you are adopting the Jersey implementation with the version specified above.
327+
Assuming the Jersey implementation is adopted with the version specified above.
325328

326329
```xml
327330
<dependency>
@@ -343,11 +346,11 @@ Assuming you are adopting the Jersey implementation with the version specified a
343346
</dependency>
344347
```
345348

346-
### Co-host Swagger UI with your server
349+
### Co-host Swagger UI with the server
347350

348-
The following steps provide the end-user with an interactive console to the OSLC services, by integrating [Swagger UI](https://swagger.io/swagger-ui/) with your OSLC server.
351+
The following steps provide the end-user with an interactive console to the OSLC services, by integrating [Swagger UI](https://swagger.io/swagger-ui/) with the OSLC server.
349352

350-
Add the following plugins to the existing `<plugins>` entry of your `pom.xml` file. These plugins download and extract the necessary `Swagger UI` files from [Swagger UI GitHub project](https://github.com/swagger-api/swagger-ui) onto your project:
353+
Add the following plugins to the existing `<plugins>` entry of the `pom.xml` file. These plugins download and extract the necessary `Swagger UI` files from [Swagger UI GitHub project](https://github.com/swagger-api/swagger-ui) onto the project:
351354

352355
```xml
353356
<build>
@@ -419,9 +422,9 @@ public class Application extends javax.ws.rs.core.Application {
419422

420423
### Configure Swagger's Servlet in the web.xml
421424
422-
Add the following to your web.xml:
425+
Add the following to the `web.xml`:
423426
424-
* *swagger.api.basepath* depends on your particular settings, as instructed above.
427+
* `swagger.api.basepath` depends on the particular settings, as instructed above.
425428
426429
```xml
427430
<servlet>
@@ -446,7 +449,7 @@ The OpenApi documentation can be achieved with as little as adding `@Api` to eac
446449
#### `@Api`
447450
448451
1. For each REST service (i.e. OSLC Service), simply add the `@Api` annotation.
449-
1. (*OPTIONAL*) add the *value* and *description* details. The *value* is used to group the REST methods into common categories, helping in the structuring of the methods in the documentation. You can give it the same value as that of the @Path annotation, collecting all REST methods for the same service together.
452+
1. (*OPTIONAL*) add the `value` and `description` details. The `value` is used to group the REST methods into common categories, helping in the structuring of the methods in the documentation. You can give it the same value as that of the @Path annotation, collecting all REST methods for the same service together.
450453
451454
```java
452455
@Api(value = "requirements", description = "OSLC service for resources of type" + "Requirement")
@@ -464,7 +467,7 @@ For each REST method, add the `@ApiOperation` Swagger annotation.
464467
!!! example
465468
If your OSLC Service defines separate Java methods to handle HTML and RDF/XML content types for the same path and HTTP method, OpenApi will only recognise one of these methods and ignore the other.
466469
467-
**Workaround:** Annotate ALL methods that are identified as unique with the complete list of media types in the *produces* property of the `@ApiOperation` annotation. This way, the generated documentation correctly indicates the existence of all methods.
470+
**Workaround:** Annotate ALL methods that are identified as unique with the complete list of media types in the `produces` property of the `@ApiOperation` annotation. This way, the generated documentation correctly indicates the existence of all methods.
468471
469472
```java
470473
@GET
@@ -490,7 +493,7 @@ public class Requirement
490493
491494
### Access the Swagger UI interactive console
492495
493-
Before you can access the [Swagger UI](https://swagger.io/swagger-ui/) interactive console for the first time, edit the `swagger-ui/index.html` file, replacing the url `http://petstore.swagger.io/v2/swagger.json` with the url of your own yaml file `http://localhost:8080/adaptor-sample/services/swagger.yaml`.
496+
Before accessing the [Swagger UI](https://swagger.io/swagger-ui/) interactive console for the first time, edit the `swagger-ui/index.html` file, replacing the url `http://petstore.swagger.io/v2/swagger.json` with the URL of the YAML file `http://localhost:8080/adaptor-sample/services/swagger.yaml`.
494497
495498
The generated interactive API console can be accessed via:
496499
@@ -562,7 +565,7 @@ public class Application extends javax.ws.rs.core.Application {
562565
}
563566
```
564567
565-
Define the `InmemPagedTrsSingleton` singleton class. You will need to complete the code example below, with:
568+
Define the `InmemPagedTrsSingleton` singleton class. Complete the code example below, with:
566569
* the code that populates `uris` with the initial set of resources to be managed by `InmemPagedTrs`;
567570
* the desired `basePageLimit` and `changelogPageLimit` parameters.
568571
@@ -618,18 +621,16 @@ The application is now ready to respond to REST requests from a TRS Client. Once
618621
619622
### Update the TRS data set
620623
621-
To update the set of OSLC resources that form the TRS Base and ChangeLog, simply call the following methods in your code:
624+
To update the set of OSLC resources that form the TRS Base and ChangeLog, call the following methods in the code:
622625
623626
* `InmemPagedTrsSingleton.getInmemPagedTrs().onCreated(aResource);`
624627
* `InmemPagedTrsSingleton.getInmemPagedTrs().onModified(aResource);`
625628
* `InmemPagedTrsSingleton.getInmemPagedTrs().onDeleted(aResource.getAbout());`
626629
627630
## Run the server
628631
629-
Once the server is developed, you can run it by selecting *Run As ➞ Maven build ...* from the project's context menu, and setting the goal to `clean jetty:run-war`.
630-
631-
You can now access your server from http://localhost:8080/adaptor-sample.
632+
Once the server is developed, run it by selecting **Run As ➞ Maven build ...** from the project's context menu, and setting the goal to `clean jetty:run-war`.
632633

633-
* *adaptor-sample* and *8080* will depend on your particular settings, as instructed above.
634+
Access the server from [http://localhost:8080/adaptor-sample](http://localhost:8080/adaptor-sample) (`adaptor-sample` and `8080` will depend on the particular settings, as instructed above).
634635

635-
> **Pro Tip:** If you get the error *Project configuration is not up-to-date with pom.xml*, simply right click on the eclipse project and select *MavenUpdate Project* ...
636+
> **Pro Tip:** If the error `Project configuration is not up-to-date with pom.xml` occurs, right click on the eclipse project and select **MavenUpdate Project** ...

0 commit comments

Comments
 (0)