automatic manage of tx in webengine filter
------------------------------------------
Key: NXP-5854
URL: https://jira.nuxeo.org/browse/NXP-5854
Project: Nuxeo Enterprise Platform
Issue Type: Improvement
Components: WebEngine
Reporter: Bogdan Stefanescu
Assignee: Bogdan Stefanescu
Priority: Major
Fix For: 5.4
WebEngine filter should:
- start/close tx if required
- provide a stateless/stateful core session which is automatically closed when
needed
- enable modules to overwrite default behavior per a path basis.
By default webengine will start tx for any request to a JAX-RS application.
*/skin/* paths are ommited to avoid tx on static resources
You can configure the default behavior using the runtime property:
org.nuxeo.webengine.tx.auto=true|false
By default session is stateless for any JAX-RS request. You can configure this
behavior by using the framework variable:
org.nuxeo.webengine.session.stateful=true|false
Note that if you enable stateful session the requests belonging to the same
HttpSession will be synchronized to avoid concurrent access to the same core
session.
To configure tx and stateful flag on a path basis you should use an extension
like:
<extension target="" point="">
<path value="/mymodule1" autoTx="false" stateful="true" />
<path value="/mymodule2/resources" autoTx="false" />
<path value="/mymodule3/.*\.gif" autoTx="false" regex="true"/>
</extension>
Path matchers will be sorted from logest path string to the smallest one,
prefixes tried matched first, and after that regex matchers are tried.
Ex:
/module1/myresource
/module1
/module1/.*
Anyway it is recommended to use path prefixes and avoid regex for better perfs.
To get the provided core session in a resource you can use:
UserSession.getCurrentSession(httpRequest).getCoreSession();
or
UserSession.getCurrentSession(httpRequest).getCoreSession("repoName");
The session will be closed by webengine - so you don't need to worry about that.
Also if you want to do cleanup after the request was done (for example removing
any temporary file or closing other resources) you can use:
UserSession.addRequestCleanupHandler(httpRequest, new RequestCleanupHandler() {
cleanup(HttpServletRequest httpRequest) {
....
}
});
in a JAX-RS or MessageBodyWriter class.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.nuxeo.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets