You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "Krohne, Frank - ENCOWAY" <kr...@encoway.de> on 2008/09/09 07:35:42 UTC

Session Handling in WebApplication

Hi,

 

we are developing web applications and now want to use jackrabbit as
contend repository.

 

So the question is, what is the preferred way to handle the jackrabbit
sessions in an web application. 

When to open a new session and when to close the session and when to
write (save) contend to it and to be sure other users don't have
modified the nodes another user is modifying at the moment?

Should we open a new session on every request or share a session on the
same http session?

Are the jackrabbit sessions thread safe?

If we bind the sessions to our own users (self implemented user
management) what is the best way to know when to close the jackrabbit
session if the user doesn't log out or has multiple http sessions open?

 

So we are new to jackrabbit and the docs about are rare to this topic (I
think).

 

It would be great to get some hints or tips on how to handle jackrabbit
sessions in a web application.

 

Thanks in advance

 

Frank


Re: Session Handling in WebApplication

Posted by Michael Wechner <mi...@wyona.com>.
Krohne, Frank - ENCOWAY schrieb:
> Hi,
>
>
>  
>
> It would be great to get some hints or tips on how to handle jackrabbit
> sessions in a web application.
>   

AFAIK:

"Session Handling -- a JCR session is obtained by providing credentials 
to the Repository implementation. Also, the methods on it are not 
thread-safe. The easiest approach for using in a Web Application thus is 
to instantiate a new JCR session for each HTTP request. This is also the 
approach used by the Jackrabbit WebDAV servlet. It is not expected that 
this affects performance negatively; session instatiation should be 
cheap. If this assumption turns out to be wrong, session pooling should 
be considered."

HTH

Michael
>  
>
> Thanks in advance
>
>  
>
> Frank
>
>
>   


AW: Session Handling in WebApplication

Posted by "Krohne, Frank - ENCOWAY" <kr...@encoway.de>.
Hi,

first of all many thanks for your replies.
So I think we have to think about our application design a bit more ;-)
Atm we had an Node-Object within our Model-Objects, but that won't work anymore if we are opening and closing a session for each request.
So maybe we just "save" the Node-ID or the Node-Path to later get to that Node in the repository again.

We also saw the spring modules yesterday and we are going to use them, because spring does the session binding to the actual thread (request) for us and many things more.

Thanks
Frank



> -----Ursprüngliche Nachricht-----
> Von: Michael Harris [mailto:michael.e.harris@gmail.com]
> Gesendet: Dienstag, 9. September 2008 15:00
> An: users@jackrabbit.apache.org
> Betreff: Re: Session Handling in WebApplication
> 
> Spring-modules makes this process really easy.  You should look into
> it.
> 
> On Tue, Sep 9, 2008 at 3:38 AM, Alexander Klimetschek
> <ak...@day.com>wrote:
> 
> > Hi,
> >
> > Michael's answer is right, typically you bound one session to one
> > request. Creating a session, especially with an embedded repository,
> > is very fast. But note that there is no automatic mechanism against
> > concurrent changes from two parallel sessions. Normally the second
> > update wins (if there is no conflict). You can use locking for
> > synchronization or versioning (see the JCR spec [1]). And in most
> > cases, a clear content structure [2] will help in avoiding conflicts
> > in most cases.
> >
> > Regards,
> > Alex
> >
> > [1] http://jcp.org/en/jsr/detail?id=170
> > [2] http://wiki.apache.org/jackrabbit/DavidsModel
> >
> > On Tue, Sep 9, 2008 at 7:35 AM, Krohne, Frank - ENCOWAY
> > <kr...@encoway.de> wrote:
> > > Hi,
> > >
> > >
> > >
> > > we are developing web applications and now want to use jackrabbit
> as
> > > contend repository.
> > >
> > >
> > >
> > > So the question is, what is the preferred way to handle the
> jackrabbit
> > > sessions in an web application.
> > >
> > > When to open a new session and when to close the session and when
> to
> > > write (save) contend to it and to be sure other users don't have
> > > modified the nodes another user is modifying at the moment?
> > >
> > > Should we open a new session on every request or share a session on
> the
> > > same http session?
> > >
> > > Are the jackrabbit sessions thread safe?
> > >
> > > If we bind the sessions to our own users (self implemented user
> > > management) what is the best way to know when to close the
> jackrabbit
> > > session if the user doesn't log out or has multiple http sessions
> open?
> > >
> > >
> > >
> > > So we are new to jackrabbit and the docs about are rare to this
> topic (I
> > > think).
> > >
> > >
> > >
> > > It would be great to get some hints or tips on how to handle
> jackrabbit
> > > sessions in a web application.
> > >
> > >
> > >
> > > Thanks in advance
> > >
> > >
> > >
> > > Frank
> > >
> > >
> >
> >
> >
> > --
> > Alexander Klimetschek
> > alexander.klimetschek@day.com
> >
> 
> 
> 
> --
> ---------------------
> Michael Harris

