|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sqlproc.engine.SqlEngineLoader
public class SqlEngineLoader
The helper class for the META SQL statements and mapping rules parsing. These statements and rules are taken from the
Properties
.
The purpose of this class is to load and analyze (=parse) the META SQL statements and mapping rules located in the
properties repository. The standard properties repository is the external properties file with the name
queries.properties
.
This is rather a low level helper class. For more simple approach please see SqlSimpleFactory
All the properties with the key QRY_...
are parsed as the META SQL queries using the ANTLR based
grammar.
All the properties with the key CRUD_...
are parsed as the META SQL CRUD statements using the ANTLR
based grammar.
All the properties with the key 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 properties with the key SET_...
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 SqlEngineLoader, Spring DI configuration can be utilized, like the next one:
<beans ...> ... <bean id="typeFactory" class="org.sqlproc.engine.jdbc.type.JdbcTypeFactory" factory-method="getInstance" /> <bean id="sqlQueries" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location"> <value>classpath:queries.properties</value> </property> </bean> <bean id="sqlLoader" class="org.sqlproc.engine.SqlEngineLoader"> <constructor-arg ref="sqlQueries" /> <constructor-arg ref="typeFactory" /> </bean> </beans>and use the next code to obtain an instance of the SQL Query engine
SqlQueryEngine sqlEngine = sqlLoader.getQueryEngine("ALL");or the next code to obtain an instance of the SQL CRUD engine
SqlCrudEngine sqlEngine = sqlLoader.getCrudEngine("ALL");
Another possibility is to utilize SqlPropertiesLoader.
SqlPropertiesLoader loader = new SqlPropertiesLoader("queries.properties", this.getClass()); SqlEngineLoader sqlLoader = new SqlEngineLoader(loader.getProperties(), JdbcTypeFactory.getInstance()); SqlEngine sqlEngine = sqlLoader.getQueryEngine("ALL");
For more info please see the Reference Guide or the tutorials.
Field Summary | |
---|---|
private SqlTypeFactory |
composedTypeFactory
|
private static String |
CRUD_PREFIX
|
private Map<String,String> |
cruds
The collection of named META SQL CRUD statements. |
private Map<String,SqlEngine> |
engines
The collection of named SQL Engine (the primary SQL Processor class) instances. |
private Map<String,Object> |
features
The collection of the SQL Processor optional features. |
private Map<String,String> |
fields
The collection of named explicitly defined mapping rules. |
private static String |
FIELDS_REFERENCE
|
private static String |
INPUT_MAPPING_PREFIX
|
private static int |
lCRUD_PREFIX
|
private static int |
lFIELDS_REFERENCE
|
private static int |
lINPUT_MAPPING_PREFIX
|
protected org.slf4j.Logger |
logger
The internal slf4j logger. |
private static int |
lOUTPUT_MAPPING_PREFIX
|
private static int |
lQUERY_PREFIX
|
private static int |
lSET_PREFIX
|
private static String |
OUTPUT_MAPPING_PREFIX
|
private static String |
QUERY_PREFIX
|
private static String |
SET_PREFIX
|
private Map<String,String> |
sqls
The collection of named META SQL queries. |
Constructor Summary | |
---|---|
SqlEngineLoader(Properties props,
SqlTypeFactory typeFactory)
Creates a new instance of the SqlEngineLoader from the properties repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlEngineLoader(Properties props,
SqlTypeFactory typeFactory,
String filter)
Creates a new instance of the SqlEngineLoader from the properties repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlEngineLoader(Properties props,
SqlTypeFactory typeFactory,
String filter,
SqlMonitorFactory monitorFactory)
Creates a new instance of the SqlEngineLoader from the properties repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlEngineLoader(Properties props,
SqlTypeFactory typeFactory,
String filter,
SqlMonitorFactory monitorFactory,
List<SqlInternalType> customTypes,
String... selectQueries)
Creates a new instance of the SqlEngineLoader from the properties repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
|
SqlEngineLoader(Properties props,
SqlTypeFactory typeFactory,
String filter,
SqlMonitorFactory monitorFactory,
String... selectQueries)
Creates a new instance of the SqlEngineLoader from the properties repository (which is in fact a collection of the META SQL statements, mapping rules and optional features. |
Method Summary | |
---|---|
SqlCrudEngine |
getCrudEngine(String name)
Returns the named SQL CRUD Engine instance (the primary SQL Processor class). |
String |
getMappingRule(String name)
Returns the named mapping rule. |
String |
getMetaSql(String name)
Returns the named META SQL query/statement. |
Collection<String> |
getNames()
Returns the collection of names of all initialized/constructed SQL Engine instances. |
SqlQueryEngine |
getQueryEngine(String name)
Returns the named SQL Query Engine instance (the primary SQL Processor class). |
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 static final String SET_PREFIX
private static final int lSET_PREFIX
private static final String FIELDS_REFERENCE
private static final int lFIELDS_REFERENCE
private static final String QUERY_PREFIX
private static final int lQUERY_PREFIX
private static final String INPUT_MAPPING_PREFIX
private static final int lINPUT_MAPPING_PREFIX
private static final String OUTPUT_MAPPING_PREFIX
private static final int lOUTPUT_MAPPING_PREFIX
private static final String CRUD_PREFIX
private static final int lCRUD_PREFIX
private SqlTypeFactory composedTypeFactory
private Map<String,SqlEngine> engines
private Map<String,String> sqls
private Map<String,String> cruds
private Map<String,String> fields
private Map<String,Object> features
Constructor Detail |
---|
public SqlEngineLoader(Properties props, SqlTypeFactory typeFactory) throws SqlEngineException
props
- the collection of META SQL statements, mapping rules and optional features located in the properties
repositorytypeFactory
- the factory for the META types construction
SqlEngineException
- mainly in the case the provided statements or rules are not compliant with the ANTLR based grammarpublic SqlEngineLoader(Properties props, SqlTypeFactory typeFactory, String filter) throws SqlEngineException
props
- the collection of META SQL statements, mapping rules and optional featurestypeFactory
- the factory for the META types constructionfilter
- 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 grammarpublic SqlEngineLoader(Properties props, SqlTypeFactory typeFactory, String filter, SqlMonitorFactory monitorFactory) throws SqlEngineException
props
- the collection of META SQL statements, mapping rules and optional featurestypeFactory
- the factory for the META types constructionfilter
- 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 grammarpublic SqlEngineLoader(Properties props, SqlTypeFactory typeFactory, String filter, SqlMonitorFactory monitorFactory, String... selectQueries)
props
- the collection of META SQL statements, mapping rules and optional featurestypeFactory
- the factory for the META types constructionfilter
- 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 creationselectQueries
- only statements and rules with the names in this set are picked up from the properties repository
SqlEngineException
- mainly in the case the provided statements or rules are not compliant with the ANTLR based grammarpublic SqlEngineLoader(Properties props, SqlTypeFactory typeFactory, String filter, SqlMonitorFactory monitorFactory, List<SqlInternalType> customTypes, String... selectQueries) throws SqlEngineException
props
- the collection of META SQL statements, mapping rules and optional featurestypeFactory
- the factory for the META types constructionfilter
- 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 typesselectQueries
- only statements and rules with the names in this set are picked up from the properties repository
SqlEngineException
- mainly in the case the provided statements or rules are not compliant with the ANTLR based grammarMethod Detail |
---|
public Collection<String> getNames()
public String getMetaSql(String name)
name
- the name of the required META SQL query/statement
public String getMappingRule(String name)
name
- the name of the required mapping rule
public SqlQueryEngine getQueryEngine(String name)
getQueryEngine
in interface SqlEngineFactory
name
- the name of the required SQL Query Engine instance
public SqlCrudEngine getCrudEngine(String name)
getCrudEngine
in interface SqlEngineFactory
name
- the name of the required SQL CRUD Engine instance
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |