You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Padraic Hannon <pi...@wasabicowboy.com> on 2008/01/16 18:47:27 UTC
[OCM] ObjectContentManager and Sessions
While working with the caches and with our own internal content
mapping project I have noticed a slight disconnect between how OCM
handles sessions and how jackrabbit seems to want to handle them. With
the OCM one tends to have a long lived object content manager that is
potentially used by multiple threads. This would mean that the session
would be re-used across multiple reader and writer threads. See http://markmail.org/message/f5lbenhnmdc2vxhx
for details on threading and sessions.
I think this points to the need to have sessions opened and closed
much like in the hibernate model. To accomplish this I think we should
create a ObjectContentManagerFactory which can create the managers so
that each thread can get its own copy. When creating a manager the
factory could use a session factory much like the one that spring has
for JCR (org.springmodules.jcr.JcrSessionFactory). This would allow
sessions to be pooled or created as needed and then be passed to
ObjectContentManagers. The factory could also preload the mapping
classes and other configuration items (like say the cache
implementation factory?). The threads could share a cache (if the
implementation is EhCache or something intelligent) or the cache could
just be a simple hashmap and the assumption would be that the managers
are short lived and the cache is there to eliminate the infinite load
issue.
WDYT?
-paddy
Re: [OCM] ObjectContentManager and Sessions
Posted by Felix Meschberger <fm...@gmail.com>.
Hi Paddy,
While I agree, that the session pooling stuff might find its (right)
place in Jackrabbit, I don't think we should build it into OCM. The
question with the Sling session pooling stuff is, when moving it over to
Jackrabbit, whether it will be "standalone" to be plugged above a JCR
repository (probably yes) or whether it should be built into Jackrabbit
itself (probably not, but might have some advantages).
Regards
Felix
Am Samstag, den 19.01.2008, 11:27 -0800 schrieb Padraic I. Hannon:
> If everyone agrees I'll start working on a patch for jackrabbit-ocm
> based on the Sling session pooling framework. The one issue I see with
> using the sling object content manager pattern is that you have to
> continuously login. It would be nice for an embedded ocm app to only
> provide credentials once.
>
> -paddy
Re: [OCM] ObjectContentManager and Sessions
Posted by "Padraic I. Hannon" <pi...@wasabicowboy.com>.
If everyone agrees I'll start working on a patch for jackrabbit-ocm
based on the Sling session pooling framework. The one issue I see with
using the sling object content manager pattern is that you have to
continuously login. It would be nice for an embedded ocm app to only
provide credentials once.
-paddy
Re: [OCM] ObjectContentManager and Sessions
Posted by Christophe Lombart <ch...@gmail.com>.
I completely agree with Paddic. It should be nice to see this session pool
in the jackrabbit project.
Christophe
On Jan 18, 2008 7:40 PM, Padraic Hannon <pi...@wasabicowboy.com> wrote:
> The more I dig into the Sling code the more I wonder if the pooled
> session implementation should be part of the core jackrabbit code. The
> pooled implementation would be extremely valuable to the OCM part of
> jackrabbit and would probably be great for others as well.
>
> See
>
>
> http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/PooledSession.java
>
>
> -paddy
>
> On Jan 18, 2008, at 9:13 AM, Padraic Hannon wrote:
>
> > Yeah I had been looking at that code, perhaps I'll work on moving
> > those concepts into ocm so others can have it. I was going to do our
> > vehicle domain model with sling but right now I think Edmunds isn't
> > ready for that so I am just using straight ocm and spring :( Once
> > that part is done I am going to adapt it to Sling as I think it is a
> > much nicer model than the spring config version.
> >
> > Pih
> >
> > On Jan 18, 2008, at 4:42 AM, Felix Meschberger wrote:
> >
> >> Hi Paddy,
> >>
> >> This is actually more or less, what we are doing in Sling: We are
> >> using
> >> shared mapping configuration and just creating the mapper (and other
> >> helper) objects when creating ObjectContentManager for a session [1].
> >>
> >> In the context of an HTTP Request we then have one
> >> ObjectContentManager
> >> instance per request whereas the mapping configuration is shared by
> >> all
> >> ObjectContentManager instances. Session management is done in another
> >> factory and behind the scenes we in fact have session pooling.
> >>
> >> Hope this helps.
> >>
> >> Regards
> >> Felix
> >>
> >> [1]
> >>
> http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObjectContentManagerFactory.java
> >>
> >>
> >> Am Mittwoch, den 16.01.2008, 09:47 -0800 schrieb Padraic Hannon:
> >>> While working with the caches and with our own internal content
> >>> mapping project I have noticed a slight disconnect between how OCM
> >>> handles sessions and how jackrabbit seems to want to handle them.
> >>> With
> >>> the OCM one tends to have a long lived object content manager that
> >>> is
> >>> potentially used by multiple threads. This would mean that the
> >>> session
> >>> would be re-used across multiple reader and writer threads. See
> http://markmail.org/message/f5lbenhnmdc2vxhx
> >>> for details on threading and sessions.
> >>>
> >>> I think this points to the need to have sessions opened and closed
> >>> much like in the hibernate model. To accomplish this I think we
> >>> should
> >>> create a ObjectContentManagerFactory which can create the managers
> >>> so
> >>> that each thread can get its own copy. When creating a manager the
> >>> factory could use a session factory much like the one that spring
> >>> has
> >>> for JCR (org.springmodules.jcr.JcrSessionFactory). This would allow
> >>> sessions to be pooled or created as needed and then be passed to
> >>> ObjectContentManagers. The factory could also preload the mapping
> >>> classes and other configuration items (like say the cache
> >>> implementation factory?). The threads could share a cache (if the
> >>> implementation is EhCache or something intelligent) or the cache
> >>> could
> >>> just be a simple hashmap and the assumption would be that the
> >>> managers
> >>> are short lived and the cache is there to eliminate the infinite
> >>> load
> >>> issue.
> >>>
> >>> WDYT?
> >>>
> >>> -paddy
> >>>
> >
>
>
>
Re: [OCM] ObjectContentManager and Sessions
Posted by Padraic Hannon <pi...@wasabicowboy.com>.
The more I dig into the Sling code the more I wonder if the pooled
session implementation should be part of the core jackrabbit code. The
pooled implementation would be extremely valuable to the OCM part of
jackrabbit and would probably be great for others as well.
See
http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/internal/PooledSession.java
-paddy
On Jan 18, 2008, at 9:13 AM, Padraic Hannon wrote:
> Yeah I had been looking at that code, perhaps I'll work on moving
> those concepts into ocm so others can have it. I was going to do our
> vehicle domain model with sling but right now I think Edmunds isn't
> ready for that so I am just using straight ocm and spring :( Once
> that part is done I am going to adapt it to Sling as I think it is a
> much nicer model than the spring config version.
>
> Pih
>
> On Jan 18, 2008, at 4:42 AM, Felix Meschberger wrote:
>
>> Hi Paddy,
>>
>> This is actually more or less, what we are doing in Sling: We are
>> using
>> shared mapping configuration and just creating the mapper (and other
>> helper) objects when creating ObjectContentManager for a session [1].
>>
>> In the context of an HTTP Request we then have one
>> ObjectContentManager
>> instance per request whereas the mapping configuration is shared by
>> all
>> ObjectContentManager instances. Session management is done in another
>> factory and behind the scenes we in fact have session pooling.
>>
>> Hope this helps.
>>
>> Regards
>> Felix
>>
>> [1]
>> http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObjectContentManagerFactory.java
>>
>>
>> Am Mittwoch, den 16.01.2008, 09:47 -0800 schrieb Padraic Hannon:
>>> While working with the caches and with our own internal content
>>> mapping project I have noticed a slight disconnect between how OCM
>>> handles sessions and how jackrabbit seems to want to handle them.
>>> With
>>> the OCM one tends to have a long lived object content manager that
>>> is
>>> potentially used by multiple threads. This would mean that the
>>> session
>>> would be re-used across multiple reader and writer threads. See http://markmail.org/message/f5lbenhnmdc2vxhx
>>> for details on threading and sessions.
>>>
>>> I think this points to the need to have sessions opened and closed
>>> much like in the hibernate model. To accomplish this I think we
>>> should
>>> create a ObjectContentManagerFactory which can create the managers
>>> so
>>> that each thread can get its own copy. When creating a manager the
>>> factory could use a session factory much like the one that spring
>>> has
>>> for JCR (org.springmodules.jcr.JcrSessionFactory). This would allow
>>> sessions to be pooled or created as needed and then be passed to
>>> ObjectContentManagers. The factory could also preload the mapping
>>> classes and other configuration items (like say the cache
>>> implementation factory?). The threads could share a cache (if the
>>> implementation is EhCache or something intelligent) or the cache
>>> could
>>> just be a simple hashmap and the assumption would be that the
>>> managers
>>> are short lived and the cache is there to eliminate the infinite
>>> load
>>> issue.
>>>
>>> WDYT?
>>>
>>> -paddy
>>>
>
Re: [OCM] ObjectContentManager and Sessions
Posted by Padraic Hannon <pi...@wasabicowboy.com>.
Yeah I had been looking at that code, perhaps I'll work on moving
those concepts into ocm so others can have it. I was going to do our
vehicle domain model with sling but right now I think Edmunds isn't
ready for that so I am just using straight ocm and spring :( Once that
part is done I am going to adapt it to Sling as I think it is a much
nicer model than the spring config version.
Pih
On Jan 18, 2008, at 4:42 AM, Felix Meschberger wrote:
> Hi Paddy,
>
> This is actually more or less, what we are doing in Sling: We are
> using
> shared mapping configuration and just creating the mapper (and other
> helper) objects when creating ObjectContentManager for a session [1].
>
> In the context of an HTTP Request we then have one
> ObjectContentManager
> instance per request whereas the mapping configuration is shared by
> all
> ObjectContentManager instances. Session management is done in another
> factory and behind the scenes we in fact have session pooling.
>
> Hope this helps.
>
> Regards
> Felix
>
> [1]
> http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObjectContentManagerFactory.java
>
>
> Am Mittwoch, den 16.01.2008, 09:47 -0800 schrieb Padraic Hannon:
>> While working with the caches and with our own internal content
>> mapping project I have noticed a slight disconnect between how OCM
>> handles sessions and how jackrabbit seems to want to handle them.
>> With
>> the OCM one tends to have a long lived object content manager that is
>> potentially used by multiple threads. This would mean that the
>> session
>> would be re-used across multiple reader and writer threads. See http://markmail.org/message/f5lbenhnmdc2vxhx
>> for details on threading and sessions.
>>
>> I think this points to the need to have sessions opened and closed
>> much like in the hibernate model. To accomplish this I think we
>> should
>> create a ObjectContentManagerFactory which can create the managers so
>> that each thread can get its own copy. When creating a manager the
>> factory could use a session factory much like the one that spring has
>> for JCR (org.springmodules.jcr.JcrSessionFactory). This would allow
>> sessions to be pooled or created as needed and then be passed to
>> ObjectContentManagers. The factory could also preload the mapping
>> classes and other configuration items (like say the cache
>> implementation factory?). The threads could share a cache (if the
>> implementation is EhCache or something intelligent) or the cache
>> could
>> just be a simple hashmap and the assumption would be that the
>> managers
>> are short lived and the cache is there to eliminate the infinite load
>> issue.
>>
>> WDYT?
>>
>> -paddy
>>
Re: [OCM] ObjectContentManager and Sessions
Posted by Felix Meschberger <fm...@gmail.com>.
Hi Paddy,
This is actually more or less, what we are doing in Sling: We are using
shared mapping configuration and just creating the mapper (and other
helper) objects when creating ObjectContentManager for a session [1].
In the context of an HTTP Request we then have one ObjectContentManager
instance per request whereas the mapping configuration is shared by all
ObjectContentManager instances. Session management is done in another
factory and behind the scenes we in fact have session pooling.
Hope this helps.
Regards
Felix
[1]
http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObjectContentManagerFactory.java
Am Mittwoch, den 16.01.2008, 09:47 -0800 schrieb Padraic Hannon:
> While working with the caches and with our own internal content
> mapping project I have noticed a slight disconnect between how OCM
> handles sessions and how jackrabbit seems to want to handle them. With
> the OCM one tends to have a long lived object content manager that is
> potentially used by multiple threads. This would mean that the session
> would be re-used across multiple reader and writer threads. See http://markmail.org/message/f5lbenhnmdc2vxhx
> for details on threading and sessions.
>
> I think this points to the need to have sessions opened and closed
> much like in the hibernate model. To accomplish this I think we should
> create a ObjectContentManagerFactory which can create the managers so
> that each thread can get its own copy. When creating a manager the
> factory could use a session factory much like the one that spring has
> for JCR (org.springmodules.jcr.JcrSessionFactory). This would allow
> sessions to be pooled or created as needed and then be passed to
> ObjectContentManagers. The factory could also preload the mapping
> classes and other configuration items (like say the cache
> implementation factory?). The threads could share a cache (if the
> implementation is EhCache or something intelligent) or the cache could
> just be a simple hashmap and the assumption would be that the managers
> are short lived and the cache is there to eliminate the infinite load
> issue.
>
> WDYT?
>
> -paddy
>
Re: [OCM] ObjectContentManager and Sessions
Posted by Padraic Hannon <pi...@wasabicowboy.com>.
Yeah I was thinking of adapting some of the sling stuff (which Felix
pointed out in another email) for session management. Then there would
be an object content manager factory which would rely on a session
factory and a cache factory.A lot of this already exists in the ocm-
spring project (Jackrabbit/JCRSessionFactory and JCRMappingTemplate
essentially do this), however, it would be nice to have this in the
default implementation. I think the object content manager factory
would also be a good place to plug in a level 2 cache controller and
factory?
-paddy
On Jan 16, 2008, at 11:54 AM, Christophe Lombart wrote:
> +1
>
>
> On Jan 16, 2008 6:47 PM, Padraic Hannon <pi...@wasabicowboy.com> wrote:
>
>> The factory could also preload the mapping
>> classes and other configuration items (like say the cache
>> implementation factory?).
>
>
> If I understand, there is 3 factories :
> one for the ObjectcontentManager
> one for the JCR session
> one for the Cache impl
>
> It is correct ?
>
>
> Christophe
Re: [OCM] ObjectContentManager and Sessions
Posted by Christophe Lombart <ch...@gmail.com>.
+1
On Jan 16, 2008 6:47 PM, Padraic Hannon <pi...@wasabicowboy.com> wrote:
> The factory could also preload the mapping
> classes and other configuration items (like say the cache
> implementation factory?).
If I understand, there is 3 factories :
one for the ObjectcontentManager
one for the JCR session
one for the Cache impl
It is correct ?
Christophe