Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Enhance Spring Boot DataFrame example with Actuator support, improved…
… configuration, and sample data

Added Spring Boot Actuator dependency to `springboot-dataframe-web`, introduced `DataFrameConfiguration` for better DataFrame post-processing, and updated CSV data sources for customers and sales. Adjusted annotations, enhanced lifecycle handling in `DataFramePostProcessor`, and added visual documentation and sample data files. Updated build scripts for Java 17 compatibility.
  • Loading branch information
zaleslaw committed Aug 22, 2025
commit 166ddf7fe0d948cabba538219bf6ae9e86de9a13
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ val modulesUsingJava11 = with(projects) {
val modulesUsingJava17 = with(projects) {
setOf(
dataframeSpring,
examples.ideaExamples.springbootDataframeWeb,
)
}.map { it.path }

Expand Down
13 changes: 13 additions & 0 deletions data/spring/customers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id,name,country,email
1,Alice Johnson,USA,[email protected]
2,Bob Smith,Canada,[email protected]
3,Charlie Davis,USA,[email protected]
4,Diana Evans,UK,[email protected]
5,Edward Wilson,USA,[email protected]
6,Fiona Brown,Australia,[email protected]
7,George Miller,Germany,[email protected]
8,Helen Clark,USA,[email protected]
9,Ian Thompson,Ireland,[email protected]
10,Julia Roberts,USA,[email protected]
11,Kevin Lee,Canada,[email protected]
12,Linda Perez,Spain,[email protected]
13 changes: 13 additions & 0 deletions data/spring/sales.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sale_id,customer_id,product,value,date
1001,1,Laptop,1200.50,2025-01-05
1002,2,Phone,799.99,2025-01-10
1003,3,Tablet,450.00,2025-02-14
1004,4,Headphones,149.99,2025-02-20
1005,5,Monitor,299.49,2025-03-01
1006,6,Keyboard,89.99,2025-03-12
1007,7,Mouse,49.95,2025-03-15
1008,8,Smartwatch,199.00,2025-04-01
1009,9,Camera,650.75,2025-04-12
1010,10,Printer,220.00,2025-04-20
1011,11,Speaker,130.00,2025-05-02
1012,12,Router,99.99,2025-05-10
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlin.reflect.full.memberProperties
import kotlin.reflect.jvm.javaField
import kotlin.reflect.jvm.javaGetter
import org.springframework.context.support.StaticApplicationContext
import org.springframework.context.LifecycleProcessor

/**
* Spring BeanPostProcessor that automatically populates DataFrame fields
Expand Down Expand Up @@ -63,6 +64,8 @@ class DataFramePostProcessor : BeanPostProcessor, ApplicationContextAware {
}

override fun postProcessBeforeInitialization(bean: Any, beanName: String): Any? {
// Skip Spring lifecycle infrastructure beans to avoid triggering optional CRaC class loading via reflection
if (bean is LifecycleProcessor) return bean
try {
bean::class.memberProperties.forEach { prop ->
processProperty(bean, prop, beanName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import org.jetbrains.kotlinx.dataframe.io.JSON
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
open annotation class JsonDataSource(
open val file: String,
open val keyValuePaths: Array<String> = [],
open val typeClashTactic: JSON.TypeClashTactic = JSON.TypeClashTactic.ARRAY_AND_VALUE_COLUMNS,
open val unifyNumbers: Boolean = true
annotation class JsonDataSource(
val file: String,
val keyValuePaths: Array<String> = [],
val typeClashTactic: JSON.TypeClashTactic = JSON.TypeClashTactic.ARRAY_AND_VALUE_COLUMNS,
val unifyNumbers: Boolean = true
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {
implementation(project(":dataframe-spring"))
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-actuator")
runtimeOnly("org.springframework.boot:spring-boot-devtools")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
classDiagram
direction LR
class dataSources
class reportController
class reportService
class springbootDataframeApplication

reportController --> reportService : depends on
reportService --> dataSources : depends on
springbootDataframeApplication ..> dataSources
springbootDataframeApplication ..> reportController
springbootDataframeApplication ..> reportService
springbootDataframeApplication ..> springbootDataframeApplication
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class SpringbootDataframeApplication
open class SpringbootDataframeApplication

fun main(args: Array<String>) {
runApplication<SpringbootDataframeApplication>(*args)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.jetbrains.kotlinx.dataframe.examples.springboot.config

import org.jetbrains.kotlinx.dataframe.spring.DataFramePostProcessor
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
open class DataFrameConfiguration {
@Bean
open fun dataFramePostProcessor(): DataFramePostProcessor = DataFramePostProcessor()
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package org.jetbrains.kotlinx.dataframe.examples.springboot.config

import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.spring.DataFramePostProcessor
import org.jetbrains.kotlinx.dataframe.spring.annotations.CsvDataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.stereotype.Component

@Component
class DataSources {
@CsvDataSource(file = "data/customers.csv")
@CsvDataSource(file = "data/spring/customers.csv")
lateinit var customers: DataFrame<*>

@CsvDataSource(file = "data/sales.csv")
@CsvDataSource(file = "data/spring/sales.csv")
lateinit var sales: DataFrame<*>
}