From: Loren C. <lor...@gm...> - 2011-12-14 15:34:57
|
Adam, For the trigger, there is already code in place that can be changed to be used for the trigger: [feature] Adding the ability to execute an XQuery script when an HTTP session is created and another XQuery script when an HTTP session is destroyed. Two listeners are being added to the server: - org.exist.http.AuditTrailSessionListener - org.exist.http.SessionCountListener NOTE: This feature is disabled by default, so it will have no impact on a system until enabled. These listeners can be enabled by uncommenting the following in tools/jetty/etc/webdefaults.xml: <listener> <listener-class>org.exist.http.AuditTrailSessionListener</listener-class> </listener> <listener> <listener-class>org.exist.http.SessionCountListener</listener-class> </listener> To change the session timeout from the default of 30 minutes, change the following value in webdefaults.xml: <session-config> <session-timeout>30</session-timeout> </session-config> When the AuditTrailSessionListener is enabled, then there are two Java properties that need to be set: - org.exist.http.session_create_listener - org.exist.http.session_destroy_listener If a property is not set, then the listener will do nothing for the create or destroy. If the property is set, but the XQuery script does not exist, then a Log4J error message "Resource [resource path] does not exist." is processed and then no other action is taken. If the resource exists and there is an execution failure, then a Log4J error message "Exception while executing [resource path] script for admin" is processed and then no other action is taken. If the resource exists and the execution succeeds, then a Log4J info message "XQuery execution results: results" is processed and then the method is completed. To set these properties, you need to edit bin/functions.d/eXist-settings.sh if starting from the command line in Unix/Linux: set_java_options() { if [ -z "${JAVA_OPTIONS}" ]; then JAVA_OPTIONS="-Xms128m -Xmx512m -Dfile.encoding=UTF-8 -Dorg.exist.http.session_destroy_listener=/db/session/session-destroy.xq"; fi JAVA_OPTIONS="${JAVA_OPTIONS} -Djava.endorsed.dirs=${JAVA_ENDORSED_DIRS}"; } To set these properties for The command line execution in Windows, you need to edit bin/startup.bat: :gotExistHome set JAVA_ENDORSED_DIRS="%EXIST_HOME%"\lib\endorsed set JAVA_OPTS="-Xms128m -Xmx512m -Dfile.encoding=UTF-8 -Dorg.exist.http.session_destroy_listener=/db/session/session-destroy.xq -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" To set these properties in wrapper, you need to edit tools/wrapper/conf/wrapper.conf: # Java Additional Parameters wrapper.java.additional.1=-Djava.endorsed.dirs=../../../lib/endorsed wrapper.java.additional.2=-Dfile.encoding=UTF-8 wrapper.java.additional.3=-Dexist.home=../../.. wrapper.java.additional.4=-Djetty.home=../../../tools/jetty wrapper.java.additional.5=-Dorg.exist.http.session_create_listener=/db/session/session-create.xq wrapper.java.additional.6=-Dorg.exist.http.session_destroy_listener=/db/session/session-destroy.xq - - - - - - - - - - - - - - - The SessionCountListener will return the number of open sessions are on the server, the way to access the value is through SessionCountListener.getActiveSessions() which returns a long. An XQuery function will be implemented to return this value. On Dec 14, 2011, at 9:22 AM, Loren Cahlander wrote: > Hello Adam, > > We talked a little about triggers when I was visiting. There are some triggers that I would like to see in trunk. > > trigger an XQuery script when an HTTP Session is created > trigger an XQuery script when an HTTP Session expires > trigger an XQuery script when a scheduled task starts > trigger an XQuery script when a scheduled task ends > > Are any of these in the works for trunk? > > Loren |