Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init for graalvm workshops - spring boot, quarkus, micronaut, helidon #3

Merged
merged 25 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fde5342
remove oci limits checks
paulparkinson May 13, 2024
7d85056
remove oci limits checks
paulparkinson May 13, 2024
99394b2
remove oci limits checks
paulparkinson May 13, 2024
75cdf7a
Merge remote-tracking branch 'upstream/main'
paulparkinson Sep 30, 2024
262ca15
init for graalvm workshops
paulparkinson Sep 30, 2024
8b2a4c8
init for graalvm workshops
paulparkinson Oct 2, 2024
cce1ecf
init for graalvm workshops
paulparkinson Oct 2, 2024
fffc721
init for graalvm workshops
paulparkinson Oct 2, 2024
ab303ef
init for graalvm workshops
paulparkinson Oct 2, 2024
9636354
init for graalvm workshops
paulparkinson Oct 2, 2024
8223090
init for graalvm workshops
paulparkinson Oct 2, 2024
7617e3c
init for graalvm workshops
paulparkinson Oct 2, 2024
fe3e90e
init for graalvm workshops
paulparkinson Oct 3, 2024
54899b2
init for graalvm workshops
paulparkinson Oct 3, 2024
33047ed
init for graalvm workshops
paulparkinson Oct 3, 2024
f0efd5c
init for graalvm workshops
paulparkinson Oct 3, 2024
ec91eee
init for graalvm workshops
paulparkinson Oct 3, 2024
232bca3
init for graalvm workshops
paulparkinson Oct 3, 2024
93744df
init for graalvm workshops
paulparkinson Oct 3, 2024
558dc04
init for graalvm workshops
paulparkinson Oct 3, 2024
62a1b70
init for graalvm workshops
paulparkinson Oct 3, 2024
da08557
init for graalvm workshops
paulparkinson Oct 3, 2024
e7bcb58
init for graalvm workshops
paulparkinson Oct 4, 2024
e7847ad
init for graalvm workshops
paulparkinson Oct 4, 2024
901e1b8
init for graalvm workshops
paulparkinson Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions graalvm-nativeimage/helidon/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.applications</groupId>
<artifactId>helidon-mp</artifactId>
<version>4.1.1</version>
<relativePath/>
</parent>
<groupId>com.oracle.helidon.datasource</groupId>
<artifactId>com-oracle-helidon-datasource</artifactId>
<version>1.0.0-SNAPSHOT</version>

<dependencies>
<!-- Compile-scoped dependencies. -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<scope>compile</scope>
</dependency>

<!-- Runtime-scoped dependencies. -->
<dependency>
<groupId>io.helidon.integrations.db</groupId>
<artifactId>ojdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.helidon.integrations.cdi</groupId>
<artifactId>helidon-integrations-cdi-datasource-ucp</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>jandex</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.server</groupId>
<artifactId>helidon-microprofile-server</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.config</groupId>
<artifactId>helidon-microprofile-config</artifactId>
<scope>runtime</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>io.smallrye</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<executions>
<execution>
<id>make-index</id>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.oracle.helidon.datasource;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Objects;

import javax.sql.DataSource;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

