Class CustomModelClassesRegistrar
java.lang.Object
org.openehealth.ipf.modules.hl7.config.CustomModelClassesRegistrar
- All Implemented Interfaces:
Aware, BeanFactoryAware, SmartInitializingSingleton
public class CustomModelClassesRegistrar
extends Object
implements BeanFactoryAware, SmartInitializingSingleton
Collects the
CustomModelClasses beans of the application context and adds their
package definitions to the CustomModelClassFactory instances in use. A single bean
declaration is enough:
<bean class="org.openehealth.ipf.modules.hl7.config.CustomModelClassesRegistrar"/>
If setCustomModelClassFactory(CustomModelClassFactory) is not set, all
CustomModelClassFactory beans of the application context are configured -- which is
what makes this work out of the box in Spring Boot, where the factory bean is contributed by
auto-configuration and frequently replaced by the application.
Collecting happens in afterSingletonsInstantiated(), i.e. before the
ContextRefreshedEvent and thus well before any HL7v2 message is parsed.
This replaces the deprecated CustomModelClassFactoryConfigurer.
- Since:
- 6.0
- Author:
- Christian Ohr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddModels(CustomModelClassFactory factory, CustomModelClasses contribution, boolean recursively) Adds the package definitions of the given contribution to the factory and, if requested, to its chain ofCustomModelClassFactorydelegates.voidThe factory to be configured.booleanWhether the delegates of aCustomModelClassFactoryshall be configured as well.voidsetBeanFactory(@NonNull BeanFactory beanFactory) voidsetConfigureRecursively(boolean configureRecursively) Whether the delegates of aCustomModelClassFactoryshall be configured as well.voidsetCustomModelClassFactory(CustomModelClassFactory customModelClassFactory) The factory to be configured.
-
Constructor Details
-
CustomModelClassesRegistrar
public CustomModelClassesRegistrar()
-
-
Method Details
-
setBeanFactory
- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- See Also:
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiatedin interfaceSmartInitializingSingleton
-
addModels
public static void addModels(CustomModelClassFactory factory, CustomModelClasses contribution, boolean recursively) Adds the package definitions of the given contribution to the factory and, if requested, to its chain ofCustomModelClassFactorydelegates. Package definitions that the factory already knows about are skipped, so that a contribution reaching a factory both directly and through a deprecatedCustomModelClassFactoryConfigureris only added once.- Parameters:
factory- model class factory to configurecontribution- custom model classes to addrecursively- whether to configure the delegates as well
-
getCustomModelClassFactory
The factory to be configured. If null, allCustomModelClassFactorybeans of the application context are configured. -
setCustomModelClassFactory
The factory to be configured. If null, allCustomModelClassFactorybeans of the application context are configured. -
isConfigureRecursively
public boolean isConfigureRecursively()Whether the delegates of aCustomModelClassFactoryshall be configured as well. -
setConfigureRecursively
public void setConfigureRecursively(boolean configureRecursively) Whether the delegates of aCustomModelClassFactoryshall be configured as well.
-