[jira] [Commented] (SLING-1391) Make JcrModifiablePropertyMap write changes directly

2012-07-16 Thread Tobias Bocanegra (JIRA)

[ 
https://issues.apache.org/jira/browse/SLING-1391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13415811#comment-13415811
 ] 

Tobias Bocanegra commented on SLING-1391:
-

what about adding a method: save(boolean persist)
that only pushes the cached entries to the node but does not call 
session.save() (if persist is false).


 Make JcrModifiablePropertyMap write changes directly
 

 Key: SLING-1391
 URL: https://issues.apache.org/jira/browse/SLING-1391
 Project: Sling
  Issue Type: Improvement
  Components: JCR
Affects Versions: JCR Resource 2.0.6
Reporter: Vidar S. Ramdal

 As discussed on http://markmail.org/thread/io2dnkykjnayydwz, the current 
 JcrModifiablePropertyMap implementation of the PersistableValueMap interface 
 uses a cached map to store changed values. The cached values are not written 
 to the underlying node until a PVM.save() is called - at which point JMPM 
 calles Node.save() to persist the changes. Thus, reverting changes made in a 
 session is impossible.
 This makes atomic operations such as this difficult to implement:
 try {
// Modify a property through PersistableValueMap
PersistableValueMap props = resource.adaptTo(PersistableValueMap.class);
props.put(prop, value);
props.save();
// Do some other, unrelated changes
Node sibling = resource.adaptTo(Node.class).getParent().addNode(child);
sibling.doSomeChange(); // This may throw an exception
session.save();
 } catch(Exception e) {
session.refresh(false); // Cancel the pending changes of this session
 } 
 Felix suggests (http://markmail.org/message/5fae3cwsshbnemrf):
 * Enable the PersistableValueMap to write through to the JCR
transient space on put().
  * Write-through is configurable on a global level (in the
JcrResourceResolver providing the PersistableValueMap
instances upon adapt()). By default it is switched off
(backwards compatiblity).
  * Write-through can also be switched on/off on a per-instance
level of the PersistableValueMap object (setWriteThrough(boolean))
  * PersistableValueMap.save() first writes back local changes
not already stored using write-through and then calls node.save()
  * PersistableValueMap.reset() drops local changes not already stored
using write-through and then calls node.refresh(false)
  * When we finally do full CRUD in the ResourceResolver, we should
add save/reset methods, which would call Session.save() or
refresh(false), resp. For now the Session methods must be called
directly.
 This task is about implementing Felix' suggestions.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Commented] (SLING-1391) Make JcrModifiablePropertyMap write changes directly

2012-07-06 Thread Carsten Ziegeler (JIRA)

[ 
https://issues.apache.org/jira/browse/SLING-1391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13407766#comment-13407766
 ] 

Carsten Ziegeler commented on SLING-1391:
-

We should rethink this in the light of SLING-2530

 Make JcrModifiablePropertyMap write changes directly
 

 Key: SLING-1391
 URL: https://issues.apache.org/jira/browse/SLING-1391
 Project: Sling
  Issue Type: Improvement
  Components: JCR
Affects Versions: JCR Resource 2.0.6
Reporter: Vidar S. Ramdal

 As discussed on http://markmail.org/thread/io2dnkykjnayydwz, the current 
 JcrModifiablePropertyMap implementation of the PersistableValueMap interface 
 uses a cached map to store changed values. The cached values are not written 
 to the underlying node until a PVM.save() is called - at which point JMPM 
 calles Node.save() to persist the changes. Thus, reverting changes made in a 
 session is impossible.
 This makes atomic operations such as this difficult to implement:
 try {
// Modify a property through PersistableValueMap
PersistableValueMap props = resource.adaptTo(PersistableValueMap.class);
props.put(prop, value);
props.save();
// Do some other, unrelated changes
Node sibling = resource.adaptTo(Node.class).getParent().addNode(child);
sibling.doSomeChange(); // This may throw an exception
session.save();
 } catch(Exception e) {
session.refresh(false); // Cancel the pending changes of this session
 } 
 Felix suggests (http://markmail.org/message/5fae3cwsshbnemrf):
 * Enable the PersistableValueMap to write through to the JCR
transient space on put().
  * Write-through is configurable on a global level (in the
JcrResourceResolver providing the PersistableValueMap
instances upon adapt()). By default it is switched off
(backwards compatiblity).
  * Write-through can also be switched on/off on a per-instance
level of the PersistableValueMap object (setWriteThrough(boolean))
  * PersistableValueMap.save() first writes back local changes
not already stored using write-through and then calls node.save()
  * PersistableValueMap.reset() drops local changes not already stored
using write-through and then calls node.refresh(false)
  * When we finally do full CRUD in the ResourceResolver, we should
add save/reset methods, which would call Session.save() or
refresh(false), resp. For now the Session methods must be called
directly.
 This task is about implementing Felix' suggestions.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] Commented: (SLING-1391) Make JcrModifiablePropertyMap write changes directly

2011-01-18 Thread Carsten Ziegeler (JIRA)

[ 
https://issues.apache.org/jira/browse/SLING-1391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12983562#action_12983562
 ] 

Carsten Ziegeler commented on SLING-1391:
-

Rethinking this, I now agree that this makes more sense, especially if we're 
moving to full CRUD operations though the resource resolver. 

 Make JcrModifiablePropertyMap write changes directly
 

 Key: SLING-1391
 URL: https://issues.apache.org/jira/browse/SLING-1391
 Project: Sling
  Issue Type: Improvement
  Components: JCR
Affects Versions: JCR Resource 2.0.6
Reporter: Vidar S. Ramdal

 As discussed on http://markmail.org/thread/io2dnkykjnayydwz, the current 
 JcrModifiablePropertyMap implementation of the PersistableValueMap interface 
 uses a cached map to store changed values. The cached values are not written 
 to the underlying node until a PVM.save() is called - at which point JMPM 
 calles Node.save() to persist the changes. Thus, reverting changes made in a 
 session is impossible.
 This makes atomic operations such as this difficult to implement:
 try {
// Modify a property through PersistableValueMap
PersistableValueMap props = resource.adaptTo(PersistableValueMap.class);
props.put(prop, value);
props.save();
// Do some other, unrelated changes
Node sibling = resource.adaptTo(Node.class).getParent().addNode(child);
sibling.doSomeChange(); // This may throw an exception
session.save();
 } catch(Exception e) {
session.refresh(false); // Cancel the pending changes of this session
 } 
 Felix suggests (http://markmail.org/message/5fae3cwsshbnemrf):
 * Enable the PersistableValueMap to write through to the JCR
transient space on put().
  * Write-through is configurable on a global level (in the
JcrResourceResolver providing the PersistableValueMap
instances upon adapt()). By default it is switched off
(backwards compatiblity).
  * Write-through can also be switched on/off on a per-instance
level of the PersistableValueMap object (setWriteThrough(boolean))
  * PersistableValueMap.save() first writes back local changes
not already stored using write-through and then calls node.save()
  * PersistableValueMap.reset() drops local changes not already stored
using write-through and then calls node.refresh(false)
  * When we finally do full CRUD in the ResourceResolver, we should
add save/reset methods, which would call Session.save() or
refresh(false), resp. For now the Session methods must be called
directly.
 This task is about implementing Felix' suggestions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.