Package io.higson.runtime.engine.config
Class ParamEngineConfigBuilder
java.lang.Object
io.higson.runtime.engine.config.ParamEngineConfigBuilder
ParamEngine configuration builder. Call build() to create
immutable configuration object that should be used to construct
new ParamEngine instance using ParamEngineFactory.
- Author:
- Adam Dubiel
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Finalizes configuration building and returns immutable config object.static ParamEngineConfigBuilderStart building configuration.registerModule(ParamEngineModule module) Add a self-registering module that encapsulates all self configuration.Disable annotation scanning, this will return bare ParamEngine without any default components.withComponent(Object component) Replace default ParamEngine components with custom one.withComponentInitializers(ComponentInitializer... initializers) Register additionalComponentInitializer.withFunctionCache(FunctionCache functionCache) Register customFunctionCache.withFunctionInvocationInterceptor(FunctionInvocationInterceptor functionInvocationInterceptor) RegisterFunctionInvocationInterceptorwithFunctionInvocationInterceptors(List<FunctionInvocationInterceptor> functionInvocationInterceptors) RegisterFunctionInvocationInterceptor'swithFunctionInvoker(String functionType, FunctionInvoker invoker) RegisterFunctionInvoker.withFunctionInvoker(String functionType, FunctionInvoker invoker, boolean supported) RegisterFunctionInvokerifsupportedis true.withFunctionRepository(String functionType, int order, FunctionRepository repository) RegisterFunctionRepositorywith given order (default repository has priority 100).withIdleChecker(IdleChecker idleChecker) Register custom implementation of initialization runner.withMatcher(String code, Matcher matcher) RegisterMatcherunder code.withOutputLevelArraySeparator(OutputLevelArraySeparator arraySeparator) specify output level array separator that will be used while extracting parameter output values.withPackagesToScan(PackageList packagesToScan) Add packages that will be scanned in search of SmartParam annotations.withPackagesToScan(String... packagesToScan) Add packages (including all descendants) that will be scanned in search of SmartParam annotations.withParameterCache(PreparedParamCache parameterCache) Register customPreparedParamCache.withParameterRepositories(ParamRepository... repositories) Register parameter repositories.withProperties(Properties properties) <T extends ValueHolder>
ParamEngineConfigBuilderRegisterTypeunder code.
-
Method Details
-
paramEngineConfig
Start building configuration.- Returns:
- param config builder
-
build
Finalizes configuration building and returns immutable config object.- Returns:
- instance of param engine config
-
withAnnotationScanDisabled
Disable annotation scanning, this will return bare ParamEngine without any default components.- Returns:
- the same instance of builder
-
withPackagesToScan
Add packages (including all descendants) that will be scanned in search of SmartParam annotations. By default SmartParam only scans default package (org.smartparam.engine) which provides a base set of capabilities. It is also possible to disable annotation scanning by usingwithAnnotationScanDisabled().- Parameters:
packagesToScan- packages to add- Returns:
- the same instance of builder
-
withPackagesToScan
Add packages that will be scanned in search of SmartParam annotations. By default SmartParam only scans default package (org.smartparam.engine) which provides a base set of capabilities. It is also possible to disable annotation scanning by usingwithAnnotationScanDisabled().- Parameters:
packagesToScan- packages to add- Returns:
- the same instance of builder
-
withComponent
Replace default ParamEngine components with custom one. This method should be used when you want to go deeper and replace one of ParamEngine core interfaces. If so, register object instance that implements interface of component you want to replace. For details on what are interfaces and classes, please take a look at source code ofParamEngineConfig.injectDefaults(java.util.List).- Parameters:
component- component to add- Returns:
- the same instance of builder
-
registerModule
Add a self-registering module that encapsulates all self configuration.- Parameters:
module- object of ParamEngineModule interface.- Returns:
- the same instance of builder
-
withParameterRepositories
Register parameter repositories. There has to be at least one registered. Order of registration matters, as it determines order of querying. First repository that contains parameter wins.- Parameters:
repositories- object of ParamRepository interface.- Returns:
- the same instance of builder
-
withFunctionRepository
public ParamEngineConfigBuilder withFunctionRepository(String functionType, int order, FunctionRepository repository) RegisterFunctionRepositorywith given order (default repository has priority 100). Order might matter if you plan on overwriting functions from one repository with function with the other. Highest order goes last.- Parameters:
functionType- function typeorder- order numberrepository- object of FunctionRepository interface- Returns:
- the same instance of builder
-
withFunctionInvoker
RegisterFunctionInvoker.- Parameters:
functionType- function typeinvoker- object ofFunctionInvokerinterface- Returns:
- the same instance of builder
-
withFunctionInvoker
public ParamEngineConfigBuilder withFunctionInvoker(String functionType, FunctionInvoker invoker, boolean supported) RegisterFunctionInvokerifsupportedis true.- Parameters:
functionType- function typeinvoker- object ofFunctionInvokerinterfacesupported- control flag- Returns:
- the same instance of builder
-
withFunctionInvocationInterceptor
public ParamEngineConfigBuilder withFunctionInvocationInterceptor(FunctionInvocationInterceptor functionInvocationInterceptor) RegisterFunctionInvocationInterceptor- Parameters:
functionInvocationInterceptor- key for type- Returns:
- the same instance of builder
-
withFunctionInvocationInterceptors
public ParamEngineConfigBuilder withFunctionInvocationInterceptors(List<FunctionInvocationInterceptor> functionInvocationInterceptors) RegisterFunctionInvocationInterceptor's- Parameters:
functionInvocationInterceptors- key for type- Returns:
- the same instance of builder
-
withProperties
-
withIdleChecker
-
withType
RegisterTypeunder code.- Type Parameters:
T- generic that extendsValueHolder- Parameters:
code- key for typetype- object of Type interface- Returns:
- the same instance of builder
-
withMatcher
RegisterMatcherunder code.- Parameters:
code- key for matchermatcher- object of Matcher interface- Returns:
- the same instance of builder
-
withFunctionCache
Register customFunctionCache.- Parameters:
functionCache- object of FunctionCache interface- Returns:
- the same instance of builder
-
withParameterCache
Register customPreparedParamCache.- Parameters:
parameterCache- object of PreparedParamCache interface- Returns:
- the same instance of builder
-
withInitializationRunner
Register custom implementation of initialization runner. This goes deep into ParamEngine construction process, so watch out.- Parameters:
runner- object of ComponentInitializerRunner interface- Returns:
- the same instance of builder
-
withComponentInitializers
Register additionalComponentInitializer. These are useful if custom component needs custom initialization (andPostConstructInitializeris not enough.- Parameters:
initializers- object of ComponentInitializer interface- Returns:
- the same instance of builder
-
withOutputLevelArraySeparator
public ParamEngineConfigBuilder withOutputLevelArraySeparator(OutputLevelArraySeparator arraySeparator) specify output level array separator that will be used while extracting parameter output values.- Parameters:
arraySeparator- output level array separator that will be used in Higson Engine- Returns:
- the same instance of builder
- See Also:
-