Package org.sqlproc.engine.jdbc
Class JdbcSession
- java.lang.Object
-
- org.sqlproc.engine.jdbc.JdbcSession
-
- All Implemented Interfaces:
InvocationHandler
public class JdbcSession extends Object implements InvocationHandler
The JDBC stack implementation of the SQL Engine session contract. In fact it's a proxy to theConnection
. It's the first parameter to all primary methods in theSqlQueryEngine
andSqlCrudEngine
.The implementation is based on the dynamic proxy design pattern provided by the Java API.
The primary contract is the method for the
SqlQuery
instance creation.For more info please see the Tutorials.
- Author:
- Vladimir Hudec
-
-
Field Summary
Fields Modifier and Type Field Description private Connection
connection
The connection to the database.private String
name
The name of the database related to this session.private static Class[]
PROXY_INTERFACES
The contracts implemented by this dynamic proxy.
-
Constructor Summary
Constructors Modifier Constructor Description private
JdbcSession(Connection connection)
Creates a new instance of this dynamic proxy.JdbcSession(Connection connection, String name)
Creates a new instance of this dynamic proxy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SqlSession
generateProxy(Connection connection)
The factory method to obtain this dynamic proxy.static SqlSession
generateProxy(Connection connection, String name)
The factory method to obtain this dynamic proxy.static ClassLoader
getProxyClassLoader()
Returns the class loader instance.Object
invoke(Object proxy, Method method, Object[] args)
-
-
-
Field Detail
-
PROXY_INTERFACES
private static final Class[] PROXY_INTERFACES
The contracts implemented by this dynamic proxy.
-
connection
private Connection connection
The connection to the database. It should be opened.
-
name
private String name
The name of the database related to this session. It's usage is implementation specific.
-
-
Constructor Detail
-
JdbcSession
private JdbcSession(Connection connection)
Creates a new instance of this dynamic proxy.- Parameters:
connection
- the connection to the database
-
JdbcSession
public JdbcSession(Connection connection, String name)
Creates a new instance of this dynamic proxy.- Parameters:
connection
- the connection to the databasename
- the name of the database
-
-
Method Detail
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-
generateProxy
public static SqlSession generateProxy(Connection connection)
The factory method to obtain this dynamic proxy.- Parameters:
connection
- the connection to the database- Returns:
- the JDBC stack implementation of the SQL Engine session contract
-
generateProxy
public static SqlSession generateProxy(Connection connection, String name)
The factory method to obtain this dynamic proxy.- Parameters:
connection
- the connection to the databasename
- the name of the database- Returns:
- the JDBC stack implementation of the SQL Engine session contract
-
getProxyClassLoader
public static ClassLoader getProxyClassLoader()
Returns the class loader instance.- Returns:
- the class loader instance
-
-