Class RegionConnectorRegistrationBeanPostProcessor

java.lang.Object
energy.eddie.spring.RegionConnectorRegistrationBeanPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.core.Ordered

public class RegionConnectorRegistrationBeanPostProcessor extends Object implements org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.core.Ordered
  • Field Details

    • ENABLED_REGION_CONNECTOR_BEAN_NAME

      public static final String ENABLED_REGION_CONNECTOR_BEAN_NAME
      Name of the Bean registered in the core context that holds a list of the IDs of the enabled region connectors.
      See Also:
    • REGION_CONNECTORS_SCAN_BASE_PACKAGE

      public static final String REGION_CONNECTORS_SCAN_BASE_PACKAGE
      Base package under which all region connectors are located.
      See Also:
    • OUTBOUND_CONNECTORS_SCAN_BASE_PACKAGE

      public static final String OUTBOUND_CONNECTORS_SCAN_BASE_PACKAGE
      See Also:
  • Constructor Details

    • RegionConnectorRegistrationBeanPostProcessor

      public RegionConnectorRegistrationBeanPostProcessor(org.springframework.core.env.Environment environment)
  • Method Details

    • classForBeanDefinition

      public static Class<?> classForBeanDefinition(org.springframework.beans.factory.config.BeanDefinition definition)
    • enableSpringDoc

      public static void enableSpringDoc(org.springframework.web.context.support.AnnotationConfigWebApplicationContext applicationContext)
      Enables SpringDoc OpenAPI in the specified applicationContext by in registering the necessary Spring and Swagger Beans. The documentation will be available at the urlMapping of the context's dispatcher servlet, e.g. "/region-connectors/dk-energinet/v3/api-docs".
      Parameters:
      applicationContext - Context for which to enable the SpringDoc support.
    • postProcessBeanDefinitionRegistry

      public void postProcessBeanDefinitionRegistry(@NonNull org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws InitializationException
      Scans the "energy.eddie.regionconnector" package for any classes that are annotated with RegionConnector and creates a separate context and DispatcherServlet for each found class, which will be registered with the registry passed to this processor.

      Important: Only region connectors that have their property region-connector.RC-NAME.enabled explicitly set to true are loaded.

      The DispatcherServlet has its URL mapping set to "/"region-connectors"/{RC-NAME}/*" whereas RC-NAME is specified by RegionConnector.name().

      Specified by:
      postProcessBeanDefinitionRegistry in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Parameters:
      registry - the bean definition registry used by the application context
      Throws:
      InitializationException - If no region connector has been enabled in the application.properties file or any other unexpected initialization error occurs.
    • postProcessBeanFactory

      public void postProcessBeanFactory(@NonNull org.springframework.beans.factory.config.ConfigurableListableBeanFactory unusedBeanFactory) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • getOrder

      public int getOrder()
      Run this processor as the last one. Spring documentation recommends to implement Ordered interface for bean post processors.
      Specified by:
      getOrder in interface org.springframework.core.Ordered
      Returns:
      Integer.MAX_VALUE