public class DBConnectionFilter extends ControllerFilterAdapter
DBConfig
class
of the application before controller is executed and will close it after.Constructor and Description |
---|
DBConnectionFilter()
This 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.
|
Modifier and Type | Method and Description |
---|---|
void |
after()
Called by framework after executing a controller
|
void |
before()
Called by framework before executing a controller
|
void |
onException(Exception e)
Called by framework in case there was an exception inside a controller
|
public DBConnectionFilter()
public DBConnectionFilter(String dbName)
dbName
- name of DB to openpublic DBConnectionFilter(String dbName, boolean manageTransaction)
dbName
- name of DB to openmanageTransaction
- if set to true, the filter will start a transaction inside before()
method,
commit inside the after()
method, and rollback inside onException(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 simple java.sql.Connection
methods:
setAutocommit(boolean)
, commit()
and rollback()
. 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.public void before()
ControllerFilter
before
in interface ControllerFilter
before
in class ControllerFilterAdapter
public void after()
ControllerFilter
after
in interface ControllerFilter
after
in class ControllerFilterAdapter
public void onException(Exception e)
ControllerFilter
onException
in interface ControllerFilter
onException
in class ControllerFilterAdapter
e
- exception.Copyright © 2016. All rights reserved.