modeshape - jcr node detach: using JcrNode properties outside of session scope (like some kind of DTO) -


currently doing test-app jcr (modeshape).

  • the abstracted flow follows: session.open, repository fetches on or more nodes related query, session.close.

  • the resulting nodes contain properties, etc. need present view. have naive setup of letting view take properties jcrnode directly. gives error like: "the session id of 'e2881d98-56fd-4a57-9cce-1a7d087a11e8' has been closed", makes sense.

i believe general approach (please correct if otherwise) create sort of nodedto populated jcrnode when session still active. view free use nodedto wants.

now, perfect structure such nodedto mimic structure of jcrnode 1-to-1 why not use jcrnode dto itself? accomplished akin hibernate detach/attach. realize jcrnode (with children) can contain lots of data, there should parameters determine depth of detachment, etc.

another approach have opensessioninview-pattern, although mvc-framework specific.

so can see several approaches this, best approach first (imo):

  1. detach/attach functionality jcrnodes
  2. good library of helper classes create dtos
  3. opensessioninview

any comments on 'best-practice' approach, etc. appreciated.

unfortunately, jcr 2.0 specification not define way nodes detached session, kind of functionality implementation-specific.

in lieu of jcr method, technique agnostic of jcr implementation copy properties , child references in simple structure of own creation. yes, structure @ high-level similar jcr node, wouldn't need have 90% of methods defined on node: simple map of properties (by name), , list (or ordered map) of child nodes. , doing this, code responsible copying nodes , subgraphs you're interested in, can define semantics suit needs.

however, project lead modeshape, agree detaching jcr nodes seem feature, , i've logged enhancement request in modeshape project. there lot of details work out in terms of proper semantics (especially relating child or descendant nodes), i'd invite watch request , participate in discussion on issue.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -