8000 Restful-ws jakarta ee9 namespace support by abutch3r · Pull Request #469 · cloudevents/sdk-java · GitHub
[go: up one dir, main page]

Skip to content

Restful-ws jakarta ee9 namespace support #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c9aa867
Initial commit - replace javax restful-ws namespace usage with jakara…
abutch3r Aug 19, 2022
af0483c
update gitignore to cover all copied directories
abutch3r Aug 19, 2022
d564b9e
Update Jersey Version to support jakarta.* namespace packages
abutch3r Sep 12, 2022
a5f4ba3
Undo changes to existing integration test package names
abutch3r Sep 12, 2022
7124971
Add Integration test for Microprofile/Liberty for Jee9 package
abutch3r Sep 16, 2022
8e52f7d
Add documentation for new Jakarta package
abutch3r Sep 20, 2022
79a9290
Support dynamic JSON data content type (#471)
segator Sep 5, 2022
17db1e7
Bump to 2.5.0-SNAPSHOT (#474)
github-actions[bot] Sep 6, 2022
f56b2d7
Fix example in "Materialize an Extension" (#475)
jolivaSan Sep 14, 2022
98dd3b7
Correct URL to naming-conventions (#477)
gklijs Sep 14, 2022
4f40b0c
Fix typo in word Covert (#480)
VikramVuppla Sep 19, 2022
b410cb9
Update new package version to match new version
abutch3r Sep 21, 2022
de32e18
Initial commit - replace javax restful-ws namespace usage with jakara…
abutch3r Aug 19, 2022
837ff89
update gitignore to cover all copied directories
abutch3r Aug 19, 2022
31e2b6c
Update Jersey Version to support jakarta.* namespace packages
abutch3r Sep 12, 2022
b7d4d81
Undo changes to existing integration test package names
abutch3r Sep 12, 2022
e0df551
Add Integration test for Microprofile/Liberty for Jee9 package
abutch3r Sep 16, 2022
455ccdd
Add documentation for new Jakarta package
abutch3r Sep 20, 2022
6500b84
Update new package version to match new version
abutch3r Sep 21, 2022
ffcb1e3
Merge branch '468-restful-ws-jakarta-ee9-support' of https://github.c…
abutch3r Sep 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Initial commit - replace javax restful-ws namespace usage with jakara…
…ta in own module

Add microprofile with openliberty example using new jar

Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com>
  • Loading branch information
abutch3r committed Sep 23, 2022
commit de32e18974b6289758bdbfe81f27d462d620a7ca
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ _site/

# MacOS
*.DS_Store
/http/restful-ws-jakarta/src/main/java/
1 change: 1 addition & 0 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<modules>
<module>kafka</module>
<module>restful-ws-quarkus</module>
<module>restful-ws-microprofile-ee9</module>
<module>vertx</module>
<module>basic-http</module>
<module>restful-ws-spring-boot</module>
Expand Down
140 changes: 140 additions & 0 deletions examples/restful-ws-microprofile-ee9/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Cloudevents Restful WS Microprofile Example

This project uses Microprofile 5.0 with OpenLiberty

If you would like to know more about Microprofile go to https://microprofile.io

This Example uses Jakarta EE9 features as such the top level namespace of the `ws-api` packages has changed from `javax` to `jakarta` and uses the `cloudevents-http-restful-ws-ee9` artifact.

## Build and Execution

### Running the application in dev mode

You can run your application in dev mode that enables live coding using:
```
mvn liberty:dev
```

### Packaging and running the application

To Package and run as a minimum jar without a full OpenLiberty server
```
mvn liberty:package -Drunnable=mvn liberty:package -Dinclude=runnable
```

### Making requests against the server

This sample application has a `/events` RESTful endpoint on the application `cloudevents-restful-ws-microprofile-example
the base application is available at `http://localhost:9080/cloudevents-restful-ws-microprofile-example/`

There are three operations that can be performed:
#### GET /events
Returns a Cloud event with a payload containing a message

```shell
curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events

* Trying 127.0.0.1:9080...
* Connected to localhost (127.0.0.1) port 9080 (#0)
> GET /cloudevents-restful-ws-microprofile-example/events HTTP/1.1
> Host: localhost:9080
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 201 no-content
< Ce-Id: hello
< Ce-Source: http://localhost
< Ce-Specversion: 1.0
< Ce-Type: example.http
< Content-Type: application/json
< Content-Language: en-GB
< Content-Length: 64
< Date: Wed, 17 Aug 2022 14:01:50 GMT
<
{"message":"Welcome to this Cloudevents + Microprofile example"}
```

#### POST /events
POST a Cloudevent with a payload that is printed out in the server logs

```shell
curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events \
-H "Ce-Specversion: 1.0" \
-H "Ce-Type: User" \
-H "Ce-Source: io.cloudevents.examples/user" \
-H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78" \
-H "Content-Type: application/json" \
-H "Ce-Subject: SUBJ-0001" \
-d "hello"

* Trying 127.0.0.1:9080...
* Connected to localhost (127.0.0.1) port 9080 (#0)
> POST /cloudevents-restful-ws-microprofile-example/events HTTP/1.1
> Host: localhost:9080
> User-Agent: curl/7.83.1
> Accept: */*
> Ce-Specversion: 1.0
> Ce-Type: User
> Ce-Source: io.cloudevents.examples/user
> Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78
> Content-Type: application/json
> Ce-Subject: SUBJ-0001
> Content-Length: 5
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 204 No Content
< Content-Language: en-GB
< Content-Length: 0
< Date: Thu, 18 Aug 2022 13:33:03 GMT
<
* Connection #0 to host localhost left intact
```
Server log statement
```
[INFO] Received request providing a event with body hello
[INFO] CloudEvent{id='536808d3-88be-4077-9d7a-a3f162705f78', source=io.cloudevents.examples/user, type='User', datacontenttype='application/json', subject='SUBJ-0001', data=BytesCloudEventData{value=[104, 101, 108, 108, 111]}, extensions={}}
```

#### POST /events/echo
POST a Cloudevent with a payload and have it echoed back as a Cloudevent

```shell
curl -v http://localhost:9080/cloudevents-restful-ws-microprofile-example/events/echo \
-H "Ce-Specversion: 1.0" \
6293 -H "Ce-Type: User" \
-H "Ce-Source: io.cloudevents.examples/user" \
-H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78" \
-H "Content-Type: application/json" \
-H "Ce-Subject: SUBJ-0001" \
-d "hello"

* Trying 127.0.0.1:9080...
* Connected to localhost (127.0.0.1) port 9080 (#0)
> POST /cloudevents-restful-ws-microprofile-example/rest/events/echo HTTP/1.1
> Host: localhost:9080
> User-Agent: curl/7.83.1
> Accept: */*
> Ce-Specversion: 1.0
> Ce-Type: User
> Ce-Source: io.cloudevents.examples/user
> Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78
> Content-Type: application/json
> Ce-Subject: SUBJ-0001
> Content-Length: 5
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Ce-Id: echo
< Ce-Source: http://localhost
< Ce-Specversion: 1.0
< Ce-Type: echo.http
< Content-Type: application/json
< Content-Language: en-GB
< Content-Length: 17
< Date: Wed, 17 Aug 2022 12:57:59 GMT
<
{"echo": "hello"}* Connection #0 to host localhost left intact
```


184 changes: 184 additions & 0 deletions examples/restful-ws-microprofile-ee9/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>cloudevents-examples</artifactId>
<groupId>io.cloudevents</groupId>
<version>2.4.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloudevents-restful-ws-microprofile-example</artifactId>
<packaging>war</packaging>

<properties>
<openliberty.maven.version>3.5.1</openliberty.maven.version>
<app.name>cloudevents-microprofile</app.name>

<!-- Liberty server properties -->
<final.name>cloudeventsServer</final.name>
<testServerHttpPort>9080</testServerHttpPort>
<testServerHttpsPort>9443</testServerHttpsPort>
<!--This is set in the ibm-web-ext.xml file -->
<warContext>cloudeventsexperiments</warContext>
<package.file>${project.build.directory}/${app.name}.zip</package.file>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<profiles>
<profile>
<id>runnable</id>
<properties>
<package.file>${project.build.directory}/${app.name}.jar</package.file>
<packaging.type>runnable</packaging.type>
</properties>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>5.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-restful-ws-ee9</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.21</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>pom.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-server-files</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>server-snippet</includeArtifactIds>
<prependGroupId>true</prependGroupId>
<outputDirectory>
${project.build.directory}/wlp/usr/servers/${wlpServerName}/configDropins/defaults
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-app</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/wlp/usr/servers/${wlpServerName}/dropins
</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>${project.artifactId}-${project.version}.war</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Enable liberty-maven plugin -->
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>${openliberty.maven.version}</version>
<executions>
<execution>
<id>package-server</id>
<phase>package</phase>
<goals>
<goal>create</goal>
<goal>install-feature</goal>
<goal>deploy</goal>
<goal>package</goal>
</goals>
<configuration>
<outputDirectory>target/wlp-package</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<include>runnable</include>
<serverName>${final.name}</serverName>
<bootstrapProperties>
<project.name>${final.name}</project.name>
<jwt.issuer>https://server.example.com</jwt.issuer>
<app.context.root>/</app.context.root>
</bootstrapProperties>
</configuration>
</plugin>

<!-- Plugin to run functional tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<phase>integration-test</phase>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/it/**</include>
</includes>
<systemPropertyVariables>
<liberty.test.port>${testServerHttpPort}</liberty.test.port>
<war.name>${warContext}</war.name>
<running.bluemix>${running.bluemix}</running.bluemix>
<cf.context.root>${cf.context.root}</cf.context.root>
</systemPropertyVariables>
</configuration>
</execution>
<execution>
<id>verify-results</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<summaryFile>${project.build.directory}/test-reports/it/failsafe-summary.xml</summaryFile>
<reportsDirectory>${project.build.directory}/test-reports/it</reportsDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.cloudevents.examples.microprofile;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("/")
public class CloudEventsApplication extends Application {

}
Loading
0