java.lang.Object
net.odoframework.container.ModuleBuilder
- All Implemented Interfaces:
BiFunction<Container,Properties,Container>,Module
- Direct Known Subclasses:
Application
public abstract class ModuleBuilder extends Object implements Module
The module builder is a utility class which provides convenience methods for registering
BeanDefinition instances for the Module-
Constructor Summary
Constructors Constructor Description ModuleBuilder() -
Method Summary
Modifier and Type Method Description <T extends Runnable>
ModuleBuilderaddStartupBean(Class<T> type)This is used to register a bean which must be run when all the modules have been loaded<T extends Runnable>
ModuleBuilderaddStartupBean(BeanDefinition<T> bean)This is used to register a bean which must be run when all the modules have been loadedprotected voidafterContainerPopulated(Container container)Can be used to implement custom logic after thebuild()method is invokedContainerapply(Container container, Properties properties)protected voidbeforeContainerPopulated(Container container)Can be used to implement custom logic before thebuild()method is invokedabstract voidbuild()This method is implemented and called as a hook to addBeanDefinitioninstances to the moduleContainergetContainer()returns the container associated with this BuilderSet<Module>getDependencies()returns the set of the modules that are dependant for this Modulestatic Set<String>getStartupBeans()Set of startup beans registered by theModuleBuilder<T> BeanDefinition<T>provides(Class<T> type)Creates an instance of aBeanDefinitionclass which has the name of the passed type<T> BeanDefinition<T>provides(String name)Creates an instance of aBeanDefinitionclass which has the name of the parameterprotected ModuleBuilderregister(BeanDefinition<?> beanDefinition)Register an instance of aBeanDefinitionto be loaded as part of the container<K, T extends Consumer<K>>
ModuleBuilderregisterEventHandler(Class<K> eventType, BeanDefinition<T> beanDefinition)Registered an Event handlerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.function.BiFunction
andThenMethods inherited from interface net.odoframework.container.Module
getPrecedence
-
Constructor Details
-
ModuleBuilder
public ModuleBuilder()
-
-
Method Details
-
getStartupBeans
Set of startup beans registered by theModuleBuilder- Returns:
-
getDependencies
returns the set of the modules that are dependant for this Module- Specified by:
getDependenciesin interfaceModule- Returns:
- a set of the dependant modules
-
register
Register an instance of aBeanDefinitionto be loaded as part of the container- Parameters:
beanDefinition- the bean definition to inject- Returns:
- self, allowing for fluent builders
-
provides
Creates an instance of aBeanDefinitionclass which has the name of the parameter- Type Parameters:
T- the return type of theBeanDefinitioninstance- Parameters:
name- the name to register in the container- Returns:
- the newly created
BeanDefinitioninstance
-
registerEventHandler
public <K, T extends Consumer<K>> ModuleBuilder registerEventHandler(Class<K> eventType, BeanDefinition<T> beanDefinition)Registered an Event handler- Type Parameters:
T-- Parameters:
eventType-beanDefinition-- Returns:
-
provides
Creates an instance of aBeanDefinitionclass which has the name of the passed type- Type Parameters:
T- the return type of theBeanDefinitioninstance- Parameters:
type- the type to use as a name to register in the container- Returns:
- the newly created
BeanDefinitioninstance
-
getContainer
returns the container associated with this Builder- Returns:
-
apply
- Specified by:
applyin interfaceBiFunction<Container,Properties,Container>
-
beforeContainerPopulated
Can be used to implement custom logic before thebuild()method is invoked- Parameters:
container- the container which will be populated withBeanDefinitioninstances
-
afterContainerPopulated
Can be used to implement custom logic after thebuild()method is invoked- Parameters:
container- the container which will be populated withBeanDefinitioninstances
-
addStartupBean
This is used to register a bean which must be run when all the modules have been loaded- Type Parameters:
T- The returned type of the bean must implementRunnable- Parameters:
bean- theBeanDefinitioninstance to run during startup- Returns:
- ModuleBuilder instance to allow for fluent builder
-
addStartupBean
This is used to register a bean which must be run when all the modules have been loaded- Type Parameters:
T- The returned type of the bean must implementRunnable- Parameters:
type- creates aBeanDefinitionwith the parameter as a name and adds it as a startup bean- Returns:
- ModuleBuilder instance to allow for fluent builder
-
build
public abstract void build()This method is implemented and called as a hook to addBeanDefinitioninstances to the module
-