Hello,
the standard hibernate way to add an interceptor to a session is:

SomeInterceptor int = new SomeInterceptor();
  | int.setStateDependentFromCurrentUserOperations(...);
  | Session session = sf.openSession( int );

Which allows to build an interceptor passing it whatever information is needed 
for its jobs (ex. auditing what the current logged user is doing).

Using HibernateContext it's only possible to pass a reflection generated 
interceptor, specified in xml, with no way to pass it some state dependent 
informations.
I've seen some pattern on the forums forcing you to add special infos to all 
the hibernate objects (the auditing example) but I would prefere to not pollute 
my objects with additional fields.
I would really like to be able to manually add an interceptor to a session 
using the HibernateContext class, so I was thinking something like:

HibernateContext.java
   public static Session getSession(String name, Interceptor interceptor)
  |     ... and ...
  | 
  | private static Session generateSession(String name, Interceptor 
interceptor) throws HibernateException
  | 

The code would check to see if interceptor is != null, and if it is, it would 
use the factory.openSession(interceptor) instead of factory.openSession().
I still have to find where it looks for the HibernateInterceptor parameter of 
the mbean, and how to make sure the xml specified interceptor have less or more 
precedence over the code specified one.
What do you think? Is this a bad idea? I think it would make some matters more 
simple to deal with.

Cheers,
Filippo





View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3865001#3865001

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3865001


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to