Package com.smeup.kokos.sdk.entity
Class EntityManager
java.lang.Object
com.smeup.kokos.sdk.entity.EntityManager
Global, singleton entry-point to retrieve
EntityRepository instances.
Lifecycle
The EntityManager must be initialized exactly once at application
startup via init(EntityManagerConfig) before any other call. After initialization the
internal registry is immutable — no further registrations are possible. This design makes the
singleton safe to use from any thread without synchronization after startup.
Registration
Repositories are registered through EntityManagerConfig, by calling the register method with
a Repository instance: config.register(MyEntity.class, new MyEntityRepository())
-
Method Summary
Modifier and TypeMethodDescriptionstatic EntityManagerReturns the globally sharedEntityManagerinstance.Set<Class<? extends AbstractEntity>> Returns the set of all entity classes that have a registered repository.<T extends AbstractEntity>
EntityRepository<T> getRepository(Class<T> entityClass) Returns the repository registered for the given entity class.static voidinit(EntityManagerConfig config) Initializes the singleton from the supplied configuration.
-
Method Details
-
init
Initializes the singleton from the supplied configuration. Must be called once beforegetInstance().- Parameters:
config- the configuration produced at startup- Throws:
EntityManagerInitException- ifinitis called more than once
-
getInstance
Returns the globally sharedEntityManagerinstance.- Throws:
EntityManagerInitException- ifinit(EntityManagerConfig)has not been called yet
-
getRepository
Returns the repository registered for the given entity class.- Type Parameters:
T- the entity type- Parameters:
entityClass- the concrete entity class (must extendAbstractEntity)- Returns:
- the registered
EntityRepository - Throws:
RepositoryNotFoundException- if no repository is registered forentityClass
-
getRegisteredEntityClasses
Returns the set of all entity classes that have a registered repository. Useful for dynamic lookups where only a class name or T+P key is available.
-