Annotation Interface ConditionalOnBroadleafModule


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented @Conditional(OnBroadleafModuleCondition.class) public @interface ConditionalOnBroadleafModule

Allows for conditional registration of beans depending only if a particular Broadleaf module is present. By default, this checks for the presence of an implementation entry for a BroadleafModuleRegistration in spring.factories.

There are 2 options for checking these registrations:

  1. The type-safe value() which assumes that this class is kept up to date with different modules that are added
  2. The moduleName() which maps directly to the BroadleafModuleRegistration.getModuleName()

Generally you should use the value() attribute to give you a type-safe way to reference the registrations but it is possible that you need to reference a module that has not yet been added to this class. In that case, use the moduleName() parameter which allows for more dynamic checking of module names.

If the module has not registered itself via spring.factories then this will always return false. In this case, utilize one of the Spring ConditionalOn... annotations like ConditionalOnClass and consider making your own composed annotation that utilizes it. For instance:

 @Target({ ElementType.TYPE, ElementType.METHOD })
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @ConditionalOnClass("com.broadleafcommerce.somemodule.ModuleClass")
 public @interface ConditionalOnSomeModule {

 }
 

This annotation can be used as a composed meta-annotation for module-specific annotations. Example:

 @Target({ ElementType.TYPE, ElementType.METHOD })
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @ConditionalOnBroadleafModule(BroadleafModuleEnum.ACCOUNT)
 public @interface ConditionalOnAccountModule {

 }
 
Since:
5.2
Author:
Phillip Verheyden (phillipuniverse)