Skip to content

Commit

Permalink
Make jafu-reactive-r2dbc runnable as GraalVM native image
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Nov 12, 2018
1 parent 40e2223 commit 0a7c185
Show file tree
Hide file tree
Showing 20 changed files with 337 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
*.ipr
out/
samples/kofu-reactive-graal/com.sample.applicationkt
samples/jafu-reactive-graal/com.sample.applicationkt
16 changes: 14 additions & 2 deletions samples/jafu-reactive-r2dbc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ plugins {
dependencies {
implementation("org.springframework.fu:spring-fu-jafu:0.0.3.BUILD-SNAPSHOT")

implementation("org.apache.logging.log4j:log4j-to-slf4j")
implementation("org.slf4j", "jul-to-slf4j")
implementation("org.slf4j", "slf4j-jdk14")

implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-mustache")
implementation("org.springframework.data:spring-data-r2dbc:1.0.0.BUILD-SNAPSHOT")
implementation("io.r2dbc:r2dbc-spi:1.0.0.M5")
implementation("io.r2dbc:r2dbc-postgresql:1.0.0.M5")
implementation("io.r2dbc:r2dbc-spi:1.0.0.BUILD-SNAPSHOT")
implementation("io.r2dbc:r2dbc-postgresql:1.0.0.BUILD-SNAPSHOT")

testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.springframework:spring-test")
Expand All @@ -25,3 +29,11 @@ repositories {
maven("https://repo.spring.io/milestone")
maven("https://repo.spring.io/snapshot")
}

configurations.all {
exclude(module = "netty-transport-native-epoll")
exclude(module = "netty-transport-native-unix-common")
exclude(module = "netty-codec-http2")
exclude(module = "hibernate-validator")
exclude(module = "spring-boot-starter-logging")
}
6 changes: 6 additions & 0 deletions samples/jafu-reactive-r2dbc/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

./gradlew clean build --refresh-dependencies
unzip build/libs/jafu-reactive-r2dbc.jar -d build/libs/jafu-reactive-r2dbc

native-image -H:IncludeResources='META-INF/.*.json|META-INF/spring.factories|org/springframework/boot/logging/.*' --allow-incomplete-classpath --delay-class-initialization-to-runtime=io.netty.handler.codec.http.HttpObjectEncoder,org.springframework.core.io.VfsUtils,org.springframework.format.support.DefaultFormattingConversionService -H:ReflectionConfigurationFiles=graal/app.json,graal/boot.json,graal/framework.json,graal/log4j.json,graal/netty.json -Dio.netty.noUnsafe=true -H:+ReportUnsupportedElementsAtRuntime -Dfile.encoding=UTF-8 -cp ".:$(echo build/libs/jafu-reactive-r2dbc/BOOT-INF/lib/*.jar | tr ' ' ':')":build/libs/jafu-reactive-r2dbc/BOOT-INF/classes com.sample.Application
23 changes: 23 additions & 0 deletions samples/jafu-reactive-r2dbc/graal/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"name": "com.sample.UserRepository",
"methods": [
{ "name": "<init>", "parameterTypes": ["org.springframework.data.r2dbc.function.DatabaseClient"] }
]
},
{
"name": "com.sample.UserHandler",
"methods": [
{ "name": "<init>", "parameterTypes": ["com.sample.UserRepository"] }
]
},
{
"name": "com.sample.User",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allPublicFields": true,
"allPublicMethods": true,
"allDeclaredMethods": true,
"allDeclaredFields": true
}
]
219 changes: 219 additions & 0 deletions samples/jafu-reactive-r2dbc/graal/boot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
[
{
"name": "org.springframework.boot.env.PropertiesPropertySourceLoader",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.env.YamlPropertySourceLoader",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.event.EventPublishingRunListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.FailureAnalyzers",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.ContextIdApplicationContextInitializer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.config.DelegatingApplicationContextInitializer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.ClearCachesApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.builder.ParentContextCloserApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.FileEncodingApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.config.AnsiOutputApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.config.ConfigFileApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.config.DelegatingApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.logging.ClasspathLoggingApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.context.logging.LoggingApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.BeanCurrentlyInCreationFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.BeanDefinitionOverrideFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.BeanNotOfRequiredTypeFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.BindFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.BindValidationFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.UnboundConfigurationPropertyFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.ConnectorStartFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.NoSuchMethodFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.NoUniqueBeanDefinitionFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.PortInUseFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyNameFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyValueFailureAnalyzer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer$SharedMetadataReaderFactoryBean",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.BackgroundPreinitializer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.condition.OnClassCondition",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvider",
"allDeclaredConstructors": true
},
{
"name": "org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name": "org.springframework.boot.logging.java.JavaLoggingSystem",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allPublicFields": true,
"allPublicMethods": true,
"allDeclaredMethods": true,
"allDeclaredFields": true
},
{
"name": "java.util.logging.ConsoleHandler",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allPublicFields": true,
"allPublicMethods": true,
"allDeclaredMethods": true,
"allDeclaredFields": true
}
]
20 changes: 20 additions & 0 deletions samples/jafu-reactive-r2dbc/graal/framework.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name": "org.springframework.context.support.GenericApplicationContext",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name": "org.springframework.context.annotation.ConfigurationClassPostProcessor",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name": "org.springframework.http.codec.support.DefaultServerCodecConfigurer",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
}
]
20 changes: 20 additions & 0 deletions samples/jafu-reactive-r2dbc/graal/log4j.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name": "org.apache.logging.log4j.message.ReusableMessageFactory",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name": "org.apache.logging.log4j.message.DefaultFlowMessageFactory",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name": "org.apache.logging.log4j.message.ParameterizedMessageFactory",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
}
]
14 changes: 14 additions & 0 deletions samples/jafu-reactive-r2dbc/graal/netty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"name": "io.netty.channel.socket.nio.NioServerSocketChannel",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name": "io.netty.channel.socket.nio.NioSocketChannel",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public abstract class Application {
public static ApplicationDsl app = application(app ->
app.importConfiguration(Configurations.dataConfig)
.importConfiguration(Configurations.webConfig)
.properties(SampleProperties.class, "sample")
.listener(ApplicationReadyEvent.class, e -> app.ref(UserRepository.class).init())
);

public static void main (String[] args) {
System.setProperty("org.springframework.boot.logging.LoggingSystem", "org.springframework.boot.logging.java.JavaLoggingSystem");
app.run(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ public abstract class Configurations {
}
server.router(router -> {
UserHandler userHandler = conf.ref(UserHandler.class);
router
.GET("/", userHandler::listView)
.GET("/api/user", userHandler::listApi)
.GET("/conf", userHandler::conf);
}).codecs(codecs -> codecs.string().jackson()).mustache();
router.GET("/", userHandler::listApi);
}).codecs(codecs -> codecs.string().jackson());
});
};
}

This file was deleted.

Loading

0 comments on commit 0a7c185

Please sign in to comment.