Package it.tidalwave.role.spi
Class SystemRoleFactorySupport
java.lang.Object
it.tidalwave.role.spi.SystemRoleFactorySupport
- All Implemented Interfaces:
SystemRoleFactory
A basic implementation of a
SystemRoleFactory
. This class must be specialized to:
- discover roles (see
scan(java.util.Collection)
- associate roles to a datum (see
findDatumTypesForRole(java.lang.Class)
- associate roles to contexts (see
findContextTypeForRole(java.lang.Class)
- eventually retrieve beans to inject in created roles (see
getBean(java.lang.Class)
- Author:
- Fabrizio Giudici
-
Nested Class Summary
Nested classes/interfaces inherited from interface it.tidalwave.role.spi.SystemRoleFactory
SystemRoleFactory.Inner
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindContextTypeForRole
(Class<?> roleImplementationType) Returns the type of the context associated to the given role implementation type.protected Class<?>[]
findDatumTypesForRole
(Class<?> roleImplementationType) Returns the valid datum types for the given role implementation type.<T> List
<T> Retrieves the roles of the given class for the given owner object.protected <T> Optional
<T> Retrieves an extra bean.void
logRoles()
protected void
scan
(Collection<Class<?>> roleImplementationTypes) Scans all the given role implementation classes and build a map of roles by owner class.
-
Constructor Details
-
SystemRoleFactorySupport
public SystemRoleFactorySupport()
-
-
Method Details
-
findRoles
Retrieves the roles of the given class for the given owner object.- Specified by:
findRoles
in interfaceSystemRoleFactory
- Type Parameters:
T
- the static type of the roles- Parameters:
datum
- the owner objectroleType
- the dynamic type of the roles- Returns:
- a list of roles
-
scan
Scans all the given role implementation classes and build a map of roles by owner class.- Parameters:
roleImplementationTypes
- the types of role implementations to scan
-
getBean
Retrieves an extra bean.- Type Parameters:
T
- the static type of the bean- Parameters:
beanType
- the dynamic type of the bean- Returns:
- the bean
-
findContextTypeForRole
@Nonnull protected Optional<Class<?>> findContextTypeForRole(@Nonnull Class<?> roleImplementationType) Returns the type of the context associated to the given role implementation type.- Parameters:
roleImplementationType
- the role type- Returns:
- the context type
-
findDatumTypesForRole
Returns the valid datum types for the given role implementation type.- Parameters:
roleImplementationType
- the role type- Returns:
- the datum types
-
logRoles
public void logRoles()
-