Class TrackerAccountInitializer
java.lang.Object
com.endurancetrio.business.tracker.service.TrackerAccountInitializer
Service responsible for initializing the first tracker account upon application startup.
This service checks for the presence of environment variables FIRST_OWNER and
FIRST_HASH during application startup. If both variables are provided and valid, it
creates the initial tracker account in the database. If an account with the provided owner name
already exists in the database, its key hash will be overridden with the provided key hash.
-
Constructor Summary
ConstructorsConstructorDescriptionTrackerAccountInitializer(TrackerAccountRepository trackerAccountRepository) -
Method Summary
Modifier and TypeMethodDescriptionvoidInitializes the first tracker account upon application startup if configuration is provided.
-
Constructor Details
-
TrackerAccountInitializer
-
-
Method Details
-
accountInitializer
@Transactional @EventListener(org.springframework.boot.context.event.ApplicationReadyEvent.class) public void accountInitializer()Initializes the first tracker account upon application startup if configuration is provided.This method is automatically triggered when the application is fully started and ready. It performs the following steps:
- Validates that both owner and hash configuration are present
- Checks if an account with the same owner already exists
- Updates the key hash if an account with the same owner already exists
- Creates and persists the new tracker account if none exists with the provided owner
-