-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: post-Session open Interceptor registration
PostPosted: Fri Jan 02, 2004 3:32 pm 
Newbie

Joined: Wed Sep 17, 2003 12:08 pm
Posts: 8
I've got a situation where I'd like to be able to register an Interceptor at runtime in some - but not all - cases. I'm using a ThreadLocal Session, so I figured I'd just tweak my API to allow someone to pass in an Interceptor when they requested the Session, but low and behold, there's no way to register an Interceptor after the Session has been created.

Is my best option to always create the Session with the Interceptor (through the configuration) and then do some sort of instance checking in the Interceptor to see if it "really" should fire? Am I missing something?

I haven't looked too deeply into SessionImpl, but what was the architectural thinking around why post-open registration of Interceptors wasn't allowed? I suppose it might get sloppy if some registers one and then doesn't clear it when they're finished...

Thanks for the feedback.

-ep


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 3:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
It should not be too difficult to create an interceptor which acts as a wrapper for interceptors you add dynamically and delegates all calls to the dynamically added ones. There is a more mature event api on the roadmap, so you might see some additional possibilitys in that area.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 3:56 pm 
Newbie

Joined: Wed Sep 17, 2003 12:08 pm
Posts: 8
Thanks for the reply.

The issue with your approach is that there isn't a hook on the Session to get at the Interceptor. So if I registered some sort of InterceptorProxy at the time of config or session open, I'd have no way to get at it later in order to 'stuff it' with actual Interceptor Impls.

-ep


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 5:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at http://www.hibernate.org/Documentation/ChainedInterceptor.
Adding some kind of ChainedInterceptor manager to plug / unplug concrete interceptors shouldn't be difficult.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 11:26 am 
Newbie

Joined: Wed Sep 17, 2003 12:08 pm
Posts: 8
Again, thanks for the help.

I understand the concept of an aggregated Interceptor. It is undoubtably the pattern I would look to implement. But it still doesn't answer my question.

Lets say I configure the Session to use ChainedInterceptor as its Interceptor. How do I get a handle to the ChainedInterceptor to add new Interceptors to the chain at runtime?

I'm sorry if I'm missing something obvious here. And if I should move this out of the Architecture forum, I can do that. It feels architectural to me.

-ep


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
edinapimp wrote:
And if I should move this out of the Architecture forum, I can do that. It feels architectural to me.

Too late, Wrong site is better than dup post.

For Interceptor management, you will have to do the management way by yourself (maneger implementing singleton/local session pattern...), and thus independant from session lifecycle (unless you wrap hibernate session to add an activateIncerceptor() method).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 1:19 pm 
Newbie

Joined: Wed Sep 17, 2003 12:08 pm
Posts: 8
Thanks for the reply. I still assert this is an architectural issue.

Wrapping the Session won't solve the problem, either. Too much of the interceptor callback stuff is private. I also don't feel that is the appropriate pattern.

I will fine an enhancement request in JIRA. Maybe it'll get shot down, but hey, it's worth a shot.

-dc


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.