Class HyperonEngineFactory

java.lang.Object
pl.decerto.hyperon.runtime.core.HyperonEngineFactory

@Deprecated public class HyperonEngineFactory extends Object
Deprecated.
This class is very important aspect of higson-runtime configuration. Main responsibility of this class is to create instance of HyperonEngineImpl using create(), that is used in many places during application runtime. Using this factory, developers might have impact on some behaviour of the runtime. It will be described below.

The most important aspect of configuration is to setup dataSource, so this is main action for developer to take. More configuration options are available via flags and setter's. During engine creation, multiple things happens:
1. Watchers are created by default, since autoStartWatchers is set to true
2. Database access points (DAO's) and providers for core elements like functions, parameters, domain are created.
3. Interceptors/listeners might be injected to the engine.
4. Functions invokers supported by higson are created.


There is also possibility for using higson engine in developer mode. By enabling developer mode setDeveloperMode(boolean) to true, and setting userName setUsername(String), runtime will be aware of user perspective(higson session) automatically. For example, if user is making some changes in parameters/function/domain via Higson Studio connected to the same dataSource as runtime, but doesn't want to public the session (so other users can't see it) and his runtime environment will be aware of this change. If developer mode is set to [@code false}, then user in Higson Studio has to manually publish his session, so any changes done to parameters, functions or domain will be available via higson runtime.


Sample basic configuration:

  DataSource ds = ... //
  HyperonEngineFactory factory = new HyperonEngineFactory(ds);
  factory.create();
 
Sample configuration with developer mode ON for username "jason":

  DataSource ds = ... //
  HyperonEngineFactory factory = new HyperonEngineFactory(ds);
  factory.setDeveloperMode(true);
  factory.setUsername("jason");
  factory.create();
 
