Skip to content

Commit

Permalink
[WFLY-19618] Helloworld REST Quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin-rh committed Oct 29, 2024
1 parent f5d53f4 commit 6bc712c
Show file tree
Hide file tree
Showing 10 changed files with 401 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/workflows/quickstart_helloworld-rs_ci.yml
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
1 change: 1 addition & 0 deletions README-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ NOTE: Some of these quickstarts use the H2 database included with {productNameFu
| link:helloworld-mdb/README{outfilesuffix}[helloworld-mdb]|JMS, EJB, MDB | Yes | The `helloworld-mdb` quickstart uses JMS and EJB Message-Driven Bean (MDB) to create and deploy JMS topic and queue resources in {productName}. | Intermediate | _none_
| link:helloworld-mutual-ssl/README{outfilesuffix}[helloworld-mutual-ssl]|Mutual TLS, Undertow | No | The `helloworld-mutual-ssl` quickstart is a basic example that demonstrates mutual TLS configuration in {productName} | Intermediate | _none_
| link:helloworld-mutual-ssl-secured/README{outfilesuffix}[helloworld-mutual-ssl-secured]|Mutual TLS, Security, Undertow | No | The `helloworld-mutual-ssl-secured` quickstart demonstrates securing a Web application using client certificate authentication with authorization | Intermediate | _none_
| link:helloworld-rs/README{outfilesuffix}[helloworld-rs]|Jakarta RESTful Web Services | No | The `helloworld-rs` quickstart demonstrates the use of Jakarta RESTful Web Services. | Begginer | _none_
| link:helloworld-singleton/README{outfilesuffix}[helloworld-singleton]|EJB, Singleton | Yes | The `helloworld-singleton` quickstart demonstrates an EJB Singleton Bean that is instantiated once and maintains state for the life of the session. | Beginner | _none_
| link:helloworld-ws/README{outfilesuffix}[helloworld-ws]|JAX-WS | Yes | The `helloworld-ws` quickstart demonstrates a simple Hello World application, bundled and deployed as a WAR, that uses JAX-WS to say Hello. | Beginner | _none_
| link:hibernate/README{outfilesuffix}[hibernate]|Hibernate | Yes | The `hibernate` quickstart demonstrates how to use Hibernate ORM 6 over Persistence, using Bean Validation, and Enterprise Beans. | Intermediate | _none_
Expand Down
51 changes: 51 additions & 0 deletions helloworld-rs/README-source.adoc
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::[]
6 changes: 6 additions & 0 deletions helloworld-rs/charts/helm.yaml
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
219 changes: 219 additions & 0 deletions helloworld-rs/pom.xml
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>35.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.Final</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>
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.helloworld.rest;

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!";
}
}
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.helloworld.rest;

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
}
10 changes: 10 additions & 0 deletions helloworld-rs/src/main/webapp/index.html
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>
Loading

0 comments on commit 6bc712c

Please sign in to comment.