/**
* A JAX-RS resource class in {@linkplain ApplicationScoped
* application scope} rooted at {@code /tables}.
*
* @see #get()
*/
@Path("/tables")
@ApplicationScoped
public class TablesResource {

private final DataSource dataSource;

/**
* Creates a new {@link TablesResource}.
*
* @param dataSource the {@link DataSource} to use to acquire
* database table names; must not be {@code null}
*
* @exception NullPointerException if {@code dataSource} is {@code
* null}
*/
@Inject
public TablesResource(@Named("example") final DataSource dataSource) {
super();
this.dataSource = Objects.requireNonNull(dataSource);
}

/**
* Returns a {@link Response} which, if successful, contains a
* newline-separated list of Oracle database table names.
*
* <p>This method never returns {@code null}.</p>
*
* @return a non-{@code null} {@link Response}
*
* @exception SQLException if a database error occurs
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response get() throws SQLException {
final StringBuilder sb = new StringBuilder();
try (Connection connection = this.dataSource.getConnection();
PreparedStatement ps =
connection.prepareStatement(" SELECT TABLE_NAME"
+ " FROM ALL_TABLES "
+ "ORDER BY TABLE_NAME ASC");
ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
sb.append(rs.getString(1)).append("\n");
}
}
final Response returnValue = Response.ok()
.entity(sb.toString())
.build();
return returnValue;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
version="4.0"
bean-discovery-mode="annotated">
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"classes": [
"oracle.ucp.jdbc.PoolDataSource",
"oracle.ucp.jdbc.PoolDataSourceImpl",
"javax.sql.DataSource"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"bean-class": "io.helidon.integrations.datasource.ucp.cdi.UCPBackedDataSourceExtension",
"ifaces": [
"java.io.Serializable",
"java.sql.Wrapper",
"javax.naming.Referenceable",
"javax.naming.spi.ObjectFactory",
"javax.sql.CommonDataSource",
"javax.sql.DataSource",
"oracle.ucp.jdbc.PoolDataSource",
"oracle.ucp.UniversalConnectionPoolAdapter"
]
},
{
"bean-class": "io.helidon.integrations.datasource.ucp.cdi.UniversalConnectionPoolExtension",
"ifaces": [
"java.io.Serializable",
"java.sql.Wrapper",
"javax.naming.Referenceable",
"javax.naming.spi.ObjectFactory",
"javax.sql.CommonDataSource",
"javax.sql.DataSource",
"javax.sql.XADataSource",
"oracle.ucp.jdbc.PoolDataSource",
"oracle.ucp.jdbc.PoolXADataSource",
"oracle.ucp.UniversalConnectionPoolAdapter"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Microprofile server properties
server.port=8080
server.host=0.0.0.0

# DataSource properties
javax.sql.DataSource.example.connectionFactoryClassName=oracle.jdbc.pool.OracleDataSource
javax.sql.DataSource.example.URL=jdbc:oracle:thin:@<ATP_NAME>_high?TNS_ADMIN=/home/<YOUR_USER>/<YOUR_WALLET_LOCATION>
javax.sql.DataSource.example.user=ADMIN
javax.sql.DataSource.example.password=<ADMIN_PASSWORD>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Args=-H:+RemoveSaturatedTypeFlows --initialize-at-build-time=com.oracle.helidon.datasource \
--initialize-at-run-time=io.helidon.integrations.datasource.ucp.cdi.UniversalConnectionPool$_$$_WeldClientProxy \
--initialize-at-run-time=oracle.jdbc.driver.NTFListener \
--initialize-at-run-time=oracle.ucp.common.Service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"name": "oracle.ucp.jdbc.PoolDataSourceImpl",
"allPublicMethods" : true
},
{
"name" : "oracle.ucp.jdbc.PoolXADataSourceImpl",
"allPublicMethods" : true
}
]
68 changes: 68 additions & 0 deletions graalvm-nativeimage/maven-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e

# Treat unset variables as an error
set -u

# Variables
MAVEN_VERSION="3.9.8"
DOWNLOAD_URL="https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
INSTALL_DIR="$HOME/mvn-upgrade"
ARCHIVE_NAME="apache-maven-${MAVEN_VERSION}-bin.tar.gz"

# Functions
log() {
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1"
}

create_directory() {
if [ ! -d "$INSTALL_DIR" ]; then
mkdir -p "$INSTALL_DIR"
log "Created directory: $INSTALL_DIR"
else
log "Directory already exists: $INSTALL_DIR"
fi
}

download_maven() {
if wget -q --spider "$DOWNLOAD_URL"; then
wget -O "${INSTALL_DIR}/${ARCHIVE_NAME}" "$DOWNLOAD_URL"
log "Downloaded Maven: $DOWNLOAD_URL"
else
log "Maven download URL does not exist: $DOWNLOAD_URL"
exit 1
fi
}

extract_and_cleanup() {
tar -xvzf "${INSTALL_DIR}/${ARCHIVE_NAME}" -C "$INSTALL_DIR"
log "Extracted Maven archive"

rm -f "${INSTALL_DIR}/${ARCHIVE_NAME}"
log "Removed Maven archive: ${INSTALL_DIR}/${ARCHIVE_NAME}"
}

# Main Script
log "Starting Maven upgrade script"

log "Changing directory to home"
cd ~

log "Printing current directory"
pwd

log "Creating installation directory"
create_directory

log "Changing directory to installation directory"
cd "$INSTALL_DIR"

log "Downloading Maven"
download_maven

log "Extracting and cleaning up Maven archive"
extract_and_cleanup

log "Maven upgrade script completed successfully"
34 changes: 34 additions & 0 deletions graalvm-nativeimage/micronaut/aot-jar.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# AOT configuration properties for jar packaging
# Please review carefully the optimizations enabled below
# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details

# Caches environment property values: environment properties will be deemed immutable after application startup.
cached.environment.enabled=true

# Precomputes Micronaut configuration property keys from the current environment variables
precompute.environment.properties.enabled=true

# Converts YAML configuration files to Java configuration
yaml.to.java.config.enabled=true

# Scans for service types ahead-of-time, avoiding classpath scanning at startup
serviceloading.jit.enabled=true

# Scans reactive types at build time instead of runtime
scan.reactive.types.enabled=true

# Deduces the environment at build time instead of runtime
deduce.environment.enabled=true

# Checks of existence of some types at build time instead of runtime
known.missing.types.enabled=true

# Precomputes property sources at build time
sealed.property.source.enabled=true

# The list of service types to be scanned (comma separated)
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

# A list of types that the AOT analyzer needs to check for existence (comma separated)
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

6 changes: 6 additions & 0 deletions graalvm-nativeimage/micronaut/micronaut-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
applicationType: default
defaultPackage: com.oracle.dev.jdbc.micronaut
testFramework: junit
sourceLanguage: java
buildTool: maven
features: [app-name, data, data-jdbc, flyway, http-client-test, java, java-application, jdbc-hikari, junit, logback, maven, maven-enforcer-plugin, micronaut-aot, micronaut-http-validation, netty-server, oracle-cloud-atp, oracle-cloud-sdk, properties, readme, serialization-jackson, shade, testcontainers]
Loading