|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sqlproc.engine.SqlProcessorLoader
public class SqlProcessorLoader
The helper class for the META SQL statements and mapping rules parsing. These statements and rules are taken from the
file repository based on the provided ANTLR grammar.
The purpose of this class is to load and analyze (=parse) the SQL Processor artifacts:
This is rather a low level helper class. For more simple approach please see SqlSimpleFactory
All the statements with the name name(QRY) are parsed as the META SQL queries using the ANTLR based
grammar.
All the statements with the name name(CRUD) are parsed as the META SQL CRUD statements using the ANTLR
based grammar.
All the statements with the name name(CALL) are parsed as the META SQL CALL statements using the ANTLR
based grammar. These are used to call the stored procedures.
All the statements with the name name(OUT) are parsed as the mapping rules using the ANTLR based
grammar.
A pair of the META SQL statement and the (optional) mapping rule forms one named SQL Engine instance.
All the statements with the name name(OPT) are taken as the optional features used in the process of the
SQL query/statement generation and execution.
In the process of ANTLR based parsing different kinds of incorrect stuff can cause the SqlEngineException to
be raised.
In the process of the META SQL statements and mapping rules parsing the input/output values META types have to be
established. For this purpose a factory class responsible for these META types construction has to be supplied.
To initialize the SqlProcessorLoader, Spring DI configuration can be utilized, like the next one:
<beans ...>
...
<bean id="sqlFactory" class="org.sqlproc.engine.jdbc.JdbcEngineFactory" init-method="init">
<property name="metaFilesNames">
<list>
<value>statements.qry</value>
</list>
</property>
</bean>
</beans>
and use the next code to obtain an instance of the SQL Query engine
SqlEngineFactory sqlFactory = context.getBean("sqlFactory", SqlEngineFactory.class);
SqlQueryEngine sqlEngine = sqlFactory.getQueryEngine("ALL");
or the next code to obtain an instance of the SQL CRUD engine
SqlEngineFactory sqlFactory = context.getBean("sqlFactory", SqlEngineFactory.class);
SqlCrudEngine sqlEngine = sqlFactory.getCrudEngine("ALL");
Another possibility is to utilize SqlFilesLoader.
SqlFilesLoader loader = new SqlFilesLoader("statements.qry", this.getClass());
SqlProcessorLoader sqlLoader = new SqlProcessorLoader(loader.getStatements(), JdbcTypeFactory.getInstance());
SqlQueryEngine sqlEngine = sqlLoader.getQueryEngine("ALL");
For more info please see the Tutorials.
| Nested Class Summary | |
|---|---|
static class |
SqlProcessorLoader.EngineType
The SQL Engine types |
| Field Summary | |
|---|---|
private Map<String,SqlMetaStatement> |
calls
The collection of named META SQL CALLABLE statements. |
private Map<String,Map<String,SqlProcessResult>> |
commonProcessingCache
The processing cache used for SqlProcessResult instances. |
private SqlTypeFactory |
composedTypeFactory
The combined factory for the META types construction. |
private Map<String,SqlMetaStatement> |
cruds
The collection of named META SQL CRUD statements. |
private Map<String,SqlEngine> |
dynamicEngines
The collection of named dynamic SQL Engines (the primary SQL Processor class) instances. |
private Map<String,SqlEngine> |
engines
The collection of named SQL Engines (the primary SQL Processor class) instances. |
private Map<String,Object> |
features
The collection of the SQL Processor optional features. |
private Boolean |
lazyInit
This flag indicates to speed up the initialization process. |
protected org.slf4j.Logger |
logger
The internal slf4j logger. |
private SqlMonitorFactory |
monitorFactory
The monitor factory used in the process of the SQL Monitor instances creation |
private Map<String,SqlMappingRule> |
outs
The collection of named explicitly defined mapping rules. |
private SqlPluginFactory |
pluginFactory
The factory for the SQL Processor plugins. |
private Map<String,SqlMetaStatement> |
sqls
The collection of named META SQL queries. |
private Map<String,Map<String,Object>> |
statementsFeatures
The collection of the SQL Processor optional features in the statement context. |
private Map<String,Set<String>> |
statementsFeaturesUnset
The collection of the SQL Processor optional features to be cleared in the statement context. |
private SqlValidatorFactory |
validatorFactory
The validator factory used in the process of the SQL Monitor instances creation |
| Constructor Summary | |
|---|---|
SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory)
Creates a new instance of the SqlProcessorLoader from the String content repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter)
Creates a new instance of the SqlProcessorLoader from the String content repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory)
Creates a new instance of the SqlProcessorLoader from the String content repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
List<SqlInternalType> customTypes,
String... onlyStatements)
Creates a new instance of the SqlProcessorLoader from the String content repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
SqlValidatorFactory validatorFactory,
List<SqlInternalType> customTypes,
Boolean lazyInit,
String... onlyStatements)
Creates a new instance of the SqlProcessorLoader from the String content repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
SqlValidatorFactory validatorFactory,
List<SqlInternalType> customTypes,
String... onlyStatements)
Creates a new instance of the SqlProcessorLoader from the String content repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
String... onlyStatements)
Creates a new instance of the SqlProcessorLoader from the String content repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
| Method Summary | |
|---|---|
private SqlEngine |
createEngine(String name,
SqlProcessorLoader.EngineType engineType,
SqlMetaStatement stmt,
String sqlStatement)
Creates a new instance of the SQL Engine instance (the primary SQL Processor class). |
SqlEngine |
getDynamicEngine(String name,
SqlProcessorLoader.EngineType engineType,
String sqlStatement)
Returns the named dynamic SQL Engine instance (the primary SQL Processor class). |
Map<String,SqlEngine> |
getDynamicEngines()
|
SqlEngine |
getEngine(String name,
SqlProcessorLoader.EngineType engineType)
Returns the named static or dynamic SQL Engine instance (the primary SQL Processor class). |
Map<String,SqlEngine> |
getEngines()
|
private Map<String,SqlMetaStatement> |
getStatements(SqlProcessorLoader.EngineType engineType)
Returns the static statements container based on required SQL Engine type |
SqlEngine |
getStaticEngine(String name,
SqlProcessorLoader.EngineType engineType)
Returns the named static SQL Engine instance (the primary SQL Processor class). |
boolean |
isLazyInit()
Returns a flag which indicates the lazy initialization mode. |
private void |
loadStatementFeatures(String name,
SqlEngine sqlEngine)
Some filters can be the optional features in the statement context. |
void |
setLazyInit(boolean lazyInit)
Sets the indicator to speed up the initialization process |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final org.slf4j.Logger logger
private SqlTypeFactory composedTypeFactory
private SqlPluginFactory pluginFactory
private SqlMonitorFactory monitorFactory
private SqlValidatorFactory validatorFactory
private Map<String,SqlEngine> engines
private Map<String,SqlEngine> dynamicEngines
private Map<String,SqlMetaStatement> sqls
private Map<String,SqlMetaStatement> cruds
private Map<String,SqlMetaStatement> calls
private Map<String,SqlMappingRule> outs
private Map<String,Object> features
private Map<String,Map<String,Object>> statementsFeatures
private Map<String,Set<String>> statementsFeaturesUnset
private Boolean lazyInit
private Map<String,Map<String,SqlProcessResult>> commonProcessingCache
SqlProcessResult instances.
| Constructor Detail |
|---|
public SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory)
throws SqlEngineException
sbStatements - the String representation of the META SQL queries/statements/output mappingstypeFactory - the factory for the META types constructionpluginFactory - the factory for the SQL Processor plugins
SqlEngineException - mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar
public SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter)
throws SqlEngineException
sbStatements - the String representation of the META SQL queries/statements/output mappingstypeFactory - the factory for the META types constructionpluginFactory - the factory for the SQL Processor pluginsfilter - the properties name prefix to filter the META SQL statements, mapping rules and optional features
SqlEngineException - mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar
public SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory)
throws SqlEngineException
sbStatements - the String representation of the META SQL queries/statements/output mappingstypeFactory - the factory for the META types constructionpluginFactory - the factory for the SQL Processor pluginsfilter - the properties name prefix to filter the META SQL statements, mapping rules and optional featuresmonitorFactory - the monitor factory used in the process of the SQL Monitor instances creation
SqlEngineException - mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar
public SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
String... onlyStatements)
sbStatements - the String representation of the META SQL queries/statements/output mappingstypeFactory - the factory for the META types constructionpluginFactory - the factory for the SQL Processor pluginsfilter - the properties name prefix to filter the META SQL statements, mapping rules and optional featuresmonitorFactory - the monitor factory used in the process of the SQL Monitor instances creationonlyStatements - only statements and rules with the names in this container are picked up from the properties
repository
SqlEngineException - mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar
public SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
List<SqlInternalType> customTypes,
String... onlyStatements)
throws SqlEngineException
sbStatements - the String representation of the META SQL queries/statements/output mappingstypeFactory - the factory for the META types constructionpluginFactory - the factory for the SQL Processor pluginsfilter - the properties name prefix to filter the META SQL statements, mapping rules and optional featuresmonitorFactory - the monitor factory used in the process of the SQL Monitor instances creationcustomTypes - the custom META typesonlyStatements - only statements and rules with the names in this container are picked up from the properties
repository
SqlEngineException - mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar
public SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
SqlValidatorFactory validatorFactory,
List<SqlInternalType> customTypes,
String... onlyStatements)
throws SqlEngineException
sbStatements - the String representation of the META SQL queries/statements/output mappingstypeFactory - the factory for the META types constructionpluginFactory - the factory for the SQL Processor pluginsfilter - the properties name prefix to filter the META SQL statements, mapping rules and optional featuresmonitorFactory - the monitor factory used in the process of the SQL Monitor instances creationvalidatorFactory - the validator factory used in the process of the SQL Monitor instances creationcustomTypes - the custom META typesonlyStatements - only statements and rules with the names in this container are picked up from the properties
repository
SqlEngineException - mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar
public SqlProcessorLoader(StringBuilder sbStatements,
SqlTypeFactory typeFactory,
SqlPluginFactory pluginFactory,
String filter,
SqlMonitorFactory monitorFactory,
SqlValidatorFactory validatorFactory,
List<SqlInternalType> customTypes,
Boolean lazyInit,
String... onlyStatements)
throws SqlEngineException
sbStatements - the String representation of the META SQL queries/statements/output mappingstypeFactory - the factory for the META types constructionpluginFactory - the factory for the SQL Processor pluginsfilter - the properties name prefix to filter the META SQL statements, mapping rules and optional featuresmonitorFactory - the monitor factory used in the process of the SQL Monitor instances creationvalidatorFactory - the validator factory used in the process of the SQL Monitor instances creationcustomTypes - the custom META typeslazyInit - this flag indicates to speed up the initialization process.onlyStatements - only statements and rules with the names in this container are picked up from the properties
repository
SqlEngineException - mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar| Method Detail |
|---|
private void loadStatementFeatures(String name,
SqlEngine sqlEngine)
name - the name of the META SQL statementpublic Map<String,SqlEngine> getEngines()
public Map<String,SqlEngine> getDynamicEngines()
private SqlEngine createEngine(String name,
SqlProcessorLoader.EngineType engineType,
SqlMetaStatement stmt,
String sqlStatement)
name - the name of the required SQL Procedure Engine instanceengineType - the required SQL Engine typestmt - the new SQL META statement instance for the case of static SQL Engine instancesqlStatement - the new SQL statement for the case of dynamic SQL Engine instance
SqlEngineException - in the case the instance can't be created
public SqlEngine getStaticEngine(String name,
SqlProcessorLoader.EngineType engineType)
name - the name of the required SQL Procedure Engine instanceengineType - the required SQL Engine type
SqlEngineException - in the case the instance can't be created
public SqlEngine getDynamicEngine(String name,
SqlProcessorLoader.EngineType engineType,
String sqlStatement)
name - the name of the required SQL Procedure Engine instanceengineType - the required SQL Engine typesqlStatement - the new SQL statement
SqlEngineException - in the case the instance can't be created
public SqlEngine getEngine(String name,
SqlProcessorLoader.EngineType engineType)
name - the name of the required SQL Procedure Engine instanceengineType - the required SQL Engine type
SqlEngineException - in the case the instance can't be createdprivate Map<String,SqlMetaStatement> getStatements(SqlProcessorLoader.EngineType engineType)
engineType - the required SQL Engine type
public boolean isLazyInit()
public void setLazyInit(boolean lazyInit)
lazyInit - the indicator to speed up the initialization process
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||