Author:
przemek hertel
  • Constructor Details

    • HyperonEngineFactory

      public HyperonEngineFactory(DataSource dataSource, ConnectionInterceptor connectionInterceptor)
      Deprecated.
    • HyperonEngineFactory

      public HyperonEngineFactory(DataSource dataSource)
      Deprecated.
  • Method Details

    • setDataSource

      public final void setDataSource(DataSource dataSource)
      Deprecated.
      This method setup dataSource used by higson-runtime with all required elements, like: main access points to parameters, functions, external sources, domain, etc. If developer didn't provided any connection interceptor, then StdConnectionInterceptor will be used.
      Parameters:
      dataSource - that will be used during runtime
    • setDialect

      public void setDialect(String dialect)
      Deprecated.
      Set database dialect, if not used then default dialect supported by higson will be used. But if dialect will not be recognized, then during creation of an engine, UnrecognizedDialectException will be thrown. Supported dialects are defined within DialectRegistry.
      Parameters:
      dialect - code to be set during startup
    • setValueNeverNull

      public void setValueNeverNull(boolean valueNeverNull)
      Deprecated.
      Flag responsible for managing global support of nullable parameters results by engine. If it is set to true (by default), then parameters will never return null, but instead they will return instance of EmptyParamValue.
      Parameters:
      valueNeverNull - true of false to be set
    • setMaxConcurrentLoads

      public void setMaxConcurrentLoads(int maxConcurrentLoads)
      Deprecated.
      Sets limited access to concurrent loads of parameters. Default value is 3. This helps to control usage of resources, since fetching parameters might be very stressful for the application.
      Parameters:
      maxConcurrentLoads - currentLoads maximal number of concurrent loads
    • setSessionProvider

      public void setSessionProvider(MpUserSessionProvider sessionProvider)
      Deprecated.
      Sets session provider, which holds information about a user like userName.
      Parameters:
      sessionProvider - instance of MpUserSessionProvider
    • setAutoStartWatchers

      public void setAutoStartWatchers(boolean autoStartWatchers)
      Deprecated.
      Control flag for starting watchers during engine build. true by default.
      Parameters:
      autoStartWatchers - if true, during engine creation watchers will be created. If false, then nothing will happen.
    • setWatcherStartDelaySeconds

      public void setWatcherStartDelaySeconds(int watcherStartDelaySeconds)
      Deprecated.
      Setup delay of watchers in seconds. Default value is set to WATCHER_DEFAULT_START_DELAY seconds. Parameter and function watchers will have the same delay.
      Parameters:
      watcherStartDelaySeconds - delay in seconds
    • setWatcherPauseSeconds

      public void setWatcherPauseSeconds(int watcherPauseSeconds)
      Deprecated.
      Setup pause of watchers in seconds. Default value is set to WATCHER_DEFAULT_PAUSE seconds. Parameter and function watchers will have the same pause.
      Parameters:
      watcherPauseSeconds - pause in seconds
    • setRefreshWatcherConfig

      public void setRefreshWatcherConfig(WatcherConfig conf)
      Deprecated.
      Sets the refresh watcher configuration (delay, pause, error pause)
    • setDomainWatcherInvalidateCacheTime

      public void setDomainWatcherInvalidateCacheTime(int domainWatcherInvalidateCacheTime, TemporalUnit unit)
      Deprecated.
      Setup lifespan of domain trees in cache, if there are not used. By default domain tree will be removed from cache, if it's last build exceeds WATCHER_DOMAIN_DEFAULT_CACHE_LIFESPAN_VALUE WATCHER_DOMAIN_DEFAULT_CACHE_LIFESPAN_UNIT (or any time defined by this method).
      Parameters:
      domainWatcherInvalidateCacheTime - value of lifespan. By default it will be WATCHER_DOMAIN_DEFAULT_CACHE_LIFESPAN_VALUE
      unit - used with value from lifespan. By default it will be WATCHER_DOMAIN_DEFAULT_CACHE_LIFESPAN_UNIT
    • setWatcherErrorPauseSeconds

      public void setWatcherErrorPauseSeconds(int watcherErrorPauseSeconds)
      Deprecated.
      Setup pause during some error of watchers in seconds. Default value is set to WATCHER_DEFAULT_RECOVERY seconds. Parameter and function watchers will have the same pause.
      Parameters:
      watcherErrorPauseSeconds - error pause in seconds
    • setWatcherForceSyncSeconds

      public void setWatcherForceSyncSeconds(int seconds)
      Deprecated.
      Set the time after which the watcher will force a full cache synchronization. Currently only the param watcher supports this setting.
      Parameters:
      seconds - force sync pause in seconds
    • setScheduleWatcherPauseSeconds

      public void setScheduleWatcherPauseSeconds(int scheduleWatcherPauseSeconds)
      Deprecated.
      Setup pause in seconds of global schedule watcher. Default value is set to SCHEDULE_WATCHER_PAUSE seconds.
      Parameters:
      scheduleWatcherPauseSeconds - value of pause seconds
    • setRhinoPlugins

      @Deprecated public void setRhinoPlugins(Map<String,Object> rhinoPlugins)
      Deprecated.
      - This method will be removed in the future. Please use according setCustomPlugins(Map).
      Parameters:
      rhinoPlugins - Custom plugins, that will be added to the base of higson supported plugins.
    • setCustomPlugins

      public void setCustomPlugins(Map<String,Object> customPlugins)
      Deprecated.
      This method allows developers to inject custom plugins or even override behaviour of higson plugins. Plugins will be added, when method create() is called. Higson supported plugins codes:
      • log
      • date
      • ctx
      • domain
      • util
      Parameters:
      customPlugins - map, where key is plugin code, value is instance of the plugin
    • setParamsToPrefetch

      public void setParamsToPrefetch(List<String> paramsToPrefetch)
      Deprecated.
      Allows to setup a list of parameters codes to be fetched early on system startup.
      Parameters:
      paramsToPrefetch - list of parameters codes
    • setFunctionsToPrefetch

      public void setFunctionsToPrefetch(List<String> functionsToPrefetch)
      Deprecated.
      Allows to setup a list of functions codes to be fetched early on system startup.
      Parameters:
      functionsToPrefetch - list of functions codes
    • addRegionForParametersPrefetch

      public void addRegionForParametersPrefetch(String profileCode, String regionCode)
      Deprecated.
      Allows specifying region code within profile, which is used to fetch parameters early on system startup. Bear in mind that adding too many profileCodes or regionCodes for given profileCode puts a lot of pressure on the database on system startup.
      Parameters:
      profileCode - profile code
      regionCode - region code
    • create

      public HyperonEngineImpl create()
      Deprecated.
      Creates HyperonEngine instance based on given configuration. Here multiple whole structure of an engine is created. First the dialect for database is registered. After that, all providers and invokers for parameters, functions, etc. All supported types for HyperonContext are created here as well. ParamEngineConfigBuilder is used as well to build ParamEngineConfig.

      autoStartWatchers if it is set to true (by default it is), then all watchers for higson main functionalities will be enabled.

      enableDomainCache if it is set to true (by default it is), then domain will be cached and maintained by higson-runtime.

      paramsToPrefetch and functionsToPrefetch gives a possibility to early fetch on startup list of given parameters or functions codes.

      Returns:
      new higson engine
      Throws:
      HyperonRuntimeException - if dataSource is null
    • startParamWatcher

      public ParamRuntimeWatcher startParamWatcher(WatcherConfig config)
      Deprecated.
      Creates, inject watcher event listener and starts parameters runtime watcher.
      Parameters:
      config - for watcher
      Returns:
      instance of started runtime watcher
      See Also:
    • startFunctionWatcher

      public FunctionRuntimeWatcher startFunctionWatcher(WatcherConfig config)
      Deprecated.
      Creates, inject watcher event listener and starts functions runtime watcher.
      Parameters:
      config - for watcher
      Returns:
      instance of started runtime watcher
      See Also:
    • startVersionWatcher

      public VersionRuntimeWatcher startVersionWatcher(WatcherConfig config)
      Deprecated.
      Creates and starts version runtime watcher.
      Parameters:
      config - for watcher
      Returns:
      instance of started runtime watcher
      See Also:
    • createVersionWatcher

      public VersionRuntimeWatcher createVersionWatcher(WatcherConfig config)
      Deprecated.
    • createUserRegionVersionWatcher

      public UserRegionVersionRuntimeWatcher createUserRegionVersionWatcher(WatcherConfig config)
      Deprecated.
    • startScheduleWatcher

      public ScheduleRuntimeWatcher startScheduleWatcher()
      Deprecated.
      Creates and starts schedule runtime watcher. WatcherConfig is using property set via #scheduleWatcherPauseSeconds.
      Returns:
      instance of started runtime watcher
      See Also:
    • startRefreshWatcher

      public RefreshRuntimeWatcher startRefreshWatcher(WatcherConfig config)
      Deprecated.
      Creates and starts refresh runtime watcher, that is responsible for evicting parameters from cache.
      Parameters:
      config - for watcher
      Returns:
      instance of started runtime watcher
      See Also:
    • startDomainWatcher

      public DomainRuntimeWatcher startDomainWatcher(WatcherConfig watcherConf)
      Deprecated.
      Creates and starts domain runtime watcher, if flag enableDomainCache is true.
      Parameters:
      watcherConf - for watcher
      Returns:
      instance of started runtime watcher
      See Also:
    • destroy

      public void destroy()
      Deprecated.
      This method stops all threads created by higson-runtime. All threads have to be stopped so that the JVM process can exit. This is very important to call this method from client application, otherwise the JVM will not stop. Below is the recommended way to free resources:
         HyperonEngineFactory factory;
         HyperonEngine engine;
      
         [PostConstruct]
         public void init() {
           factory = new HyperonEngineFactory(dataSource);
           engine = factory.create();
         }
      
         [PreDestroy]
         public void destroy() {
           factory.destroy();
         }
       
    • setLevelCreatorInterceptor

      public void setLevelCreatorInterceptor(FunctionInvokerInterceptor levelCreatorInterceptor)
      Deprecated.
      Setup level creator interceptor. Higson provides default implementation if not specified.
      Parameters:
      levelCreatorInterceptor - acts as function invoker interceptor
    • setEnableDomainCache

      public void setEnableDomainCache(boolean enableDomainCache)
      Deprecated.
      Control flag, that enables domain caching managed by higson-runtime mechanism. By default it is true.
      Parameters:
      enableDomainCache - control flag
    • setRefreshOnlyViaWatcher

      @Deprecated public void setRefreshOnlyViaWatcher(boolean refreshOnlyViaWatcher)
      Deprecated.
    • setAttributeInterceptor

      public void setAttributeInterceptor(AttributeInterceptor attributeInterceptor)
      Deprecated.
      Setup attribute interceptor for attribute value provider.
      Parameters:
      attributeInterceptor - custom interceptor for domain attributes
      See Also:
    • setWatcherEventListener

      public void setWatcherEventListener(WatcherEventListener watcherEventListener)
      Deprecated.
      Setup watcher event listener for function and parameters runtime watchers.
      Parameters:
      watcherEventListener - custom event listener
    • isDeveloperMode

      public boolean isDeveloperMode()
      Deprecated.
      Checks if developerMode is ON or OFF.
      Returns:
      true if ON, false otherwise
    • setDeveloperMode

      public void setDeveloperMode(boolean developerMode)
      Deprecated.
      Setup higson engine with developer mode. It will change default behaviour of an engine. Default value is false.
      Parameters:
      developerMode - control flag
    • setUsername

      public void setUsername(String username)
      Deprecated.
      Setup username for developer mode.
      Parameters:
      username - to be used
    • setValidateFunctionArgumentsDataTypes

      public void setValidateFunctionArgumentsDataTypes(boolean validateFunctionArgumentsDataTypes)
      Deprecated.
      Setup built-in argument data types validator for function invocation. Default value is false.
      Parameters:
      validateFunctionArgumentsDataTypes - control flag
    • isRefreshOnlyViaWatcher

      @Deprecated public boolean isRefreshOnlyViaWatcher()
      Deprecated.
    • getPythonFunctionInvoker

      public Optional<PythonFunctionInvoker> getPythonFunctionInvoker()
      Deprecated.
    • addExternalDataSources

      public void addExternalDataSources(Map<String,DataSource> dataSourceMap)
      Deprecated.
      Same as setExternalDataSources(Map) and it will iterate over given map and call addExternalDataSource(String, DataSource)
      Parameters:
      dataSourceMap - of datasource and theirs codes
    • addExternalDataSource

      public void addExternalDataSource(String code, DataSource dataSource)
      Deprecated.
      Add external dataSource under given code, so higson will recognize it, when fetching for parameters that have defined this external source.
      Parameters:
      code - under which dataSource will be available
      dataSource - external dataSource
    • setExternalDataSources

      public void setExternalDataSources(Map<String,DataSource> map)
      Deprecated.
      Same as addExternalDataSources(Map) and it will iterate over given map and call addExternalDataSource(String, DataSource)
      Parameters:
      map - of datasource and theirs codes
    • redefineDomainCache

      public void redefineDomainCache(DomainCache newMpDomainCache, MpDomainCacheProvider newDomainCacheProvider, DomainCacheManager newDomainCacheManager)
      Deprecated.
      Setup custom domain cache, provider and manager for it. If developer provider custom implementations, then during create() higson will skip building them on its own.
      Parameters:
      newMpDomainCache - custom domain cache
      newDomainCacheProvider - custom domain cache provider
      newDomainCacheManager - custom domain cache manager
    • setDbSchema

      public void setDbSchema(String dbSchema)
      Deprecated.
      Setup database schema if required. Then all queries within engine will use this schema with queries.
      Parameters:
      dbSchema - to be used in engine queries
    • setExternalModulesForPython

      public void setExternalModulesForPython(List<String> modules)
      Deprecated.
    • setThrowOnNormalizeInputValueException

      public void setThrowOnNormalizeInputValueException(boolean throwOnNormalizeInputValueException)
      Deprecated.
    • addFunctionInvocationInterceptor

      public void addFunctionInvocationInterceptor(FunctionInvocationInterceptor functionInvocationInterceptor)
      Deprecated.
      Add user defined function invocation interceptor. Higson triggers added interceptor before every function invocation.
      Parameters:
      functionInvocationInterceptor - User defined function invocation interceptor
      See Also:
    • setFunctionLogLevelCacheTTL

      public void setFunctionLogLevelCacheTTL(Duration ttl)
      Deprecated.
      Set time-to-live (TTL) for function log level cached entries.
    • attachLogListener

      public void attachLogListener(LogListener logListener)
      Deprecated.
    • setIdleChecker

      public void setIdleChecker(IdleChecker idleChecker)
      Deprecated.
    • setMaxIdleTime

      public void setMaxIdleTime(Duration maxIdleTime)
      Deprecated.
    • setReloadPolicy

      public void setReloadPolicy(ReloadPolicy reloadPolicy)
      Deprecated.