Package org.geotools.jdbc
Class SessionCommandsListener
- Object
-
- SessionCommandsListener
-
- All Implemented Interfaces:
ConnectionLifecycleListener
public class SessionCommandsListener extends Object implements ConnectionLifecycleListener
AConnectionLifecycleListenerthat executes custom SQL commands on connection grab and release. The SQL commands can contain environment variable references, where the environment variable reference contains a name and an eventual default value. Parsing rules are:- whatever is between
${and}is considered a environment variable reference in the form${name,defaultvalue}, the default value being optional $and}can be used stand alone only escaped with\(e.g.\$and\})\can be used stand alone only escaped with another\ (e.g.
- a environment variable name cannot contain a comma, which is used as the separator between the environment variable name and its default value (first comma acts as a separator)
- the default value is always interpreted as a string and expanded as such in the sql commands
\\)- "one two three \} \$ \\" (simple literal with special chars escaped)
- "My name is ${name}" (a simple environment variable reference without a default value)
- "My name is ${name,Joe}" (a simple environment variable reference with a default value)
- "bla ${myAttName" (unclosed expression section)
- "bla } bla" (
}is reserved, should have been escaped)
- Author:
- Andrea Aime - GeoSolutions
-
-
Constructor Summary
Constructors Constructor Description SessionCommandsListener(String sqlOnBorrow, String sqlOnRelease)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonBorrow(JDBCDataStore store, Connection cx)Called when the collection is being borrowed from the connection poolvoidonCommit(JDBCDataStore store, Connection cx)Called when the connection comes to a commitvoidonRelease(JDBCDataStore store, Connection cx)Called when the collection is being released back to the connection poolvoidonRollback(JDBCDataStore store, Connection cx)Called when the connection comes to a rollback
-
-
-
Method Detail
-
onBorrow
public void onBorrow(JDBCDataStore store, Connection cx) throws SQLException
Description copied from interface:ConnectionLifecycleListenerCalled when the collection is being borrowed from the connection pool- Specified by:
onBorrowin interfaceConnectionLifecycleListener- Throws:
SQLException
-
onRelease
public void onRelease(JDBCDataStore store, Connection cx) throws SQLException
Description copied from interface:ConnectionLifecycleListenerCalled when the collection is being released back to the connection pool- Specified by:
onReleasein interfaceConnectionLifecycleListener- Throws:
SQLException
-
onCommit
public void onCommit(JDBCDataStore store, Connection cx)
Description copied from interface:ConnectionLifecycleListenerCalled when the connection comes to a commit- Specified by:
onCommitin interfaceConnectionLifecycleListener
-
onRollback
public void onRollback(JDBCDataStore store, Connection cx)
Description copied from interface:ConnectionLifecycleListenerCalled when the connection comes to a rollback- Specified by:
onRollbackin interfaceConnectionLifecycleListener
-
-