|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.web.filter.TopiaTransactionFilter
public abstract class TopiaTransactionFilter
TopiaContext and deal with the complete lifecycle of a topia
transaction while a request.
The injected transaction will be closed (if was really opened) at the end of
the request.
excludeMethods: This parameters configure a set of method names
which should never be called on the proxied transaction.
When a such method is called on the transaction then the filter will pass in
the hook onExcludeMethod(Object, Method, Object[]).
Default implementation of this hook is to throw an exception.
unusedMethods: This parameters configure a set of method names
which should be by-pass when the proxied transaction was not still open (via a TopiaContext.beginTransaction().
When a such method is called on the transaction then the filter will pass in
the hook onUnusedMethod(Object, Method, Object[]).
Default implementation of this hook is to not return null values.
TOPIA_TRANSACTION_REQUEST_ATTRIBUTE.
A convience method is created here to obtain the transaction getTransaction(ServletRequest) :
TopiaContext tx = TopiaTransactionFilter.getTransaction(ServletRequest);If you prefer to not use this nice method, you can also do this:
TopiaContext tx = (TopiaContext) request.getAttribute(TopiaTransactionFilter#TOPIA_TRANSACTION_REQUEST_ATTRIBUTE);
| Nested Class Summary | |
|---|---|
class |
TopiaTransactionFilter.TopiaTransactionProxyInvocationHandler
Handler of a proxy on a TopiaContext. |
| Field Summary | |
|---|---|
static String[] |
DEFAULT_EXCLUDE_METHODS
|
static String[] |
DEFAULT_UNUSED_METHODS
|
protected Set<String> |
excludeMethods
names of methods to forbid access while using proxy. |
static String |
TOPIA_TRANSACTION_REQUEST_ATTRIBUTE
|
protected Set<String> |
unusedMethods
names of methods to by-pass if no transaction opened on proxy. |
| Constructor Summary | |
|---|---|
TopiaTransactionFilter()
|
|
| Method Summary | |
|---|---|
protected abstract org.nuiton.topia.TopiaContext |
beginTransaction()
Method to open a new transaction. |
void |
destroy()
|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
|
Set<String> |
getExcludeMethods()
|
static org.nuiton.topia.TopiaContext |
getTransaction(javax.servlet.ServletRequest request)
|
Set<String> |
getUnusedMethods()
|
void |
init(javax.servlet.FilterConfig filterConfig)
|
protected Object |
onExcludeMethod(Object proxy,
Method method,
Object[] args)
Hook method called when a method with his name in excludeMethods was invoked on the proxied transaction. |
protected Object |
onUnusedMethod(Object proxy,
Method method,
Object[] args)
Hook method called when a method with his name in unusedMethods was invoked on the proxied transaction
while the underlying transaction is still not opened. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String TOPIA_TRANSACTION_REQUEST_ATTRIBUTE
public static final String[] DEFAULT_EXCLUDE_METHODS
public static final String[] DEFAULT_UNUSED_METHODS
protected Set<String> excludeMethods
protected Set<String> unusedMethods
| Constructor Detail |
|---|
public TopiaTransactionFilter()
| Method Detail |
|---|
public Set<String> getExcludeMethods()
public Set<String> getUnusedMethods()
public static org.nuiton.topia.TopiaContext getTransaction(javax.servlet.ServletRequest request)
protected abstract org.nuiton.topia.TopiaContext beginTransaction()
throws org.nuiton.topia.TopiaRuntimeException
org.nuiton.topia.TopiaRuntimeException - if any problem while opening a new transactionpublic void destroy()
destroy in interface javax.servlet.Filter
public void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletException
public void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterIOException
javax.servlet.ServletException
protected Object onExcludeMethod(Object proxy,
Method method,
Object[] args)
throws Throwable
excludeMethods was invoked on the proxied transaction.
proxy - proxied transactionmethod - method invokedargs - arguments of the invoked method
Throwable - if any error to do.
protected Object onUnusedMethod(Object proxy,
Method method,
Object[] args)
throws Throwable
unusedMethods was invoked on the proxied transaction
while the underlying transaction is still not opened.
proxy - the proxy itselfmethod - method invokedargs - arguments of the invoked method
Throwable - if any error to do.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||