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 PasswordManagerprivate final IPermissionServiceprivate final IProfileServiceprivate final IRoleServiceprivate final IUserService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSeeds the database with default permissions, roles, users, and profiles, only if no user records already exist.voidInvoked 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
Transactionalto ensure atomicity and rollback safety.- Specified by:
initializeDatain 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
EventListenerwithApplicationReadyEventensures this runs only once the Spring context is fully set up.
-