public class SqlSimpleFactory extends Object implements SqlEngineFactory
SqlEngineFactory
.
It's suitable mainly for the Spring DI based configuration, like the next one for the loader
SqlProcessorLoader
:
<beans ...> ... <bean id="typeFactory" class="org.sqlproc.engine.jdbc.type.JdbcTypeFactory" factory-method="getInstance" /> <bean id="sqlFactory" class="org.sqlproc.engine.SqlSimpleFactory" init-method="init"> <property name="metaFilesNames"> <list> <value>statements.qry</value> </list> </property> <property name="typeFactory" ref="typeFactory" /> </bean> </beans>and use the next code to obtain an instance of the SQL Query engine
SqlQueryEngine sqlEngine = sqlFactory.getQueryEngine("ALL");or the next code to obtain an instance of the SQL CRUD engine
SqlCrudEngine sqlEngine = sqlFactory.getCrudEngine("ALL");
In the case the SQL Processor runs on the top of the JDBC stack, there's more suitable JdbcEngineFactory
.
For more info please see the Tutorials.
Modifier and Type | Class and Description |
---|---|
static class |
SqlSimpleFactory.SqlThreadPoolExecutor
The customized ThreadPoolExecutor.
|
Modifier and Type | Field and Description |
---|---|
private Integer |
asyncInitThreads
The number of threads used for asynchronous initialization.
|
private SqlEngineConfiguration |
configuration
The overall configuration, which can be persisted.
|
private List<SqlInternalType> |
customTypes
The custom META types.
|
private Executor |
executor
The asynchronous SQL Processor engines initialization executor.
|
private Boolean |
executorTerminated
The flag indicating the asynchronous SQL Processor engines initialization has been finished.
|
private String |
filter
The name of the filter to filter the META SQL statements, mapping rules and optional features.
|
private boolean |
jdbc
The indicator the JDBC stack is used.
|
private Boolean |
lazyInit
This flag indicates to speed up the initialization process.
|
private static String |
LINESEP
The platform based line separator.
|
protected org.slf4j.Logger |
logger
The internal slf4j logger.
|
private List<String> |
metaFilesNames
The names of files, which hold a collection of the SQL Processor artifacts (META SQL statements, mapping rules
and optional features).
|
private StringBuilder |
metaStatements
The String representation of all SQL Processor artifacts (META SQL statements, mapping rules and optional
features).
|
private SqlMonitorFactory |
monitorFactory
The monitor factory used in the process of the SQL Monitor instances creation.
|
private String[] |
onlyStatements
Only statements and rules with the names in this set are picked up from the properties repository.
|
protected SqlPluginFactory |
pluginFactory
The factory for the SQL Processor plugins.
|
private SqlProcessorLoader |
processorLoader
The helper class for the META SQL statements and mapping rules parsing.
|
private SqlTypeFactory |
typeFactory
The factory for the META types construction.
|
private SqlValidatorFactory |
validatorFactory
The validator factory used in the process of the SQL Monitor instances creation.
|
Constructor and Description |
---|
SqlSimpleFactory()
Creates a new instance with no default values.
|
SqlSimpleFactory(boolean lazyInit)
Creates a new instance with no default values.
|
SqlSimpleFactory(boolean lazyInit,
int asyncInitThreads)
Creates a new instance with no default values.
|
SqlSimpleFactory(int asyncInitThreads)
Creates a new instance with no default values.
|
Modifier and Type | Method and Description |
---|---|
void |
addCustomType(SqlInternalType customType)
Adds a new custom META type.
|
private void |
check(String name,
SqlEngine sqlEngine)
Check the SQL Engine instance is not null
|
int |
getAsyncInitThreads()
Returns the number of threads used for asynchronous initialization
|
SqlCrudEngine |
getCheckedCrudEngine(String name)
Returns the named static or dynamic SQL CRUD Engine instance (the primary SQL Processor class).
|
SqlProcedureEngine |
getCheckedProcedureEngine(String name)
Returns the named static or dynamic SQL Procedure Engine instance (the primary SQL Processor class).
|
SqlQueryEngine |
getCheckedQueryEngine(String name)
Returns the named static or dynamic SQL Query Engine instance (the primary SQL Processor class).
|
SqlCrudEngine |
getCheckedStaticCrudEngine(String name)
Returns the named static SQL CRUD Engine instance (the primary SQL Processor class).
|
SqlProcedureEngine |
getCheckedStaticProcedureEngine(String name)
Returns the named static SQL Procedure Engine instance (the primary SQL Processor class).
|
SqlQueryEngine |
getCheckedStaticQueryEngine(String name)
Returns the named static SQL Query Engine instance (the primary SQL Processor class).
|
SqlEngineConfiguration |
getConfiguration()
Returns the overall dynamic configuration
|
Map<String,SqlEngine> |
getCrudDynamicEngines()
Returns the collection of names of all initialized/constructed dynamic SQL CRUD Engine instances.
|
Collection<String> |
getCrudDynamicNames()
Returns the collection of names of all initialized/constructed dynamic SQL CRUD Engine instances.
|
SqlCrudEngine |
getCrudEngine(String name)
Returns the named static or dynamic SQL CRUD Engine instance (the primary SQL Processor class).
|
Map<String,SqlEngine> |
getCrudEngines()
Returns the collection of named dynamic SQL CRUD Engines (the primary SQL Processor class) instances.
|
Collection<String> |
getCrudNames()
Returns the collection of names of all initialized/constructed static SQL CRUD Engine instances.
|
List<SqlInternalType> |
getCustomTypes()
Returns the custom META types.
|
SqlCrudEngine |
getDynamicCrudEngine(String name,
String sqlStatement)
Returns the named dynamic SQL CRUD Engine instance (the primary SQL Processor class).
|
SqlProcedureEngine |
getDynamicProcedureEngine(String name,
String sqlStatement)
Returns the named dynamic SQL Procedure Engine instance (the primary SQL Processor class).
|
SqlQueryEngine |
getDynamicQueryEngine(String name,
String sqlStatement)
Returns the named dynamic SQL Query Engine instance (the primary SQL Processor class).
|
Map<String,String> |
getEnginesInitErrors()
Returns the result of engines initialization process.
|
String |
getEnginesInitErrorsMsg()
Returns the result of engines initialization process.
|
protected Executor |
getExecutor()
Returns the asynchronous SQL Processor engines initialization executor.
|
String |
getFilter()
Returns the name of the filter to filter the META SQL statements, mapping rules and optional features.
|
SqlProcessorLoader |
getLoader()
Returns the internal SQL engine or processor loader.
|
List<String> |
getMetaFilesNames()
Returns the names of files, which holds a collection of META SQL statements, mapping rules and optional features.
|
StringBuilder |
getMetaStatements()
Returns the String representation of the META SQL statements, mapping rules and optional features.
|
SqlMonitorFactory |
getMonitorFactory()
Returns the monitor factory used in the process of the SQL Monitor instances creation.
|
String[] |
getOnlyStatements()
Returns the only statements and rules, which are picked up from the properties repository.
|
SqlPluginFactory |
getPluginFactory()
Returns the factory for the SQL Processor plugins.
|
Map<String,SqlEngine> |
getProcedureDynamicEngines()
Returns the collection of names of all initialized/constructed dynamic SQL Procedure Engine instances.
|
Collection<String> |
getProcedureDynamicNames()
Returns the collection of names of all initialized/constructed dynamic SQL Procedure Engine instances.
|
SqlProcedureEngine |
getProcedureEngine(String name)
Returns the named static or dynamic SQL Procedure Engine instance (the primary SQL Processor class).
|
Map<String,SqlEngine> |
getProcedureEngines()
Returns the collection of named dynamic SQL Procedure Engines (the primary SQL Processor class) instances.
|
Collection<String> |
getProcedureNames()
Returns the collection of names of all initialized/constructed static SQL Procedure Engine instances.
|
Map<String,SqlEngine> |
getQueryDynamicEngines()
Returns the collection of names of all initialized/constructed dynamic SQL Query Engine instances.
|
Collection<String> |
getQueryDynamicNames()
Returns the collection of names of all initialized/constructed dynamic SQL Query Engine instances.
|
SqlQueryEngine |
getQueryEngine(String name)
Returns the named static or dynamic SQL Query Engine instance (the primary SQL Processor class).
|
Map<String,SqlEngine> |
getQueryEngines()
Returns the collection of named dynamic SQL Query Engines (the primary SQL Processor class) instances.
|
Collection<String> |
getQueryNames()
Returns the collection of names of all initialized/constructed static SQL Query Engine instances.
|
SqlCrudEngine |
getStaticCrudEngine(String name)
Returns the named static SQL CRUD Engine instance (the primary SQL Processor class).
|
SqlProcedureEngine |
getStaticProcedureEngine(String name)
Returns the named static SQL Procedure Engine instance (the primary SQL Processor class).
|
SqlQueryEngine |
getStaticQueryEngine(String name)
Returns the named static SQL Query Engine instance (the primary SQL Processor class).
|
SqlTypeFactory |
getTypeFactory()
Returns the factory for the META types construction.
|
SqlValidatorFactory |
getValidatorFactory()
Returns the validator factory used in the process of the SQL Monitor instances creation.
|
void |
init()
Dynamic initialization, called mainly from the Spring configuration initialization.
|
void |
init0()
Conditional dynamic initialization, called mainly from the Spring configuration initialization.
|
Boolean |
isAsyncInitFinished()
Returns the flag indicating the asynchronous SQL Processor engines initialization has been finished.
|
boolean |
isJdbc()
Return the indicator the JDBC stack is used.
|
boolean |
isLazyInit()
Returns the indicator to speed up the initialization process
|
void |
setAsyncInitThreads(int asyncInitThreads)
Sets the number of threads used for asynchronous initialization
|
void |
setConfiguration(SqlEngineConfiguration configuration)
Sets the overall dynamic configuration
|
void |
setCustomTypes(List<SqlInternalType> customTypes)
Sets the custom META types.
|
void |
setCustomTypes(SqlInternalType... customTypes)
Sets the custom META types.
|
void |
setExecutor(Executor executor)
Sets the asynchronous SQL Processor engines initialization executor.
|
void |
setFilter(SqlFeature filter)
Sets the name of the filter to filter the META SQL statements, mapping rules and optional features.
|
void |
setFilter(String filter)
Sets the name of the filter to filter the META SQL statements, mapping rules and optional features.
|
void |
setJdbc(boolean jdbc)
Sets the indicator the JDBC stack is used.
|
void |
setLazyInit(boolean lazyInit)
Sets the indicator to speed up the initialization process
|
void |
setMetaFilesNames(List<String> metaFilesNames)
Sets the names of files, which holds a collection of META SQL statements, mapping rules and optional features.
|
void |
setMetaFilesNames(String... metaFilesNames)
Sets the names of files, which holds a collection of META SQL statements, mapping rules and optional features.
|
void |
setMetaStatements(StringBuilder metaStatements)
Sets the String representation of the META SQL statements, mapping rules and optional features.
|
void |
setMonitorFactory(SqlMonitorFactory monitorFactory)
Sets the monitor factory used in the process of the SQL Monitor instances creation.
|
void |
setOnlyStatements(String[] selectQueries)
Sets the only statements and rules, which are picked up from the properties repository.
|
void |
setPluginFactory(SqlPluginFactory pluginFactory)
Sets the factory for the SQL Processor plugins.
|
void |
setTypeFactory(SqlTypeFactory typeFactory)
Sets the factory for the META types construction.
|
void |
setValidatorFactory(SqlValidatorFactory validatorFactory)
Sets the validator factory used in the process of the SQL Monitor instances creation.
|
protected final org.slf4j.Logger logger
private static final String LINESEP
private List<String> metaFilesNames
private StringBuilder metaStatements
private SqlTypeFactory typeFactory
protected SqlPluginFactory pluginFactory
private String filter
private SqlMonitorFactory monitorFactory
private List<SqlInternalType> customTypes
private String[] onlyStatements
private boolean jdbc
private SqlProcessorLoader processorLoader
private SqlValidatorFactory validatorFactory
private Boolean lazyInit
private Integer asyncInitThreads
private SqlEngineConfiguration configuration
private Executor executor
private Boolean executorTerminated
public SqlSimpleFactory()
public SqlSimpleFactory(boolean lazyInit)
lazyInit
- this flag indicates to speed up the initialization process.public SqlSimpleFactory(int asyncInitThreads)
asyncInitThreads
- number of threads used for asynchronous initializationpublic SqlSimpleFactory(boolean lazyInit, int asyncInitThreads)
lazyInit
- this flag indicates to speed up the initialization process.asyncInitThreads
- number of threads used for asynchronous initializationpublic void init()
public void init0()
public SqlQueryEngine getQueryEngine(String name)
getQueryEngine
in interface SqlEngineFactory
name
- the name of the required SQL Query Engine instancepublic SqlCrudEngine getCrudEngine(String name)
getCrudEngine
in interface SqlEngineFactory
name
- the name of the required SQL CRUD Engine instancepublic SqlProcedureEngine getProcedureEngine(String name)
getProcedureEngine
in interface SqlEngineFactory
name
- the name of the required SQL Procedure Engine instancepublic SqlQueryEngine getStaticQueryEngine(String name)
getStaticQueryEngine
in interface SqlEngineFactory
name
- the name of the required SQL Query Engine instancepublic SqlCrudEngine getStaticCrudEngine(String name)
getStaticCrudEngine
in interface SqlEngineFactory
name
- the name of the required SQL CRUD Engine instancepublic SqlProcedureEngine getStaticProcedureEngine(String name)
getStaticProcedureEngine
in interface SqlEngineFactory
name
- the name of the required SQL Procedure Engine instanceprivate void check(String name, SqlEngine sqlEngine)
name
- the name of the required SQL Engine instancesqlEngine
- the checked SQL Engine instanceSqlEngineException
- in the case the the SQL Engine instance is nullpublic SqlQueryEngine getCheckedQueryEngine(String name) throws SqlEngineException
getCheckedQueryEngine
in interface SqlEngineFactory
name
- the name of the required SQL Query Engine instanceSqlEngineException
- in the case the related statement is missingpublic SqlCrudEngine getCheckedCrudEngine(String name)
getCheckedCrudEngine
in interface SqlEngineFactory
name
- the name of the required SQL CRUD Engine instancepublic SqlProcedureEngine getCheckedProcedureEngine(String name)
getCheckedProcedureEngine
in interface SqlEngineFactory
name
- the name of the required SQL Procedure Engine instancepublic SqlQueryEngine getCheckedStaticQueryEngine(String name) throws SqlEngineException
getCheckedStaticQueryEngine
in interface SqlEngineFactory
name
- the name of the required SQL Query Engine instanceSqlEngineException
- in the case the related statement is missingpublic SqlCrudEngine getCheckedStaticCrudEngine(String name)
getCheckedStaticCrudEngine
in interface SqlEngineFactory
name
- the name of the required SQL CRUD Engine instancepublic SqlProcedureEngine getCheckedStaticProcedureEngine(String name)
getCheckedStaticProcedureEngine
in interface SqlEngineFactory
name
- the name of the required SQL Procedure Engine instancepublic SqlQueryEngine getDynamicQueryEngine(String name, String sqlStatement) throws SqlEngineException
getDynamicQueryEngine
in interface SqlEngineFactory
name
- the name of the required SQL Query Engine instancesqlStatement
- the new SQL statement, which is going to replace the original oneSqlEngineException
- in the case the original statement is missingpublic SqlCrudEngine getDynamicCrudEngine(String name, String sqlStatement)
getDynamicCrudEngine
in interface SqlEngineFactory
name
- the name of the required SQL CRUD Engine instancesqlStatement
- the new SQL statement, which is going to replace the original onepublic SqlProcedureEngine getDynamicProcedureEngine(String name, String sqlStatement)
getDynamicProcedureEngine
in interface SqlEngineFactory
name
- the name of the required SQL Procedure Engine instancesqlStatement
- the new SQL statement, which is going to replace the original onepublic List<String> getMetaFilesNames()
public void setMetaFilesNames(List<String> metaFilesNames)
metaFilesNames
- the names of files, which holds a collection of META SQL statements, mapping rules and optional
featurespublic void setMetaFilesNames(String... metaFilesNames)
metaFilesNames
- the names of files, which holds a collection of META SQL statements, mapping rules and optional
featurespublic StringBuilder getMetaStatements()
public void setMetaStatements(StringBuilder metaStatements)
metaStatements
- the String representation of the META SQL statements, mapping rules and optional featurespublic SqlTypeFactory getTypeFactory()
public void setTypeFactory(SqlTypeFactory typeFactory)
typeFactory
- the factory for the META types constructionpublic SqlPluginFactory getPluginFactory()
public void setPluginFactory(SqlPluginFactory pluginFactory)
pluginFactory
- the factory for the SQL Processor pluginspublic String getFilter()
public void setFilter(String filter)
filter
- the name of the filter to filter the META SQL statements, mapping rules and optional featurespublic void setFilter(SqlFeature filter)
filter
- the name of the filter to filter the META SQL statements, mapping rules and optional featurespublic SqlMonitorFactory getMonitorFactory()
public void setMonitorFactory(SqlMonitorFactory monitorFactory)
monitorFactory
- the monitor factory used in the process of the SQL Monitor instances creationpublic List<SqlInternalType> getCustomTypes()
public void setCustomTypes(List<SqlInternalType> customTypes)
customTypes
- the custom META typespublic void setCustomTypes(SqlInternalType... customTypes)
customTypes
- the custom META typespublic void addCustomType(SqlInternalType customType)
customType
- the custom META typepublic String[] getOnlyStatements()
public void setOnlyStatements(String[] selectQueries)
selectQueries
- the only statements and rules, which are picked up from the properties repositorypublic boolean isJdbc()
public void setJdbc(boolean jdbc)
jdbc
- the indicator the JDBC stack is usedpublic boolean isLazyInit()
isLazyInit
in interface SqlEngineFactory
public void setLazyInit(boolean lazyInit)
lazyInit
- the indicator to speed up the initialization processpublic int getAsyncInitThreads()
getAsyncInitThreads
in interface SqlEngineFactory
public Boolean isAsyncInitFinished()
isAsyncInitFinished
in interface SqlEngineFactory
public void setAsyncInitThreads(int asyncInitThreads)
asyncInitThreads
- the number of threads used for asynchronous initializationpublic SqlProcessorLoader getLoader()
public SqlValidatorFactory getValidatorFactory()
public void setValidatorFactory(SqlValidatorFactory validatorFactory)
validatorFactory
- the validator factory used in the process of the SQL Monitor instances creationpublic Collection<String> getQueryNames()
getQueryNames
in interface SqlEngineFactory
public Collection<String> getQueryDynamicNames()
getQueryDynamicNames
in interface SqlEngineFactory
public Map<String,SqlEngine> getQueryEngines()
getQueryEngines
in interface SqlEngineFactory
public Map<String,SqlEngine> getQueryDynamicEngines()
getQueryDynamicEngines
in interface SqlEngineFactory
public Collection<String> getCrudNames()
getCrudNames
in interface SqlEngineFactory
public Collection<String> getCrudDynamicNames()
getCrudDynamicNames
in interface SqlEngineFactory
public Map<String,SqlEngine> getCrudEngines()
getCrudEngines
in interface SqlEngineFactory
public Map<String,SqlEngine> getCrudDynamicEngines()
getCrudDynamicEngines
in interface SqlEngineFactory
public Collection<String> getProcedureNames()
getProcedureNames
in interface SqlEngineFactory
public Collection<String> getProcedureDynamicNames()
getProcedureDynamicNames
in interface SqlEngineFactory
public Map<String,SqlEngine> getProcedureEngines()
getProcedureEngines
in interface SqlEngineFactory
public Map<String,SqlEngine> getProcedureDynamicEngines()
getProcedureDynamicEngines
in interface SqlEngineFactory
public Map<String,String> getEnginesInitErrors()
getEnginesInitErrors
in interface SqlEngineFactory
public String getEnginesInitErrorsMsg()
getEnginesInitErrorsMsg
in interface SqlEngineFactory
public SqlEngineConfiguration getConfiguration()
getConfiguration
in interface SqlEngineFactory
public void setConfiguration(SqlEngineConfiguration configuration)
configuration
- the overall dynamic configurationprotected Executor getExecutor()
public void setExecutor(Executor executor)
executor
- the asynchronous SQL Processor engines initialization executorCopyright © 2015. All rights reserved.