|
||||||||||
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
Helper class for the parsing of META SQL statements and Mapping rules located in properties file.
The purpose of this class is to load and analyze (=parse) 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
.
All the properties with the key LIST_..._SQL
are parsed as META SQL statements using ANTLR based
grammar.
All the properties with the key LIST_..._FIELDS
are parsed as Mapping rules using ANTLR based grammar.
A pair of META SQL statement and Mapping rule forms one named SQL Engine instance.
All the properties with the key SET_...
are taken as optional features used in the process of SQL Engine
instance construction.
In the process of ANTLR based parsing different kinds of incorrect stuff can cause SqlEngineException to be raised.
To initialize this class, Spring DI configuration can be utilized, like the next one:
<beans ...> ... <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" /> </bean> </beans>and use the next code to obtain instance of SQL Engine
SqlEngine sqlEngine = sqlLoader.getSqlEngine("ALL");
Another possibility is to utilize SqlPropertiesLoader.
SqlPropertiesLoader loader = new SqlPropertiesLoader("queries.properties", this.getClass()); SqlEngineLoader sqlLoader = new SqlEngineLoader(loader.getProperties()); SqlEngine sqlEngine = sqlLoader.getSqlEngine("ALL");
For more info please see the User's tutorial.
Field Summary | |
---|---|
private static java.lang.String |
COMMON_PREFIX
|
private java.util.Map<java.lang.String,SqlEngine> |
engines
The collection of named SQL Engine (the primary SQL Processor class) instances. |
private java.util.Map<java.lang.String,java.lang.Object> |
features
The collection of SQL Processor optional features |
private java.util.Map<java.lang.String,java.lang.String> |
fields
The collection of named Mapping rules |
private static java.lang.String |
FIELDS_REFERENCE
|
private static java.lang.String |
FIELDS_SUFFIX
|
private static int |
lCOMMON_PREFIX
|
private static int |
lFIELDS_REFERENCE
|
private static int |
lFIELDS_SUFFIX
|
protected org.slf4j.Logger |
logger
The internal slf4j logger. |
private static int |
lSET_PREFIX
|
private static int |
lSQL_SUFFIX
|
private static java.lang.String |
SET_PREFIX
|
private static java.lang.String |
SQL_SUFFIX
|
private java.util.Map<java.lang.String,java.lang.String> |
sqls
The collection of named META SQL statements |
Constructor Summary | |
---|---|
SqlEngineLoader(java.util.Properties props)
Creates a new instance of SqlEngineLoader from the properties repository (which is in fact a collection of META SQL statements, Mapping rules and Optional features. |
|
SqlEngineLoader(java.util.Properties props,
SqlMonitorFactory monitorFactory)
Creates a new instance of SqlEngineLoader from the properties repository (which is in fact a collection of META SQL statements, Mapping rules and Optional features. |
|
SqlEngineLoader(java.util.Properties props,
SqlMonitorFactory monitorFactory,
java.lang.String... selectQueries)
Creates a new instance of SqlEngineLoader from the properties repository (which is in fact a collection of META SQL statements, Mapping rules and Optional features. |
Method Summary | |
---|---|
java.lang.String |
getMappingRule(java.lang.String name)
Returns the named Mapping rule. |
java.lang.String |
getMetaSql(java.lang.String name)
Returns the named META SQL statement. |
java.util.Collection<java.lang.String> |
getNames()
Returns the collection of names of all initialized/constructed SQL Engine instances. |
SqlEngine |
getSqlEngine(java.lang.String name)
Returns the named SQL Engine instance (the primary SQL Processor class). |
SqlMonitor |
getSqlMonitor(java.lang.String name)
Returns the SQL Monitor instance devoted to the named SQL Engine instance. |
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 java.lang.String COMMON_PREFIX
private static final java.lang.String SQL_SUFFIX
private static final java.lang.String FIELDS_SUFFIX
private static final int lCOMMON_PREFIX
private static final int lSQL_SUFFIX
private static final int lFIELDS_SUFFIX
private static final java.lang.String SET_PREFIX
private static final int lSET_PREFIX
private static final java.lang.String FIELDS_REFERENCE
private static final int lFIELDS_REFERENCE
private java.util.Map<java.lang.String,SqlEngine> engines
private java.util.Map<java.lang.String,java.lang.String> sqls
private java.util.Map<java.lang.String,java.lang.String> fields
private java.util.Map<java.lang.String,java.lang.Object> features
Constructor Detail |
---|
public SqlEngineLoader(java.util.Properties props) throws SqlEngineException
props
- The collection of 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 SqlEngineLoader(java.util.Properties props, SqlMonitorFactory monitorFactory) throws SqlEngineException
props
- The collection of META SQL statements, Mapping rules and Optional featuresmonitorFactory
- The monitor factory used in the process of SQL Monitor instances creation.
SqlEngineException
- Mainly in the case the provided statements or rules are not compliant with the ANTLR based grammar.public SqlEngineLoader(java.util.Properties props, SqlMonitorFactory monitorFactory, java.lang.String... selectQueries) throws SqlEngineException
props
- The collection of META SQL statements, Mapping rules and Optional featuresmonitorFactory
- The monitor factory used in the process of SQL Monitor instances creation.selectQueries
- 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 grammar.Method Detail |
---|
public java.util.Collection<java.lang.String> getNames()
public java.lang.String getMetaSql(java.lang.String name)
name
- the name of the required META SQL statement
public java.lang.String getMappingRule(java.lang.String name)
name
- the name of the required Mapping rule
public SqlEngine getSqlEngine(java.lang.String name)
name
- the name of the required SQL Engine instance
public SqlMonitor getSqlMonitor(java.lang.String name)
name
- the name of the SQL Engine instance
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |