cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Hartmann <>
Subject Re: [jcr] Scope of JCRNodeSource
Date Fri, 22 Jul 2005 12:46:40 GMT
Sylvain Wallez wrote:


>> 1) IIUC, every time a source is resolved a new JCR session is created.
>>    Does this mean that no transactions can be used?
>>    Maybe it would make sense to attach the JCR session to the Cocoon
>>    session, so that all resolved JCRNodeSources save their data to a
>>    single session which would allow them to take part in a single
>>    transaction?
> Yes it makes sense! As Cedric said this stuff is fairly new, and 
> currently the session management is definitely suboptimal and doesn't 
> allow for transaction management.
> Now what should be the scope of the session? I'm not sure there is a 
> single answer to this and the plan was to allow to configure the 
> Repostory object with input/output modules that whould be used to 
> get/store the session. Such modules would typically store the JCR 
> session in a request attribute or in a servlet session attribute.

That sounds quite useful, but maybe a special service (interface)
would make more sense than an input + output module?

> And this leads to yet another problem: calling session.logout(), which 
> happens at different times depending on the session scope...
> The solution (thinking as a type) can be to have some kind of 
> JCRSessionPolicy object that would take care of getting/storing/closing 
> the session.

Would that be something like this?

public Source getSource(String uri, Map parameters) ... {

     JCRSessionPolicy policy = null;
     try {
         policy = (...) this.manager.lookup(JCRSessionPolicy.ROLE);

         // policy logs in or restores JCR session from wherever
         Session session = policy.getSession();

         source = createSource(session, path);

         // policy stores session for further use

     finally {
         ... release policy


> For now, you can simply override the login() method to manage the session!

Good idea, I'll try that.


>> I read a comment by Ugo Cei that it would make sense to drop the Cocoon
>> Repository block in favor of the JCR block. Does that mean that the
>> JCRNodeSource would be extended to provide access to JCR functionality?
> I'm not sure this is a good idea. The repository block defines some 
> Source extensions that can be used by source implementations that wrap a 
> repository (JCR, webdav, etc).

That sounds very useful and would dovetail with the Lenya repo integration
(see my other mail).

Thanks for your answer!

-- Andreas

View raw message