Class SessionCommandsListener

Object
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