Skip to content

Commit

Permalink
Update Neo4j example:
Browse files Browse the repository at this point in the history
 - move the example from examples/integrations/neo4j/neo4j-se to examples/integrations/neo4j
 - renamed package from io.helidon.examples.integrations.neo4j.se to io.helidon.examples.integrations.neo4j
 - update README
 - fix metrics

Updated module-info and poms to remove CDI dependencies.

Adjust copyright years.
Update README to state JDK20 instead of JDK21.
  • Loading branch information
romain-grecourt committed Jun 21, 2023
1 parent 7820902 commit be6955b
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 205 deletions.
8 changes: 4 additions & 4 deletions etc/copyright-exclude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ node_modules
archetype-resources/pom.xml
# excluded as it contains both Oracle and original copyright notice
src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
src/main/java/io/helidon/examples/integrations/neo4j/se/domain/Actor.java
src/main/java/io/helidon/examples/integrations/neo4j/se/domain/Movie.java
src/main/java/io/helidon/examples/integrations/neo4j/se/domain/Person.java
src/main/java/io/helidon/examples/integrations/neo4j/se/domain/MovieRepository.java
src/main/java/io/helidon/examples/integrations/neo4j/domain/Actor.java
src/main/java/io/helidon/examples/integrations/neo4j/domain/Movie.java
src/main/java/io/helidon/examples/integrations/neo4j/domain/Person.java
src/main/java/io/helidon/examples/integrations/neo4j/domain/MovieRepository.java
etc/THIRD_PARTY_LICENSES.xml
etc/HELIDON_THIRD_PARTY_LICENSES.xml
etc/dependency-check-suppression.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret'

Goto the Neo4j browser and play the first step of the movies graph: [`:play movies`](http://localhost:7474/browser/?cmd=play&arg=movies).

Build and run with With JDK21
Build and run with JDK20
```bash
mvn package
java -jar target/helidon-examples-integration-neo4j-nima.jar
Expand All @@ -32,11 +32,7 @@ Enable them in the driver:
metricsEnabled: true
```
````
curl localhost:8080/observe/health
````
````
curl localhost:8080/observe/metrics
````
````
1 change: 0 additions & 1 deletion examples/integrations/neo4j/neo4j-se/.dockerignore

This file was deleted.

117 changes: 0 additions & 117 deletions examples/integrations/neo4j/neo4j-se/pom.xml

This file was deleted.

113 changes: 102 additions & 11 deletions examples/integrations/neo4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,112 @@
-->

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.examples.integrations</groupId>
<artifactId>helidon-examples-integrations-project</artifactId>
<groupId>io.helidon.applications</groupId>
<artifactId>helidon-nima</artifactId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../../../applications/nima/pom.xml</relativePath>
</parent>
<groupId>io.helidon.examples.integrations.neo4j</groupId>
<artifactId>helidon-examples-integrations-neo4j-project</artifactId>
<name>Helidon Neo4j Integrations Examples</name>
<packaging>pom</packaging>
<artifactId>helidon-examples-integration-neo4j</artifactId>
<name>Helidon Integrations Neo4j Example</name>

<modules>
<module>neo4j-se</module>
</modules>
<properties>
<mainClass>io.helidon.examples.integrations.neo4j.Main</mainClass>
<neo4j-harness.version>5.8.0</neo4j-harness.version>
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.nima.webserver</groupId>
<artifactId>helidon-nima-webserver</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.health</groupId>
<artifactId>helidon-health-checks</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.http.media</groupId>
<artifactId>helidon-nima-http-media-jsonp</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.http.media</groupId>
<artifactId>helidon-nima-http-media-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-yaml</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe-health</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.observe</groupId>
<artifactId>helidon-nima-observe-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-health</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.nima.testing.junit5</groupId>
<artifactId>helidon-nima-testing-junit5-webserver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<!--Neo4j harness -->
<dependency>
<groupId>org.neo4j.test</groupId>
<artifactId>neo4j-harness</artifactId>
<version>${neo4j-harness.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libs</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,15 +14,16 @@
* limitations under the License.
*/

package io.helidon.examples.integrations.neo4j.se;
package io.helidon.examples.integrations.neo4j;

import io.helidon.config.Config;
import io.helidon.examples.integrations.neo4j.se.domain.MovieRepository;
import io.helidon.examples.integrations.neo4j.domain.MovieRepository;
import io.helidon.health.checks.DeadlockHealthCheck;
import io.helidon.health.checks.DiskSpaceHealthCheck;
import io.helidon.health.checks.HeapMemoryHealthCheck;
import io.helidon.integrations.neo4j.Neo4j;
import io.helidon.integrations.neo4j.health.Neo4jHealthCheck;
import io.helidon.integrations.neo4j.metrics.Neo4jMetricsSupport;
import io.helidon.logging.common.LogConfig;
import io.helidon.nima.http.media.jsonp.JsonpSupport;
import io.helidon.nima.observe.ObserveFeature;
Expand Down Expand Up @@ -71,17 +72,19 @@ static void startServer() {
* Updates HTTP Routing.
*/
static void routing(Builder routing) {

Neo4j neo4j = Neo4j.create(Config.create().get("neo4j"));
Driver neo4jDriver = neo4j.driver();

Neo4jHealthCheck healthCheck = Neo4jHealthCheck.create(neo4j.driver());
Neo4jMetricsSupport.builder()
.driver(neo4jDriver)
.build()
.initialize();

Driver neo4jDriver = neo4j.driver();
Neo4jHealthCheck healthCheck = Neo4jHealthCheck.create(neo4jDriver);

MovieService movieService = new MovieService(new MovieRepository(neo4jDriver));

ObserveFeature observe = ObserveFeature.builder()
.useSystemServices(false)
.addProvider(HealthObserveProvider.create(HealthFeature.builder()
.useSystemServices(false)
.addCheck(HeapMemoryHealthCheck.create())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,9 +14,9 @@
* limitations under the License.
*/

package io.helidon.examples.integrations.neo4j.se;
package io.helidon.examples.integrations.neo4j;

import io.helidon.examples.integrations.neo4j.se.domain.MovieRepository;
import io.helidon.examples.integrations.neo4j.domain.MovieRepository;
import io.helidon.nima.webserver.http.HttpRules;
import io.helidon.nima.webserver.http.HttpService;
import io.helidon.nima.webserver.http.ServerRequest;
Expand All @@ -38,15 +38,9 @@ public MovieService(MovieRepository movieRepository) {
this.movieRepository = movieRepository;
}

/**
* Main routing done here.
*
* @param rules
*/
@Override
public void routing(HttpRules rules) {
rules
.get("/api/movies", this::findMoviesHandler);
rules.get("/api/movies", this::findMoviesHandler);
}

private void findMoviesHandler(ServerRequest request, ServerResponse response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*
*/

package io.helidon.examples.integrations.neo4j.se.domain;
package io.helidon.examples.integrations.neo4j.domain;

import java.util.ArrayList;
import java.util.List;

/*
* Helidon changes are under the copyright of:
*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit be6955b

Please sign in to comment.