Class SessionCommandsListener

  • All Implemented Interfaces:
    ConnectionLifecycleListener

    public class SessionCommandsListener
    extends Object
    implements ConnectionLifecycleListener
    A ConnectionLifecycleListener that 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
    Examples of valid expressions:
    • "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)
    Examples of non valid expressions:
    • "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
      void onBorrow​(JDBCDataStore store, Connection cx)
      Called when the collection is being borrowed from the connection pool
      void onCommit​(JDBCDataStore store, Connection cx)
      Called when the connection comes to a commit
      void onRelease​(JDBCDataStore store, Connection cx)
      Called when the collection is being released back to the connection pool
      void onRollback​(JDBCDataStore store, Connection cx)
      Called when the connection comes to a rollback
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait