-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-19618] Helloworld REST Quickstart
- Loading branch information
Showing
10 changed files
with
401 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: WildFly helloworld-rs Quickstart CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
paths: | ||
- 'helloworld-rs/**' | ||
- '.github/workflows/quickstart_ci.yml' | ||
jobs: | ||
call-quickstart_ci: | ||
uses: ./.github/workflows/quickstart_ci.yml | ||
with: | ||
QUICKSTART_PATH: helloworld-rs | ||
TEST_PROVISIONED_SERVER: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
include::../shared-doc/attributes.adoc[] | ||
|
||
= helloworld-rs: Jakarta RESTful Web Services Helloworld Example | ||
:author: Ashwin Mehendale | ||
:level: Beginner | ||
:technologies: Jakarta RESTful Web Services | ||
:openshift: true | ||
:portedToGlow: true | ||
|
||
[abstract] | ||
The `helloworld-rs` quickstart demonstrates the use of Jakarta RESTful Web Services. | ||
|
||
:standalone-server-type: default | ||
:archiveType: war | ||
|
||
== What is it? | ||
|
||
The `helloworld-rs` quickstart demonstrates the use of _Jakarta RESTful Web Services_ in {productNameFull} {productVersion}. | ||
|
||
// Link to the quickstart source | ||
include::../shared-doc/view-the-source.adoc[leveloffset=+1] | ||
// System Requirements | ||
include::../shared-doc/system-requirements.adoc[leveloffset=+1] | ||
// Use of {jbossHomeName} | ||
include::../shared-doc/use-of-jboss-home-name.adoc[leveloffset=+1] | ||
|
||
// build and run with standard server distribution | ||
[[build_and_run_the_quickstart_with_server_dist]] | ||
== Building and running the quickstart application with a {productName} server distribution | ||
// Start the {productName} Standalone Server | ||
include::../shared-doc/start-the-standalone-server.adoc[leveloffset=+2] | ||
// Build and Deploy the Quickstart | ||
include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+2] | ||
|
||
=== Access the Application | ||
The application will be running at the following URL: http://localhost:8080/{artifactId}/. | ||
|
||
// Server Distribution Testing | ||
include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2] | ||
// Undeploy the Quickstart | ||
include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] | ||
|
||
// Build and run sections for other environments/builds | ||
ifndef::ProductRelease,EAPXPRelease[] | ||
include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] | ||
endif::[] | ||
include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] | ||
ifndef::ProductRelease,EAPXPRelease[] | ||
//Kubernetes | ||
include::../shared-doc/build-and-run-the-quickstart-with-kubernetes.adoc[leveloffset=+1] | ||
endif::[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build: | ||
uri: https://github.com/wildfly/quickstart.git | ||
ref: main | ||
contextDir: helloworld-rs | ||
deploy: | ||
replicas: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<!-- | ||
Copyright The WildFly Authors | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.wildfly.quickstarts</groupId> | ||
<artifactId>wildfly-quickstart-parent</artifactId> | ||
<!-- | ||
Maintain separation between the artifact id and the version to help prevent | ||
merge conflicts between commits changing the GA and those changing the V. | ||
--> | ||
<version>8</version> | ||
<relativePath/> | ||
</parent> | ||
<artifactId>helloworld-rs</artifactId> | ||
<version>34.0.0.Beta1-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
<name>Quickstart: helloworld-rs</name> | ||
<description>A simple Hello World project that uses Jakarta RESTful Web Services</description> | ||
|
||
<licenses> | ||
<license> | ||
<name>Apache License, Version 2.0</name> | ||
<distribution>repo</distribution> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<!-- the version for the Server --> | ||
<version.server>34.0.0.Beta1</version.server> | ||
<!-- the versions for BOMs, Packs and Plugins --> | ||
<version.bom.ee>${version.server}</version.bom.ee> | ||
<version.plugin.wildfly>5.0.0.Final</version.plugin.wildfly> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<!-- importing the ee-with-tools BOM adds specs and other useful artifacts as managed dependencies --> | ||
<dependency> | ||
<groupId>org.wildfly.bom</groupId> | ||
<artifactId>wildfly-ee-with-tools</artifactId> | ||
<version>${version.bom.ee}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- Import the Jakarta REST API, we use provided scope as the API is included in the server --> | ||
<dependency> | ||
<groupId>jakarta.ws.rs</groupId> | ||
<artifactId>jakarta.ws.rs-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Tests --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-client</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- resteasy client needs commons-logging yet the server uses this instead, | ||
to be fully compatible on apps we need to add this dependency whenever commons-logging is needed, | ||
but on testing clients like this we could use commons-logging instead --> | ||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>commons-logging-jboss-logging</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-json-p-provider</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Required by the resteasy-json-p-provider --> | ||
<dependency> | ||
<groupId>org.eclipse.parsson</groupId> | ||
<artifactId>parsson</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.wildfly.plugins</groupId> | ||
<artifactId>wildfly-maven-plugin</artifactId> | ||
<version>${version.plugin.wildfly}</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>provisioned-server</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.wildfly.plugins</groupId> | ||
<artifactId>wildfly-maven-plugin</artifactId> | ||
<configuration> | ||
<discover-provisioning-info> | ||
<version>${version.server}</version> | ||
</discover-provisioning-info> | ||
<!-- | ||
Rename the output war to ROOT.war before adding it to the server, so that the | ||
application is deployed in the root web context. | ||
--> | ||
<name>ROOT.war</name> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>openshift</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.wildfly.plugins</groupId> | ||
<artifactId>wildfly-maven-plugin</artifactId> | ||
<configuration> | ||
<discover-provisioning-info> | ||
<version>${version.server}</version> | ||
<context>cloud</context> | ||
</discover-provisioning-info> | ||
<!-- | ||
The parent POM's 'openshift' profile renames the output archive to ROOT.war so that the | ||
application is deployed in the root web context. Add ROOT.war to the server. | ||
--> | ||
<filename>ROOT.war</filename> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>integration-testing</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<includes> | ||
<include>**/RESTEndPointIT</include> | ||
</includes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jboss-public-maven-repository</id> | ||
<name>JBoss Public Maven Repository</name> | ||
<url>https://repository.jboss.org/nexus/content/groups/public/</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
<updatePolicy>never</updatePolicy> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
<updatePolicy>never</updatePolicy> | ||
</snapshots> | ||
<layout>default</layout> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>jboss-public-maven-repository</id> | ||
<name>JBoss Public Maven Repository</name> | ||
<url>https://repository.jboss.org/nexus/content/groups/public/</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
helloworld-rs/src/main/java/org/jboss/as/quickstarts/helloworldrs/HelloWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.jboss.as.quickstarts.rshelloworld; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
/** | ||
* A simple REST service which is able to say "Hello World!" | ||
* | ||
* @author Ashwin Mehendale | ||
* @author emartins | ||
*/ | ||
|
||
@Path("/") | ||
public class HelloWorld { | ||
|
||
@GET | ||
@Path("/HelloWorld") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "Hello World!"; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
helloworld-rs/src/main/java/org/jboss/as/quickstarts/helloworldrs/JakartaRESTActivator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.jboss.as.quickstarts.rshelloworld; | ||
|
||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
|
||
/** | ||
* JakartaRESTActivator is an arbitrary name, what is important is that jakarta.ws.rs.core.Application is extended | ||
* and the @ApplicationPath annotation is used with a "rest" path. Without this the rest endpoints linked to | ||
* from index.html would not be found. | ||
*/ | ||
@ApplicationPath("rest") | ||
public class JakartaRESTActivator extends Application { | ||
// Left empty intentionally | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- | ||
Copyright The WildFly Authors | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<html> | ||
<head> | ||
<meta http-equiv="Refresh" content="0; URL=rest/HelloWorld"> | ||
</head> | ||
</html> |
Oops, something went wrong.