org.sqlproc.engine
Class SqlSimpleFactory

java.lang.Object
  extended by org.sqlproc.engine.SqlSimpleFactory
All Implemented Interfaces:
SqlEngineFactory
Direct Known Subclasses:
JdbcEngineFactory

public class SqlSimpleFactory
extends Object
implements SqlEngineFactory

The simple implementation of the SqlEngineFactory.

It's suitable mainly for the Spring DI based configuration, like the next one for the new 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>
 
or like the next one for the old loader SqlEngineLoader:
 <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="sqlFactory" class="org.sqlproc.engine.SqlSimpleFactory" init-method="init">
     <property name="metaProps" ref="sqlQueries" />
     <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.

Author:
Vladimir Hudec

Field Summary
private  List<SqlInternalType> customTypes
          The custom META types.
protected static String DEFAULT_META_PROPS_NAME
          Default value for metaPropsNames.
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 static String LINESEP
          The platform based line separator.
private  SqlEngineLoader loader
          The helper class for the META SQL statements and mapping rules parsing.
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  Properties metaProps
          The collection of all SQL Processor artifacts (META SQL statements, mapping rules and optional features).
private  List<String> metaPropsNames
          The names of property 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.
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.
 
Constructor Summary
SqlSimpleFactory()
          Creates a new instance with no default values.
 
Method Summary
 void addCustomType(SqlInternalType customType)
          Adds a new custom META type.
 SqlCrudEngine getCrudEngine(String name)
          Returns the named SQL CRUD Engine instance (the primary SQL Processor class).
 List<SqlInternalType> getCustomTypes()
          Returns the custom META types.
 String getFilter()
          Returns the name of the filter to filter the META SQL statements, mapping rules and optional features.
 SqlEngineFactory 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.
 Properties getMetaProps()
          Returns the collection of the META SQL statements, mapping rules and optional features.
 List<String> getMetaPropsNames()
          Returns the names of property 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.
 SqlProcedureEngine getProcedureEngine(String name)
          Returns the named SQL Procedure Engine instance (the primary SQL Processor class).
 SqlQueryEngine getQueryEngine(String name)
          Returns the named SQL Query Engine instance (the primary SQL Processor class).
 SqlTypeFactory getTypeFactory()
          Returns the factory for the META types construction.
 void init()
          Dynamic initialization, called mainly from the Spring configuration initialization.
 boolean isJdbc()
          Return the indicator the JDBC stack is used.
 void setCustomTypes(List<SqlInternalType> customTypes)
          Sets the custom META types.
 void setCustomTypes(SqlInternalType... customTypes)
          Sets the custom META types.
 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 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 setMetaProps(Properties props)
          Sets the collection of the META SQL statements, mapping rules and optional features.
 void setMetaPropsNames(List<String> propsNames)
          Sets the names of property files, which holds a collection of META SQL statements, mapping rules and optional features.
 void setMetaPropsNames(String... propsNames)
          Sets the names of property 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 setTypeFactory(SqlTypeFactory typeFactory)
          Sets the factory for the META types construction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINESEP

private static final String LINESEP
The platform based line separator.


DEFAULT_META_PROPS_NAME

protected static final String DEFAULT_META_PROPS_NAME
Default value for metaPropsNames.

See Also:
Constant Field Values

metaPropsNames

private List<String> metaPropsNames
The names of property files, which hold a collection of the SQL Processor artifacts (META SQL statements, mapping rules and optional features).


metaFilesNames

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).


metaProps

private Properties metaProps
The collection of all SQL Processor artifacts (META SQL statements, mapping rules and optional features).


metaStatements

private StringBuilder metaStatements
The String representation of all SQL Processor artifacts (META SQL statements, mapping rules and optional features).


typeFactory

private SqlTypeFactory typeFactory
The factory for the META types construction.


filter

private String filter
The name of the filter to filter the META SQL statements, mapping rules and optional features.


monitorFactory

private SqlMonitorFactory monitorFactory
The monitor factory used in the process of the SQL Monitor instances creation.


customTypes

private List<SqlInternalType> customTypes
The custom META types.


onlyStatements

private String[] onlyStatements
Only statements and rules with the names in this set are picked up from the properties repository.


jdbc

private boolean jdbc
The indicator the JDBC stack is used.


loader

private SqlEngineLoader loader
The helper class for the META SQL statements and mapping rules parsing. All artifacts are loaded from properties.


processorLoader

private SqlProcessorLoader processorLoader
The helper class for the META SQL statements and mapping rules parsing. All artifacts are loaded from new grammar based files.

Constructor Detail

SqlSimpleFactory

public SqlSimpleFactory()
Creates a new instance with no default values.

Method Detail

init

public void init()
Dynamic initialization, called mainly from the Spring configuration initialization.


getQueryEngine

public SqlQueryEngine getQueryEngine(String name)
Returns the named SQL Query Engine instance (the primary SQL Processor class).

Specified by:
getQueryEngine in interface SqlEngineFactory
Parameters:
name - the name of the required SQL Query Engine instance
Returns:
the SQL Engine instance

getCrudEngine

public SqlCrudEngine getCrudEngine(String name)
Returns the named SQL CRUD Engine instance (the primary SQL Processor class).

Specified by:
getCrudEngine in interface SqlEngineFactory
Parameters:
name - the name of the required SQL CRUD Engine instance
Returns:
the SQL Engine instance

