Class TrackerAccountInitializer

java.lang.Object
com.endurancetrio.business.tracker.service.TrackerAccountInitializer

@Service public class TrackerAccountInitializer extends Object
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 Details

    • TrackerAccountInitializer

      @Autowired public TrackerAccountInitializer(TrackerAccountRepository trackerAccountRepository)
  • 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:

      1. Validates that both owner and hash configuration are present
      2. Checks if an account with the same owner already exists
      3. Updates the key hash if an account with the same owner already exists
      4. Creates and persists the new tracker account if none exists with the provided owner