Class DBConnectionFilter
java.lang.Object
org.javalite.activeweb.HttpSupport
org.javalite.activeweb.controller_filters.HttpSupportFilter
org.javalite.activeweb.controller_filters.AppControllerFilter
org.javalite.activeweb.controller_filters.DBConnectionFilter
- All Implemented Interfaces:
RequestAccess
Class is to be used in web apps that use ActiveJDBC. This class will open a connection configured in
DBConfig class
of the application before controller is executed and will close it after.- Author:
- Igor Polevoy
-
Nested Class Summary
Nested classes/interfaces inherited from class org.javalite.activeweb.HttpSupport
HttpSupport.HttpBuilder, HttpSupport.RenderBuilder -
Field Summary
Fields inherited from interface org.javalite.activeweb.RequestAccess
LOGGER -
Constructor Summary
ConstructorsConstructorDescriptionThis constructor is used to open all configured connections for a current environment.DBConnectionFilter(String dbName)Use this constructor to only open a named DB connection for a given environment.DBConnectionFilter(String dbName, boolean manageTransaction)Use this constructor to only open a named DB connection for a given environment and specify if this filter needs to manage transactions. -
Method Summary
Modifier and TypeMethodDescriptionvoidafter()voidbefore()voidonException(Exception e)To be implemented by application level filters.Methods inherited from class org.javalite.activeweb.HttpSupport
applicationJSON, assign, blank, encoding, flash, flash, flash, flash, getEncoding, getFile, getHttpServletRequest, getHttpServletResponse, getMap, getMap, getRealPath, getRequestBytes, getRequestInputStream, getRequestJSONList, getRequestJSONMap, getRequestStream, getRequestString, getResponseHeaders, header, header, jsonList, jsonMap, jsonMaps, locale, logDebug, logError, logError, logError, logInfo, logWarning, logWarning, merge, multipartForm, multipartForm, multipartFormItems, multipartFormItems, multipartFormItems, outputStream, outputStream, outputStream, redirect, redirect, redirect, redirect, redirect, redirect, redirect, redirect, redirectToReferrer, redirectToReferrer, render, respond, respondJSON, sanitize, sendCookie, sendCookie, sendFile, sendFile, sendPermanentCookie, session, session, sessionBoolean, sessionDouble, sessionFloat, sessionHas, sessionInteger, sessionLong, sessionObject, sessionString, setContentLength, setEncoding, setLocale, setRequestEncoding, setResponseEncoding, status, streamOut, uploadedFiles, uploadedFiles, uploadedFiles, values, view, view, view, writer, writerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.javalite.activeweb.RequestAccess
appContext, context, cookie, cookies, cookieValue, exists, format, getHeader, getId, getLocale, getRequestHost, getRequestPort, getRequestProperties, getRequestProtocol, getRoute, hasHeader, header, headers, host, ipAddress, ipForwardedFor, isDelete, isGet, isHead, isMethod, isMultipartContent, isPost, isPut, isXhr, locale, method, param, param, params, params, params, params1st, params1st, path, port, protocol, queryString, remoteAddress, remoteHost, requestHas, servletPath, session, session, uri, url, userAgent, xhr
-
Constructor Details
-
DBConnectionFilter
public DBConnectionFilter()This constructor is used to open all configured connections for a current environment. -
DBConnectionFilter
Use this constructor to only open a named DB connection for a given environment.- Parameters:
dbName- name of DB to open
-
DBConnectionFilter
Use this constructor to only open a named DB connection for a given environment and specify if this filter needs to manage transactions.- Parameters:
dbName- name of DB to openmanageTransaction- if set to true, the filter will start a transaction insidebefore()method, commit inside theafter()method, and rollback insideonException(Exception)method. This applies to all connections managed by this filter. If set to false, transactions are not managed. Configuration of J2EE container transaction management for a given JNDI DataSource can interfere with this filter. This filter uses simplejava.sql.Connectionmethods:setAutocommit(boolean),commit()androllback(). If you configure XA transactions, this parameter could be completely ignored by the container itself. For this filter to manage transactions, the datasources should not be type of XA. Read container documentation.
-
-
Method Details
-
before
public void before()- Overrides:
beforein classHttpSupportFilter
-
after
public void after()- Overrides:
afterin classHttpSupportFilter
-
onException
Description copied from class:HttpSupportFilterTo be implemented by application level filters. If there is an exception generated downstream, the filters- Overrides:
onExceptionin classHttpSupportFilter- Parameters:
e- exception.
-