JavaStandalone

Spring Resource Loader Example

Spring ResourceLoader sample that reads BLOB-backed resources from Oracle AI Database.

Spring#Java#SpringBoot
What this sample helps you learn

This example demonstrates how to implement a custom [Spring Resource Loader](https://docs.spring.io/spring-framework/reference/core/resources.html#resources-resourceloader) to idiomatically load blob resources (such as images or files) at application startup from an arbitrary storage backend.

What this sample demonstrates

Spring

Runnable Spring behavior on Oracle AI Database.

Use when Spring needs to be tested against real database behavior.

Highlights

  • DatabaseResource.java defines custom Resource type extending AbstractResource
  • DatabaseResourceResolver.java implements the Spring ResourceLoaderAware and ProtocolResolver interfaces to provide a Spring Compnent capable of instantiating DatabaseResorce objects.
  • DatabaseLocation.java is a data class that maps a Resource location to a BLOB in the database.