Examples reorg: first pass (#270)

* Examples reorganization first pass
This commit is contained in:
Joe DiPol
2018-12-21 16:00:38 -08:00
committed by GitHub
parent 26457e05f0
commit be05579ed6
405 changed files with 686 additions and 303 deletions

View File

@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<groupId>io.helidon.config.examples</groupId>
<artifactId>helidon-config-examples-project</artifactId>
<packaging>pom</packaging>
<name>Helidon Config Examples</name>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.sources.skip>true</maven.sources.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<spotbugs.skip>true</spotbugs.skip>
</properties>
<modules>
<module>basics</module>
<module>changes</module>
<module>git</module>
<module>mapping</module>
<module>overrides</module>
<module>sources</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<longClasspath>true</longClasspath>
<arguments>
<argument>-enableassertions</argument>
<argument>-Djava.util.logging.config.file=src/main/resources/logging.properties</argument>
<argument>-classpath</argument>
<classpath/>
<argument>${example.mainClass}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@@ -42,7 +42,6 @@
<module>etcd</module>
<module>git</module>
<module>hocon</module>
<module>examples</module>
<module>testing</module>
<module>test-infrastructure</module>
<module>tests</module>

View File

@@ -33,6 +33,7 @@ jaxb.index
.p8
.pkcs8.pem
.p12
.bin
src/main/proto/
src/test/resources/keystore/
conf/secrets/
@@ -41,4 +42,3 @@ empty_file
copyright-exclude.txt
src/test/resources/sample.txt
src/main/resources/WEB/node
webserver/examples/streaming/src/main/resources/large-file.bin

View File

@@ -49,4 +49,4 @@ mvn -f ${WS_DIR}/pom.xml \
clean install \
-Pexamples,integrations,spotbugs,javadoc,docs,sources,ossrh-releases,tck
examples/archetypes/test-archetypes.sh
examples/quickstarts/archetypes/test-archetypes.sh

57
examples/README.md Normal file
View File

@@ -0,0 +1,57 @@
<p align="center">
<img src="../etc/images/Primary_logo_blue.png" height="180">
</p>
# Helidon Examples
Welcome to the Helidon Examples! If this is your first experience with
Helidon we recommend you start with our
[quickstart](https://helidon.io/docs/latest/#/getting-started/02_base-example).
That will quickly get you going with your first Helidon application.
After that you can come back here and dig into the examples. To access
these examples we recommend checking out from a released tag. For example:
```
git clone git@github.com:oracle/helidon.git
cd helidon
git checkout tags/0.10.5
```
Our examples are Maven projects and can be built and run with
Java 8 or Java 11 -- so make sure you have those:
```
java -version
mvn -version
```
# Building an Example
Each example has a `README` that you will follow. To build most examples
just `cd` to the directory and run `mvn package`:
```
cd examples/microprofile/hello-world-explicit
mvn package
```
Usually you can then run the example using:
```
mvn exec:java
```
But always see the example's `README` for details.
# Examples
|Directory | Description |
|:------------------------------|:-------------|
| config | Helidon SE config examples |
| security | Helidon SE security examples |
| webserver | Helidon SE webserver examples |
| microprofile | Helidon MP examples |
| quickstarts | Quickstart examples. These are the same examples used by the Helidon quickstart archetypes |
| integrations | CDI extensions examples. |
| todo-app | A more complex example consisting of front end and back end services |

View File

@@ -0,0 +1,4 @@
# Helidon SE Config Examples

View File

@@ -0,0 +1,19 @@
# Helidon Config Basic Example
This example shows the basics of using Helidon SE Config:
* Loading configuration from `application.conf`
* Getting configuration values of various types
## Build
```
mvn package
```
## Run
```
mvn exec:java
```

View File

@@ -21,11 +21,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.config.examples</groupId>
<artifactId>helidon-config-examples-project</artifactId>
<groupId>io.helidon.examples.config</groupId>
<artifactId>helidon-examples-config-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-config-examples-basics</artifactId>
<artifactId>helidon-examples-config-basics</artifactId>
<name>Helidon Config Examples Basics</name>
<description>
@@ -34,7 +34,7 @@
<properties>
<helidon.version>0.11.0-SNAPSHOT</helidon.version>
<example.mainClass>io.helidon.config.examples.basics.Main</example.mainClass>
<mainClass>io.helidon.config.examples.basics.Main</mainClass>
</properties>
<dependencies>

View File

@@ -0,0 +1,17 @@
# Helidon Config Changes Example
This example shows how an application can detect changes to its
configuration.
## Build
```
mvn package
```
## Run
```
mvn exec:java
```

View File

@@ -22,11 +22,11 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>helidon-config-examples-project</artifactId>
<groupId>io.helidon.config.examples</groupId>
<groupId>io.helidon.examples.config</groupId>
<artifactId>helidon-examples-config-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-config-examples-changes</artifactId>
<artifactId>helidon-examples-config-changes</artifactId>
<name>Helidon Config Examples Changes</name>
<description>
@@ -35,7 +35,7 @@
<properties>
<helidon.version>0.11.0-SNAPSHOT</helidon.version>
<example.mainClass>io.helidon.config.examples.changes.Main</example.mainClass>
<mainClass>io.helidon.config.examples.changes.Main</mainClass>
</properties>
<dependencies>

View File

@@ -0,0 +1,21 @@
# Helidon Config Git Example
This example shows how to load configuration from a Git repository
and switch which branch to load from at runtime.
## Build
```
mvn package
```
## Run
```
export ENVIRONMENT_NAME=test
mvn exec:java
```
Note that the application determines which Git branch to load from
based on the `ENVIRONMENT_NAME` environment variable.

View File

@@ -21,11 +21,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.config.examples</groupId>
<artifactId>helidon-config-examples-project</artifactId>
<groupId>io.helidon.examples.config</groupId>
<artifactId>helidon-examples-config-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-config-examples-git</artifactId>
<artifactId>helidon-examples-config-git</artifactId>
<name>Helidon Config Examples Git</name>
<description>
The example shows how to use GitConfigSource.
@@ -33,7 +33,7 @@
<properties>
<helidon.version>0.11.0-SNAPSHOT</helidon.version>
<example.mainClass>io.helidon.config.examples.git.Main</example.mainClass>
<mainClass>io.helidon.config.examples.git.Main</mainClass>
</properties>
<dependencies>

View File

@@ -46,12 +46,15 @@ public class Main {
Config env = Config.create(ConfigSources.environmentVariables());
System.out.println("Loading from branch " + env.get(ENVIRONMENT_NAME_PROPERTY).asString().orElse("null"));
Config config = Config.create(
GitConfigSourceBuilder.create("application.conf")
.uri(URI.create("https://github.com/okosatka/test-config.git"))
.branch(env.get(ENVIRONMENT_NAME_PROPERTY).asString().orElse("master"))
.build());
System.out.println("Greeting is " + config.get("greeting").asString().get());
assert config.get("greeting").asString().get().equals("hello");
}

View File

@@ -0,0 +1,18 @@
# Helidon Config Mapping Example
This example shows how to implement mappers that map configuration
to POJOs.
## Build
```
mvn package
```
## Run
```
mvn exec:java
```

View File

@@ -21,11 +21,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.config.examples</groupId>
<artifactId>helidon-config-examples-project</artifactId>
<groupId>io.helidon.examples.config</groupId>
<artifactId>helidon-examples-config-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-config-examples-mapping</artifactId>
<artifactId>helidon-examples-config-mapping</artifactId>
<name>Helidon Config Examples Mapping</name>
<description>
@@ -34,7 +34,7 @@
<properties>
<helidon.version>0.11.0-SNAPSHOT</helidon.version>
<example.mainClass>io.helidon.config.examples.mapping.Main</example.mainClass>
<mainClass>io.helidon.config.examples.mapping.Main</mainClass>
</properties>
<dependencies>

View File

@@ -0,0 +1,18 @@
# Helidon Config Overrides Example
This example shows how to load configuration from multiple
configuration sources.
## Build
```
mvn package
```
## Run
```
mvn exec:java
```

View File

@@ -21,11 +21,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.config.examples</groupId>
<artifactId>helidon-config-examples-project</artifactId>
<groupId>io.helidon.examples.config</groupId>
<artifactId>helidon-examples-config-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-config-examples-overrides</artifactId>
<artifactId>helidon-examples-config-overrides</artifactId>
<name>Helidon Config Examples Overrides</name>
<description>
@@ -34,7 +34,7 @@
<properties>
<helidon.version>0.11.0-SNAPSHOT</helidon.version>
<example.mainClass>io.helidon.config.examples.overrides.Main</example.mainClass>
<mainClass>io.helidon.config.examples.overrides.Main</mainClass>
</properties>
<dependencies>

42
examples/config/pom.xml Normal file
View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.examples</groupId>
<artifactId>helidon-examples-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<groupId>io.helidon.examples.config</groupId>
<artifactId>helidon-examples-config-project</artifactId>
<packaging>pom</packaging>
<name>Helidon Config Examples</name>
<modules>
<module>basics</module>
<module>changes</module>
<module>git</module>
<module>mapping</module>
<module>overrides</module>
<module>sources</module>
</modules>
</project>

View File

@@ -0,0 +1,17 @@
# Helidon Config Sources Example
This example shows how to load configuration from multiple
configuration sources.
## Build
```
mvn package
```
## Run
```
mvn exec:java
```

View File

@@ -21,11 +21,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.config.examples</groupId>
<artifactId>helidon-config-examples-project</artifactId>
<groupId>io.helidon.examples.config</groupId>
<artifactId>helidon-examples-config-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-config-examples-sources</artifactId>
<artifactId>helidon-examples-config-sources</artifactId>
<name>Helidon Config Examples Sources</name>
<description>
@@ -34,7 +34,7 @@
<properties>
<helidon.version>0.11.0-SNAPSHOT</helidon.version>
<example.mainClass>io.helidon.config.examples.sources.Main</example.mainClass>
<mainClass>io.helidon.config.examples.sources.Main</mainClass>
</properties>
<dependencies>

View File

@@ -22,11 +22,11 @@
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.integrations.examples</groupId>
<artifactId>helidon-integrations-examples-project</artifactId>
<groupId>io.helidon.examples.integrations.cdi</groupId>
<artifactId>helidon-examples-integrations-cdi-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-integrations-examples-datasource-hikaricp</artifactId>
<artifactId>helidon-examples-integrations-datasource-hikaricp</artifactId>
<name>Helidon Integrations Examples DataSource/HikariCP</name>
<properties>

View File

@@ -21,11 +21,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.integrations.examples</groupId>
<artifactId>helidon-integrations-examples-project</artifactId>
<groupId>io.helidon.examples.integrations.cdi</groupId>
<artifactId>helidon-examples-integrations-cdi-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-integrations-examples-jedis</artifactId>
<artifactId>helidon-examples-integrations-jedis</artifactId>
<name>Helidon Integrations Examples Jedis</name>
<properties>

View File

@@ -21,8 +21,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.integrations.examples</groupId>
<artifactId>helidon-integrations-examples-project</artifactId>
<groupId>io.helidon.examples.integrations.cdi</groupId>
<artifactId>helidon-examples-integrations-cdi-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-integrations-examples-oci-objectstorage</artifactId>

View File

@@ -22,13 +22,12 @@
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.examples</groupId>
<artifactId>helidon-examples-project</artifactId>
<groupId>io.helidon.examples.integrations</groupId>
<artifactId>helidon-examples-integrations-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>io.helidon.integrations.examples</groupId>
<artifactId>helidon-integrations-examples-project</artifactId>
<groupId>io.helidon.examples.integrations.cdi</groupId>
<artifactId>helidon-examples-integrations-cdi-project</artifactId>
<packaging>pom</packaging>
<name>Helidon Integrations Examples</name>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.examples</groupId>
<artifactId>helidon-examples-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<groupId>io.helidon.examples.integrations</groupId>
<artifactId>helidon-examples-integrations-project</artifactId>
<name>Helidon CDI Extensions Examples</name>
<packaging>pom</packaging>
<modules>
<module>cdi</module>
</modules>
</project>

View File

@@ -0,0 +1,4 @@
# Helidon MP Examples

View File

@@ -0,0 +1,25 @@
# Helidon MP Hello World Explicit Example
This examples shows a simple application written using Helidon MP.
It is explicit because in this example you write the `main` class
and explicitly start the microprofile server.
## Build
```
mvn package
```
## Run
```
mvn exec:java
```
Then try the endpoints:
```
curl -X GET http://localhost:7001/helloworld
curl -X GET http://localhost:7001/helloworld/another
```

View File

@@ -22,17 +22,21 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.microprofile.examples</groupId>
<artifactId>examples-project</artifactId>
<groupId>io.helidon.examples.microprofile</groupId>
<artifactId>helidon-examples-microprofile-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>hello-world-explicit</artifactId>
<artifactId>helidon-examples-microprofile-hello-world-explicit</artifactId>
<name>Helidon Microprofile Examples Explicit Hello World</name>
<description>
Microprofile 1.1 example with explicit bootstrapping (Server.create(Application.class).start())
</description>
<properties>
<mainClass>io.helidon.microprofile.example.helloworld.explicit.Main</mainClass>
</properties>
<dependencies>
<dependency>
<groupId>io.helidon.microprofile.bundles</groupId>

View File

@@ -0,0 +1,25 @@
# Helidon MP Hello World Implicit Example
This examples shows a simple application written using Helidon MP.
It is implicit because in this example you don't write the
`main` class, instead you rely on the Microprofile Server main class.
## Build
```
mvn package
```
## Run
```
mvn exec:java
```
Then try the endpoints:
```
curl -X GET http://localhost:7001/helloworld
curl -X GET http://localhost:7001/helloworld/another
```

View File

@@ -22,11 +22,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.microprofile.examples</groupId>
<artifactId>examples-project</artifactId>
<groupId>io.helidon.examples.microprofile</groupId>
<artifactId>helidon-examples-microprofile-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>hello-world-implicit</artifactId>
<artifactId>helidon-examples-microprofile-hello-world-implicit</artifactId>
<name>Helidon Microprofile Examples Implicit Hello World</name>
<description>
@@ -34,7 +34,7 @@
</description>
<properties>
<example.main-class>io.helidon.microprofile.server.Main</example.main-class>
<mainClass>io.helidon.microprofile.server.Main</mainClass>
</properties>
<dependencies>
@@ -57,7 +57,6 @@
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -88,21 +87,6 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<longClasspath>true</longClasspath>
<arguments>
<argument>-enableassertions</argument>
<argument>-Djava.util.logging.config.file=src/main/resources/logging.properties</argument>
<argument>-classpath</argument>
<classpath/>
<argument>${example.main-class}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,22 @@
# Helidon MP IDCS
Example JAX-RS application with resources protected by IDCS
## Build
```
mvn package
```
## Run
```
mvn exec:java
```
Try the endpoints:
```
TBD
```

View File

@@ -22,17 +22,21 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.microprofile.examples</groupId>
<artifactId>examples-project</artifactId>
<groupId>io.helidon.examples.microprofile</groupId>
<artifactId>helidon-examples-microprofile-project</artifactId>
<version>0.11.0-SNAPSHOT</version>
</parent>
<artifactId>security-idcs</artifactId>
<artifactId>helidon-examples-microprofile-security-idcs</artifactId>
<name>Helidon Microprofile Examples IDCS Security</name>
<description>
Microprofile example with IDCS integration (through Open ID Connect)
</description>
<properties>
<mainClass>io.helidon.microprofile.example.idcs.IdcsMain</mainClass>
</properties>
<dependencies>
<dependency>
<groupId>io.helidon.microprofile.bundles</groupId>

Some files were not shown because too many files have changed in this diff Show More