Interface ResourceWithLifecycle

All Known Implementing Classes:
AzureBicepResource, AzureEventHubsResource, AzureOpenAIResource, AzureStorageBlobsResource, AzureStorageChildResource, AzureStorageQueuesResource, AzureStorageResource, AzureStorageTablesResource, Container, DockerFile, EurekaServiceDiscovery, Executable, MicronautProject, MicroserviceProject, QuarkusProject, Resource, SpringProject, Value

public interface ResourceWithLifecycle
All resources have a lifecycle, beginning with creation and ending with the resource being written out to the Java App Host manifest. Within this lifecycle, there are times when the resource should ideally be configured, introspected, and then written out. The stages of a resources lifecycle are:
  1. Resource is created - Resource constructor is called.
  2. Resource is added to the distributed application - onResourceAdded() is called.
  3. Prior to writing the resource to the manifest, onResourcePrecommit() is called on all resources in the order they were added to the distributed application.

The most important point to understand about resource lifecycles is that resources work best when they are configured as early as possible, as this allows for other resources to glean more information from them. A resource that keeps its cards close to its chest only hurts the resources around it!

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    This method is called immediately after the resource is added to the distributed application.
    default void
    Prior to writing the resource to the manifest, onResourcePrecommit() is called on all resources in the order they were added to the distributed application.
    default void
    This method is called immediately after the resource is removed from the distributed application.
  • Method Details

    • onResourceAdded

      default void onResourceAdded()
      This method is called immediately after the resource is added to the distributed application. It is the earliest time that the resource can be configured.
    • onResourceRemoved

      default void onResourceRemoved()
      This method is called immediately after the resource is removed from the distributed application.
    • onResourcePrecommit

      default void onResourcePrecommit()
      Prior to writing the resource to the manifest, onResourcePrecommit() is called on all resources in the order they were added to the distributed application.