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
ConstructorDescriptionThis 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 TypeMethodDescriptionvoid
after()
void
before()
void
onException(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, 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, 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, writer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.javalite.activeweb.RequestAccess
appContext, context, cookie, cookies, cookieValue, exists, format, getId, getLocale, getRequestHost, getRequestPort, getRequestProperties, getRequestProtocol, getRoute, 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.Connection
methods: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:
before
in classHttpSupportFilter
-
after
public void after()- Overrides:
after
in classHttpSupportFilter
-
onException
Description copied from class:HttpSupportFilter
To be implemented by application level filters. If there is an exception generated downstream, the filters- Overrides:
onException
in classHttpSupportFilter
- Parameters:
e
- exception.
-