I'm trying to subscribe to Session.Persisting event, and want to do some post-processing in this event. Or Is there any want to inject my own Persisting handler or smth into Session?

Updated at 22.04.2010 7:52:39

Just tried to implement my own ChainingSessionHandler. Got a nice problem. Why do you mark Session.Handler internal?? Now i'm unable to do so: var handler = new OperationalSessionHandler(e.Session.Handler)

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Apr 22 '10 at 07:44

xumix's gravatar image


One Answer:

The main answer: see Audit Sampel for DO4, in fact it takes care of this: http://goo.gl/Bqrq

Concerning your own SessionHandler:

  • It's a bad idea to implement your own one in this case, since there are simpler APIs for this (session events).

  • Session.Handler must really be internal. But we should really provide a way to read it, if this is intentional. Otherwise DirectSessionAccessor.ChangeSessionHandler is nearly useless :) Undiscovered by tests, since Xtensive.Storage internals are visible to its test assemblies. To be fixed.

Domain module is used just to ensure audit works @ every Session. So you don't need it - you should just subscribe to events.

SessionHandler is very low-level API - it is attractive when you need no intercept low-level oeprations, and moreover, change their results. In your case it's really better to subscribe to these 3 events.

Btw, see VersionValidator and VersionCapturer - they're much better "template" for this task.

answered Apr 22 '10 at 08:40

Alex%20Yakunin's gravatar image

Alex Yakunin

Moreover, as far as i can judge, you use a Domain module? So why use domain module and dont use a session module/session handler?

(Apr 22 '10 at 08:40) xumix xumix's gravatar image

main answer: ok, thx, looks like what I want

session events there is no EntityChangED event, and I dont want to subscribe to 3 events instead of 1(created/removed/fieldchanged)

(Apr 22 '10 at 08:40) xumix xumix's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA