- java.lang.Object
-
- aeonics.template.Item<T>
-
- aeonics.manager.Manager<T>
-
- Type Parameters:
T
- The manager entity type
public abstract class Manager<T extends Manager.Type> extends Item<T>
This class acts as a central registry for entities that must have only one authoritative instance. It is used typically for application-wide cross cutting concerns.As an entity, it represents a class that can only exists once in the system. All Manager instances must extend this class and should be registered using
set(Class, Type)
.All Manager Type instances are considered internal and will never be affected by a snapshot or restore operation. This means that managers must not have own instance parameters. If needed, use config parameters instead.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Manager.Type
Basic manager entity superclass
-
Constructor Summary
Constructors Constructor Description Manager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.Iterable<Manager.Type>
all()
Returns an iterator over all managersprotected java.lang.Class<? extends Manager<T>>
category()
Returns the target entity category.static <T extends Manager.Type>
Tof(java.lang.Class<T> type)
Returns the instance of the specified manageable typestatic <T extends Manager.Type>
voidremove(java.lang.Class<T> type)
Removes the instance of a manageable typestatic <T extends Manager.Type>
Treplace(java.lang.Class<T> type, T instance)
Replaces the instance of the specified entity type.static <T extends Manager.Type>
Tset(java.lang.Class<T> type, T instance)
Sets the instance of the specified manager type.-
Methods inherited from class aeonics.template.Item
creator, creator, defaultCreator, defaultTarget, defaultType, from, target, target, template, type, type
-
-
-
-
Method Detail
-
of
public static <T extends Manager.Type> T of(java.lang.Class<T> type)
Returns the instance of the specified manageable type- Type Parameters:
T
- the manageable type- Parameters:
type
- the manager type- Returns:
- the instance of the specified entity type, or null if none was registered
-
set
public static <T extends Manager.Type> T set(java.lang.Class<T> type, T instance)
Sets the instance of the specified manager type. The instance must not be null.- Type Parameters:
T
- the manageable instance type- Parameters:
type
- the manageable typeinstance
- the instance- Returns:
- the instance that has been set
- Throws:
java.lang.RuntimeException
- if another instance is already registered for this entity typejava.lang.IllegalArgumentException
- if the instance is not an instance of the specified entity type
-
remove
public static <T extends Manager.Type> void remove(java.lang.Class<T> type)
Removes the instance of a manageable type- Type Parameters:
T
- the manageable type- Parameters:
type
- the manageable type
-
replace
public static <T extends Manager.Type> T replace(java.lang.Class<T> type, T instance)
Replaces the instance of the specified entity type. The instance must not be null.- Type Parameters:
T
- the manageable instance type- Parameters:
type
- the entity typeinstance
- the instance- Returns:
- the instance that has been set
- Throws:
java.lang.IllegalArgumentException
- if the instance is not an instance of the specified entity type
-
all
public static java.lang.Iterable<Manager.Type> all()
Returns an iterator over all managers- Returns:
- a manager iterator
-
category
protected java.lang.Class<? extends Manager<T>> category()
Description copied from class:Item
Returns the target entity category. This method should be implemented by subclasses to specify the entity category.- Specified by:
category
in classItem<T extends Manager.Type>
- Returns:
- the target entity category
-
-