public class HyperonPersistenceFactory extends Object
dataSource - main application (probably) separate data source with mapped tables, that matches
BundleDef. This field is mandatory.hyperonDataSource - additional data source with Hyperon tables.identifierGenerator - if not provided, we will create it for you with default name "gmo_sequence" and alloc pool of
100.bundleCache - it is possible to provide custom cache or use embedded, provided engine.Engine supports different dialects for Hyperon Persistence dataSource and Hyperon dataSource. It means that, application might be connected to MSSQL and Hyperon Studio on Oracle. By default, Oracle dialect is used.
Example - simple config:
HyperonPersistenceFactory factory = new HyperonPersistenceFactory();
factory.setHyperonDataSource(hyperonDataSource());
factory.setDataSource(applicationDataSource());
With this config, default data will be used as follows:
HyperonPersistenceFactory factory = new HyperonPersistenceFactory();
factory.setHyperonDataSource(hyperonDataSource());
factory.setDataSource(applicationDataSource());
factory.setAutoStartWatchers(false);
factory.setDefaultProfile("CUSTOM_PROFILE");
factory.setGmoDbDialect("mssql2012");
factory.setHiloSequenceName("persistence_seq");
factory.setBundleTable("persistence_bundle");
factory.setBundleColumn("bid");
factory.setOwnerColumn("parentid");
factory.setOwnerPropertyColumn("collname");
create(),
IdentifierDao,
IdentifierGenerator,
DynamicDao,
HyperonPersistenceRuntimeWatcher| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CACHE_NAME |
static int |
DEFAULT_HILO_ALLOC |
static String |
DEFAULT_HILO_SEQUENCE |
static String |
DEFAULT_PROFILE_NAME |
| Constructor and Description |
|---|
HyperonPersistenceFactory() |
| Modifier and Type | Method and Description |
|---|---|
BundleService |
create()
Creates
BundleService instance based on provided configuration. |
void |
destroy()
Right now it will just stop watchers.
|
BundleCache |
getCache()
Deprecated.
this method might be removed in the future.
|
GmoCacheManager |
getCacheManager()
Get Hyperon Persistence cache manager.
|
DaoConfig |
getConf()
Deprecated.
this method might be removed in the future.
|
DynamicDao |
getDao()
Deprecated.
this method might be removed in the future.
|
String |
getDefaultProfile()
Gets default profile, used within Hyperon Persistence engine.
|
DynamicDao |
getDynamicDao()
Deprecated.
this method might be removed in the future, should not be used outside Hyperon-Persistence.
|
String |
getGmoDbDialect()
Gets separate dialect for Hyperon Persistence engine.
|
GmoSandboxLoader |
getGmoSandboxLoader()
Deprecated.
this method might be removed in the future.
|
HyperonPersistenceRuntimeWatcher |
getHyperonPersistenceWatcher()
Gets Hyperon Persistence engine watcher.
|
IdentifierGenerator |
getIdentifierGenerator()
Deprecated.
This method might be removed in the future.
|
GmoSandboxDao |
getSandboxDao()
Deprecated.
Will be removed in the future.
|
void |
setAutoStartWatchers(boolean autoStartWatchers)
Setup flag, that controls watcher on
create(). |
void |
setBundleColumn(String bundleColumn)
Setup column name for bundle reference (foreign key to bundle id).
|
void |
setBundleTable(String bundleTable)
Setup bundle table name.
|
void |
setCache(BundleCache cache)
Setup custom cache for bundle storage, that is used within
BundleService implementation for boosting performance. |
void |
setCacheName(String cacheName)
Setup custom cache name for
BundleCache implementation, for cache manager (if there is any). |
void |
setDatabaseFetchStatsCache(DatabaseFetchStatsCache statsCache)
Setup custom cache for database fetch statistic storage, that is used within
BundleService. |
void |
setDataSource(DataSource dataSource)
Setup
dataSource, to which Hyperon Persistence engine should be connected to. |
void |
setDefaultProfile(String defaultProfile)
Setup default profile for Hyperon Persistence engine.
|
void |
setGmoDbDialect(String gmoDbDialect)
Setup separate dialect for Hyperon Persistence engine from Hyperon Engine (runtime).
|
void |
setHiloAllocationSize(int hiloAllocationSize)
Setup allocation size for
identifierGenerator. |
void |
setHiloSequenceName(String hiloSequenceName)
Setup sequence name for
identifierGenerator. |
void |
setHyperonDataSource(DataSource hyperonDataSource)
Setup
hyperonDataSource, to which Hyperon Persistence engine should be connected to. |
void |
setIdentifierGenerator(IdentifierGenerator identifierGenerator)
Setup custom identifier generator, that will be used by Hyperon Persistence Engine.
|
void |
setOwnerColumn(String ownerColumn)
Setup column name owner/parent reference (foreign key to owner id).
|
void |
setOwnerPropertyColumn(String ownerPropertyColumn)
Setup column name, that will hold mapping to owner property name.
|
void |
setSandboxWatcherErrorPause(int sandboxWatcherErrorPause)
Setup sandbox watcher error pause in seconds.
|
void |
setSandboxWatcherPause(int sandboxWatcherPause)
Setup sandbox watcher pause in seconds.
|
void |
setSandboxWatcherStartDelay(int sandboxWatcherStartDelay)
Setup sandbox watcher start delay in seconds.
|
void |
setSchema(String schema)
Setup schema for
dataSource. |
void |
setUseColumnMetadataCache(boolean useColumnMetadataCache)
true if table metadata should be used, false otherwise
|
void |
startSandboxWatcher()
This method is called during BundleService creation
create(), if autoStartWatchers == true. |
void |
stopSandboxWatcher()
It will stop watcher, if
persistenceRuntimeWatcher was defined. |
public static final String DEFAULT_HILO_SEQUENCE
public static final int DEFAULT_HILO_ALLOC
public static final String DEFAULT_CACHE_NAME
public static final String DEFAULT_PROFILE_NAME
public BundleService create()
BundleService instance based on provided configuration. The most important aspect is to setup dataSource with
setDataSource(DataSource). Other fields are optional and BundleService will be created with default configuration. Before this method
might be called, there is possibility to setup some custom configuration with provided setters in this class.HyperonPersistenceException - if dataSource is nullpublic void startSandboxWatcher()
create(), if autoStartWatchers == true. If not, then it can be invoked
manually here.HyperonPersistenceRuntimeWatcher,
WatcherConfigpublic void stopSandboxWatcher()
persistenceRuntimeWatcher was defined.public void destroy()
stopSandboxWatcher()public void setDataSource(DataSource dataSource)
dataSource, to which Hyperon Persistence engine should be connected to. In most cases it will be separate application dataSource.dataSource - application data sourcepublic void setHyperonDataSource(DataSource hyperonDataSource)
hyperonDataSource, to which Hyperon Persistence engine should be connected to. If not provided, then during create(),
the same dataSource will be used.hyperonDataSource - Hyperon Studio data sourcepublic void setHiloAllocationSize(int hiloAllocationSize)
identifierGenerator. If not provided, default will be used - 100hiloAllocationSize - allocation size for identifier generatorpublic void setHiloSequenceName(String hiloSequenceName)
identifierGenerator. If not provided, default will be used - "gmo_sequence"hiloSequenceName - sequence name for identifier generatorpublic void setSchema(String schema)
dataSource. If not provided, no schema will be used in queries.schema - for hyperon peristence engine used in queriesDaoConfig.setSchema(String)public void setBundleColumn(String bundleColumn)
bundleColumn - column name referencing bundleDaoConfig.DEFAULT_BUNDLE_FKpublic void setOwnerColumn(String ownerColumn)
ownerColumn - column name referencing ownerDaoConfig.DEFAULT_PARENT_FKpublic void setOwnerPropertyColumn(String ownerPropertyColumn)
ownerPropertyColumn - column name mapping for owner propertyDaoConfig.DEFAULT_PROP_COLUMNpublic void setBundleTable(String bundleTable)
bundleTable - bundle table nameDaoConfig.DEFAULT_BUNDLE_TABLE@Deprecated public GmoSandboxDao getSandboxDao()
@Deprecated public IdentifierGenerator getIdentifierGenerator()
public void setIdentifierGenerator(IdentifierGenerator identifierGenerator)
HiLoSequenceGenerator
will be used.identifierGenerator - custom implementation of id generatorIdentifierGenerator,
HiLoSequenceGeneratorpublic void setCache(BundleCache cache)
BundleService implementation for boosting performance.cache - custom cache implementationBundleCache,
EhcacheBundleCache,
MapBundleCache@Deprecated public BundleCache getCache()
GmoCacheManagerpublic void setCacheName(String cacheName)
BundleCache implementation, for cache manager (if there is any). By default, Hyperon Persistence engine uses
EhcacheBundleCache with Ehcache implementation with default cache name - "gmo"cacheName - cache name for cache managerBundleCache,
EhcacheBundleCachepublic String getDefaultProfile()
public void setDefaultProfile(String defaultProfile)
defaultProfile - profile to be used@Deprecated public DaoConfig getConf()
public void setSandboxWatcherErrorPause(int sandboxWatcherErrorPause)
sandboxWatcherErrorPause - error pause in secondspublic void setSandboxWatcherPause(int sandboxWatcherPause)
sandboxWatcherPause - watcher pause in secondspublic void setSandboxWatcherStartDelay(int sandboxWatcherStartDelay)
sandboxWatcherStartDelay - start delay of watcherpublic GmoCacheManager getCacheManager()
@Deprecated public DynamicDao getDao()
@Deprecated public GmoSandboxLoader getGmoSandboxLoader()
public void setAutoStartWatchers(boolean autoStartWatchers)
create().
If true, then watcher will start.
If false (default), then watcher won't start.
Watcher can be manually started using startSandboxWatcher()autoStartWatchers - control flagpublic HyperonPersistenceRuntimeWatcher getHyperonPersistenceWatcher()
public String getGmoDbDialect()
public void setGmoDbDialect(String gmoDbDialect)
gmoDbDialect is not setup, then default dialect is used for queries - oracle.gmoDbDialect - supported dialectIdentifierDaopublic void setDatabaseFetchStatsCache(DatabaseFetchStatsCache statsCache)
BundleService. DynamicDao,
DynamicRowMapper. Cache is used to resolve specific SQL queries when bundle mappings are changed.statsCache - custom cache implementationDatabaseFetchStatsSetCacheImpl,
Bundle,
BundleDef@Deprecated public DynamicDao getDynamicDao()
public void setUseColumnMetadataCache(boolean useColumnMetadataCache)
Copyright © 2021. All rights reserved.