Skip to content

Commit a14c21a

Browse files
Merge pull request #3 from paulparkinson/main
init for graalvm workshops - spring boot, quarkus, micronaut, helidon
2 parents 247f834 + 901e1b8 commit a14c21a

File tree

83 files changed

+3290
-84212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3290
-84212
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5+
https://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
<parent>
8+
<groupId>io.helidon.applications</groupId>
9+
<artifactId>helidon-mp</artifactId>
10+
<version>4.1.1</version>
11+
<relativePath/>
12+
</parent>
13+
<groupId>com.oracle.helidon.datasource</groupId>
14+
<artifactId>com-oracle-helidon-datasource</artifactId>
15+
<version>1.0.0-SNAPSHOT</version>
16+
17+
<dependencies>
18+
<!-- Compile-scoped dependencies. -->
19+
<dependency>
20+
<groupId>jakarta.enterprise</groupId>
21+
<artifactId>jakarta.enterprise.cdi-api</artifactId>
22+
<scope>compile</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>jakarta.ws.rs</groupId>
26+
<artifactId>jakarta.ws.rs-api</artifactId>
27+
<scope>compile</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.eclipse.microprofile.config</groupId>
31+
<artifactId>microprofile-config-api</artifactId>
32+
<scope>compile</scope>
33+
</dependency>
34+
35+
<!-- Runtime-scoped dependencies. -->
36+
<dependency>
37+
<groupId>io.helidon.integrations.db</groupId>
38+
<artifactId>ojdbc</artifactId>
39+
<scope>runtime</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.helidon.integrations.cdi</groupId>
43+
<artifactId>helidon-integrations-cdi-datasource-ucp</artifactId>
44+
<scope>runtime</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.smallrye</groupId>
48+
<artifactId>jandex</artifactId>
49+
<scope>runtime</scope>
50+
<optional>true</optional>
51+
</dependency>
52+
<dependency>
53+
<groupId>io.helidon.microprofile.server</groupId>
54+
<artifactId>helidon-microprofile-server</artifactId>
55+
<scope>runtime</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>io.helidon.microprofile.config</groupId>
59+
<artifactId>helidon-microprofile-config</artifactId>
60+
<scope>runtime</scope>
61+
</dependency>
62+
</dependencies>
63+
64+
<build>
65+
<plugins>
66+
<plugin>
67+
<groupId>org.apache.maven.plugins</groupId>
68+
<artifactId>maven-dependency-plugin</artifactId>
69+
<executions>
70+
<execution>
71+
<id>copy-libs</id>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
<plugin>
76+
<groupId>io.smallrye</groupId>
77+
<artifactId>jandex-maven-plugin</artifactId>
78+
<executions>
79+
<execution>
80+
<id>make-index</id>
81+
</execution>
82+
</executions>
83+
</plugin>
84+
</plugins>
85+
</build>
86+
</project>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.oracle.helidon.datasource;
2+
3+
import java.sql.Connection;
4+
import java.sql.PreparedStatement;
5+
import java.sql.ResultSet;
6+
import java.sql.SQLException;
7+
import java.util.Objects;
8+
9+
import javax.sql.DataSource;
10+
11+
import jakarta.enterprise.context.ApplicationScoped;
12+
import jakarta.inject.Inject;
13+
import jakarta.inject.Named;
14+
import jakarta.ws.rs.GET;
15+
import jakarta.ws.rs.Path;
16+
import jakarta.ws.rs.Produces;
17+
import jakarta.ws.rs.core.MediaType;
18+
import jakarta.ws.rs.core.Response;
19+
20+
/**
21+
* A JAX-RS resource class in {@linkplain ApplicationScoped
22+
* application scope} rooted at {@code /tables}.
23+
*
24+
* @see #get()
25+
*/
26+
@Path("/tables")
27+
@ApplicationScoped
28+
public class TablesResource {
29+
30+
private final DataSource dataSource;
31+
32+
/**
33+
* Creates a new {@link TablesResource}.
34+
*
35+
* @param dataSource the {@link DataSource} to use to acquire
36+
* database table names; must not be {@code null}
37+
*
38+
* @exception NullPointerException if {@code dataSource} is {@code
39+
* null}
40+
*/
41+
@Inject
42+
public TablesResource(@Named("example") final DataSource dataSource) {
43+
super();
44+
this.dataSource = Objects.requireNonNull(dataSource);
45+
}
46+
47+
/**
48+
* Returns a {@link Response} which, if successful, contains a
49+
* newline-separated list of Oracle database table names.
50+
*
51+
* <p>This method never returns {@code null}.</p>
52+
*
53+
* @return a non-{@code null} {@link Response}
54+
*
55+
* @exception SQLException if a database error occurs
56+
*/
57+
@GET
58+
@Produces(MediaType.TEXT_PLAIN)
59+
public Response get() throws SQLException {
60+
final StringBuilder sb = new StringBuilder();
61+
try (Connection connection = this.dataSource.getConnection();
62+
PreparedStatement ps =
63+
connection.prepareStatement(" SELECT TABLE_NAME"
64+
+ " FROM ALL_TABLES "
65+
+ "ORDER BY TABLE_NAME ASC");
66+
ResultSet rs = ps.executeQuery()) {
67+
System.out.println("Connection is : " + connection);
68+
while (rs.next()) {
69+
sb.append(rs.getString(1)).append("\n");
70+
}
71+
}
72+
final Response returnValue = Response.ok()
73+
.entity(sb.toString())
74+
.build();
75+
return returnValue;
76+
}
77+
78+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
5+
https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
6+
version="4.0"
7+
bean-discovery-mode="annotated">
8+
</beans>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"classes": [
3+
"oracle.ucp.jdbc.PoolDataSource",
4+
"oracle.ucp.jdbc.PoolDataSourceImpl",
5+
"javax.sql.DataSource"
6+
]
7+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
"bean-class": "io.helidon.integrations.datasource.ucp.cdi.UCPBackedDataSourceExtension",
4+
"ifaces": [
5+
"java.io.Serializable",
6+
"java.sql.Wrapper",
7+
"javax.naming.Referenceable",
8+
"javax.naming.spi.ObjectFactory",
9+
"javax.sql.CommonDataSource",
10+
"javax.sql.DataSource",
11+
"oracle.ucp.jdbc.PoolDataSource",
12+
"oracle.ucp.UniversalConnectionPoolAdapter"
13+
]
14+
},
15+
{
16+
"bean-class": "io.helidon.integrations.datasource.ucp.cdi.UniversalConnectionPoolExtension",
17+
"ifaces": [
18+
"java.io.Serializable",
19+
"java.sql.Wrapper",
20+
"javax.naming.Referenceable",
21+
"javax.naming.spi.ObjectFactory",
22+
"javax.sql.CommonDataSource",
23+
"javax.sql.DataSource",
24+
"javax.sql.XADataSource",
25+
"oracle.ucp.jdbc.PoolDataSource",
26+
"oracle.ucp.jdbc.PoolXADataSource",
27+
"oracle.ucp.UniversalConnectionPoolAdapter"
28+
]
29+
}
30+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Microprofile server properties
2+
server.port=8080
3+
server.host=0.0.0.0
4+
5+
# DataSource properties
6+
javax.sql.DataSource.example.connectionFactoryClassName=oracle.jdbc.pool.OracleDataSource
7+
javax.sql.DataSource.example.URL=jdbc:oracle:thin:@<ATP_NAME>_high?TNS_ADMIN=/home/<YOUR_USER>/myatpwallet
8+
javax.sql.DataSource.example.user=ADMIN
9+
javax.sql.DataSource.example.password=<ADMIN_PASSWORD>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Args=-H:+RemoveSaturatedTypeFlows --initialize-at-build-time=com.oracle.helidon.datasource \
2+
--initialize-at-run-time=io.helidon.integrations.datasource.ucp.cdi.UniversalConnectionPool$_$$_WeldClientProxy \
3+
--initialize-at-run-time=oracle.jdbc.driver.NTFListener \
4+
--initialize-at-run-time=oracle.ucp.common.Service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"name": "oracle.ucp.jdbc.PoolDataSourceImpl",
4+
"allPublicMethods" : true
5+
},
6+
{
7+
"name" : "oracle.ucp.jdbc.PoolXADataSourceImpl",
8+
"allPublicMethods" : true
9+
}
10+
]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
# Exit immediately if a command exits with a non-zero status
4+
set -e
5+
6+
# Treat unset variables as an error
7+
set -u
8+
9+
# Variables
10+
MAVEN_VERSION="3.9.8"
11+
DOWNLOAD_URL="https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
12+
INSTALL_DIR="$HOME/mvn-upgrade"
13+
ARCHIVE_NAME="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
14+
15+
# Functions
16+
log() {
17+
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1"
18+
}
19+
20+
create_directory() {
21+
if [ ! -d "$INSTALL_DIR" ]; then
22+
mkdir -p "$INSTALL_DIR"
23+
log "Created directory: $INSTALL_DIR"
24+
else
25+
log "Directory already exists: $INSTALL_DIR"
26+
fi
27+
}
28+
29+
download_maven() {
30+
if wget -q --spider "$DOWNLOAD_URL"; then
31+
wget -O "${INSTALL_DIR}/${ARCHIVE_NAME}" "$DOWNLOAD_URL"
32+
log "Downloaded Maven: $DOWNLOAD_URL"
33+
else
34+
log "Maven download URL does not exist: $DOWNLOAD_URL"
35+
exit 1
36+
fi
37+
}
38+
39+
extract_and_cleanup() {
40+
tar -xvzf "${INSTALL_DIR}/${ARCHIVE_NAME}" -C "$INSTALL_DIR"
41+
log "Extracted Maven archive"
42+
43+
rm -f "${INSTALL_DIR}/${ARCHIVE_NAME}"
44+
log "Removed Maven archive: ${INSTALL_DIR}/${ARCHIVE_NAME}"
45+
}
46+
47+
# Main Script
48+
log "Starting Maven upgrade script"
49+
50+
log "Changing directory to home"
51+
cd ~
52+
53+
log "Printing current directory"
54+
pwd
55+
56+
log "Creating installation directory"
57+
create_directory
58+
59+
log "Changing directory to installation directory"
60+
cd "$INSTALL_DIR"
61+
62+
log "Downloading Maven"
63+
download_maven
64+
65+
log "Extracting and cleaning up Maven archive"
66+
extract_and_cleanup
67+
68+
log "Maven upgrade script completed successfully"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# AOT configuration properties for jar packaging
2+
# Please review carefully the optimizations enabled below
3+
# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details
4+
5+
# Caches environment property values: environment properties will be deemed immutable after application startup.
6+
cached.environment.enabled=true
7+
8+
# Precomputes Micronaut configuration property keys from the current environment variables
9+
precompute.environment.properties.enabled=true
10+
11+
# Converts YAML configuration files to Java configuration
12+
yaml.to.java.config.enabled=true
13+
14+
# Scans for service types ahead-of-time, avoiding classpath scanning at startup
15+
serviceloading.jit.enabled=true
16+
17+
# Scans reactive types at build time instead of runtime
18+
scan.reactive.types.enabled=true
19+
20+
# Deduces the environment at build time instead of runtime
21+
deduce.environment.enabled=true
22+
23+
# Checks of existence of some types at build time instead of runtime
24+
known.missing.types.enabled=true
25+
26+
# Precomputes property sources at build time
27+
sealed.property.source.enabled=true
28+
29+
# The list of service types to be scanned (comma separated)
30+
service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver
31+
32+
# A list of types that the AOT analyzer needs to check for existence (comma separated)
33+
known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable
34+

0 commit comments

Comments
 (0)