Package com.alpaca.service.impl
Class DataServiceImpl
java.lang.Object
com.alpaca.service.impl.DataServiceImpl
- All Implemented Interfaces:
DataService
Service responsible for seeding essential application data upon startup.
Implements DataService
and initializes default permissions, roles, users, and
profiles. Listens for ApplicationReadyEvent
to trigger post-startup actions, such as
warming up caches or validating system readiness.
This ensures the application is populated with baseline data when it starts in a clean state.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PasswordManager
private final IPermissionService
private final IProfileService
private final IRoleService
private final IUserService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Seeds the database with default permissions, roles, users, and profiles, only if no user records already exist.void
Invoked after the application is fully initialized and ready to serve requests.
-
Field Details
-
permissionService
-
roleService
-
userService
-
profileService
-
passwordManager
-
-
Constructor Details
-
DataServiceImpl
public DataServiceImpl()
-
-
Method Details
-
initializeData
@Transactional public void initializeData()Seeds the database with default permissions, roles, users, and profiles, only if no user records already exist.Marked
Transactional
to ensure atomicity and rollback safety.- Specified by:
initializeData
in interfaceDataService
-
warmUpHibernate
@EventListener(org.springframework.boot.context.event.ApplicationReadyEvent.class) public void warmUpHibernate()Invoked after the application is fully initialized and ready to serve requests. Triggers a base call to preload roles and logs system readiness.Using
EventListener
withApplicationReadyEvent
ensures this runs only once the Spring context is fully set up.
-