Re: Session Handling in WebApplication

Posted by Michael Harris <mi...@gmail.com>.
Spring-modules makes this process really easy.  You should look into it.

On Tue, Sep 9, 2008 at 3:38 AM, Alexander Klimetschek <ak...@day.com>wrote:

> Hi,
>
> Michael's answer is right, typically you bound one session to one
> request. Creating a session, especially with an embedded repository,
> is very fast. But note that there is no automatic mechanism against
> concurrent changes from two parallel sessions. Normally the second
> update wins (if there is no conflict). You can use locking for
> synchronization or versioning (see the JCR spec [1]). And in most
> cases, a clear content structure [2] will help in avoiding conflicts
> in most cases.
>
> Regards,
> Alex
>
> [1] http://jcp.org/en/jsr/detail?id=170
> [2] http://wiki.apache.org/jackrabbit/DavidsModel
>
> On Tue, Sep 9, 2008 at 7:35 AM, Krohne, Frank - ENCOWAY
> <kr...@encoway.de> wrote:
> > Hi,
> >
> >
> >
> > we are developing web applications and now want to use jackrabbit as
> > contend repository.
> >
> >
> >
> > So the question is, what is the preferred way to handle the jackrabbit
> > sessions in an web application.
> >
> > When to open a new session and when to close the session and when to
> > write (save) contend to it and to be sure other users don't have
> > modified the nodes another user is modifying at the moment?
> >
> > Should we open a new session on every request or share a session on the
> > same http session?
> >
> > Are the jackrabbit sessions thread safe?
> >
> > If we bind the sessions to our own users (self implemented user
> > management) what is the best way to know when to close the jackrabbit
> > session if the user doesn't log out or has multiple http sessions open?
> >
> >
> >
> > So we are new to jackrabbit and the docs about are rare to this topic (I
> > think).
> >
> >
> >
> > It would be great to get some hints or tips on how to handle jackrabbit
> > sessions in a web application.
> >
> >
> >
> > Thanks in advance
> >
> >
> >
> > Frank
> >
> >
>
>
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>



-- 
---------------------
Michael Harris

Re: Session Handling in WebApplication

Posted by Alexander Klimetschek <ak...@day.com>.
Hi,

Michael's answer is right, typically you bound one session to one
request. Creating a session, especially with an embedded repository,
is very fast. But note that there is no automatic mechanism against
concurrent changes from two parallel sessions. Normally the second
update wins (if there is no conflict). You can use locking for
synchronization or versioning (see the JCR spec [1]). And in most
cases, a clear content structure [2] will help in avoiding conflicts
in most cases.

Regards,
Alex

[1] http://jcp.org/en/jsr/detail?id=170
[2] http://wiki.apache.org/jackrabbit/DavidsModel

On Tue, Sep 9, 2008 at 7:35 AM, Krohne, Frank - ENCOWAY
<kr...@encoway.de> wrote:
> Hi,
>
>
>
> we are developing web applications and now want to use jackrabbit as
> contend repository.
>
>
>
> So the question is, what is the preferred way to handle the jackrabbit
> sessions in an web application.
>
> When to open a new session and when to close the session and when to
> write (save) contend to it and to be sure other users don't have
> modified the nodes another user is modifying at the moment?
>
> Should we open a new session on every request or share a session on the
> same http session?
>
> Are the jackrabbit sessions thread safe?
>
> If we bind the sessions to our own users (self implemented user
> management) what is the best way to know when to close the jackrabbit
> session if the user doesn't log out or has multiple http sessions open?
>
>
>
> So we are new to jackrabbit and the docs about are rare to this topic (I
> think).
>
>
>
> It would be great to get some hints or tips on how to handle jackrabbit
> sessions in a web application.
>
>
>
> Thanks in advance
>
>
>
> Frank
>
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com