getProcedureEngine

public SqlProcedureEngine getProcedureEngine(String name)
Returns the named SQL Procedure Engine instance (the primary SQL Processor class).

Specified by:
getProcedureEngine in interface SqlEngineFactory
Parameters:
name - the name of the required SQL Procedure Engine instance
Returns:
the SQL Engine instance

getMetaPropsNames

public List<String> getMetaPropsNames()
Returns the names of property files, which holds a collection of META SQL statements, mapping rules and optional features.

Returns:
the names of property files, which holds a collection of META SQL statements, mapping rules and optional features

setMetaPropsNames

public void setMetaPropsNames(List<String> propsNames)
Sets the names of property files, which holds a collection of META SQL statements, mapping rules and optional features.

Parameters:
propsNames - the names of property files, which holds a collection of META SQL statements, mapping rules and optional features

setMetaPropsNames

public void setMetaPropsNames(String... propsNames)
Sets the names of property files, which holds a collection of META SQL statements, mapping rules and optional features.

Parameters:
propsNames - the names of property files, which holds a collection of META SQL statements, mapping rules and optional features

getMetaFilesNames

public List<String> getMetaFilesNames()
Returns the names of files, which holds a collection of META SQL statements, mapping rules and optional features.

Returns:
the names of files, which holds a collection of META SQL statements, mapping rules and optional features

setMetaFilesNames

public void setMetaFilesNames(List<String> metaFilesNames)
Sets the names of files, which holds a collection of META SQL statements, mapping rules and optional features.

Parameters:
metaFilesNames - the names of files, which holds a collection of META SQL statements, mapping rules and optional features

setMetaFilesNames

public void setMetaFilesNames(String... metaFilesNames)
Sets the names of files, which holds a collection of META SQL statements, mapping rules and optional features.

Parameters:
metaFilesNames - the names of files, which holds a collection of META SQL statements, mapping rules and optional features

getMetaProps

public Properties getMetaProps()
Returns the collection of the META SQL statements, mapping rules and optional features.

Returns:
the collection of the META SQL statements, mapping rules and optional features

setMetaProps

public void setMetaProps(Properties props)
Sets the collection of the META SQL statements, mapping rules and optional features.

Parameters:
props - the collection of the META SQL statements, mapping rules and optional features

getMetaStatements

public StringBuilder getMetaStatements()
Returns the String representation of the META SQL statements, mapping rules and optional features.

Returns:
the String representation of the META SQL statements, mapping rules and optional features

setMetaStatements

public void setMetaStatements(StringBuilder metaStatements)
Sets the String representation of the META SQL statements, mapping rules and optional features.

Parameters:
metaStatements - the String representation of the META SQL statements, mapping rules and optional features

getTypeFactory

public SqlTypeFactory getTypeFactory()
Returns the factory for the META types construction.

Returns:
the factory for the META types construction

setTypeFactory

public void setTypeFactory(SqlTypeFactory typeFactory)
Sets the factory for the META types construction.

Parameters:
typeFactory - the factory for the META types construction

getFilter

public String getFilter()
Returns the name of the filter to filter the META SQL statements, mapping rules and optional features.

Returns:
the name of the filter to filter the META SQL statements, mapping rules and optional features

setFilter

public void setFilter(String filter)
Sets the name of the filter to filter the META SQL statements, mapping rules and optional features.

Parameters:
filter - the name of the filter to filter the META SQL statements, mapping rules and optional features

getMonitorFactory

public SqlMonitorFactory getMonitorFactory()
Returns the monitor factory used in the process of the SQL Monitor instances creation.

Returns:
the monitor factory used in the process of the SQL Monitor instances creation

setMonitorFactory

public void setMonitorFactory(SqlMonitorFactory monitorFactory)
Sets the monitor factory used in the process of the SQL Monitor instances creation.

Parameters:
monitorFactory - the monitor factory used in the process of the SQL Monitor instances creation

getCustomTypes

public List<SqlInternalType> getCustomTypes()
Returns the custom META types.

Returns:
the custom META types

setCustomTypes

public void setCustomTypes(List<SqlInternalType> customTypes)
Sets the custom META types.

Parameters:
customTypes - the custom META types

setCustomTypes

public void setCustomTypes(SqlInternalType... customTypes)
Sets the custom META types.

Parameters:
customTypes - the custom META types

addCustomType

public void addCustomType(SqlInternalType customType)
Adds a new custom META type.

Parameters:
customType - the custom META type

getOnlyStatements

public String[] getOnlyStatements()
Returns the only statements and rules, which are picked up from the properties repository.

Returns:
the only statements and rules, which are picked up from the properties repository

setOnlyStatements

public void setOnlyStatements(String[] selectQueries)
Sets the only statements and rules, which are picked up from the properties repository.

Parameters:
selectQueries - the only statements and rules, which are picked up from the properties repository

isJdbc

public boolean isJdbc()
Return the indicator the JDBC stack is used.

Returns:
the indicator the JDBC stack is used

setJdbc

public void setJdbc(boolean jdbc)
Sets the indicator the JDBC stack is used.

Parameters:
jdbc - the indicator the JDBC stack is used

getLoader

public SqlEngineFactory getLoader()
Returns the internal SQL engine or processor loader.

Returns:
the internal SQL engine or processor loader


Copyright © 2011. All Rights Reserved.