Java Standalone

Spring Resource Loader Example

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

#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.

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.