Hi all,

In SLING-73 [1], Lars Trieloff raises the question whether the JCR
Session should automatically be saved or refreshed by the ScriptSelector
after a script has run. His position is, that this might easily be
forgotten and most people would want such a behaviour.

I on the other hand think, that the decision to persist or not any
changes and the point in time of taking this decision and persiting or
not the changes are completely up to the script and the ScriptSelector
cannot and should not take an active role in this game. On the other
hand, the session should probably be refreshed (or logged out) at the
end of processing a request to cleanup and unsaved changes.

I think, we can place the responsibility to persist changes on the
shoulders of the script programmer just as it is done in SQL where
generally a transaction must be commited.

Along the lines of SQL, we could discuss whether we add support to the
SlingRequestContext to save/refresh the session at the end of request
processing depending on success or failure of the request if setting a
flag:

   SlingRequestContext.setAutoSave(boolean);

By default a session would always be refreshed, by calling
setAutoSave(true), the Session might be saved before logging it out in
case of a successfull (HTTP status 200, no exceptions thrown) request.

WDYT ?

Regards
Felix


[1] https://issues.apache.org/jira/browse/SLING-73

Reply via email to