none
architectural solutions RRS feed

  • Question

  • Hi,

    I've just been wondering about Interceptor architectural patterns. I'm actually a novice even in "ordinary" development, not saying about some architectural things. But just interesting...

    Could somebody really tell me about the pattern in a few words. For my getting it fast.
    Friday, October 17, 2008 12:14 PM

Answers

  • The events can be any number of things like, LoadSessionState (ASP.NET), Before a Message is Dispatch to the service (WCF) or before a method call (AOP).

     

    For asp.net it's the ASP.NET runtime that invokes the events when a request is processed. For WCF it's the WCF runtime that invokes the events and for AOP frameworks it's some kind of object container. ¨

     

    In short it's another piece of code that works as a container for the code that you want intercepted. The CLR doesn't have such a mechanism publicly available for developers to use, so if you want to use it you need to eiter build your own object runtime on top of the CLR, like Spring.NET does for AOPish things, or utilize interception mechanisms from other parts of the framework like the ContextBound object from remoting och WCF.

     

    Friday, October 17, 2008 5:44 PM

All replies

  • Basically the idea is to intercept any incoming messages or method calls and do stuff with parameters or messages before they get passed down to what was actually called.

    An example is the ASP.NET HTTP Module model where the http request get's intercepted by the statemanger, asp.net authorization providers etc before the request gets to your page and code.

    You can read more about the background and implementation of the pattern here:

    http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html




    Friday, October 17, 2008 12:38 PM
  • Yes, but it seems to me that an ordinary Indirection Layer can intercept messages and calls. And Interceptor is supposed to be a more complex solution. (However, it also exists and that's already enough for occupying another niche.)

    To tell the truth at once, I haven't read the material you put as a reference). I believe you can explain the pattern yourself with a little bit more details).



    I'll put here some sentences from one source describing the pattern and ask something concerning them.

    "An INTERCEPTOR is a mechanism for transparently updating the services offered by the framework
    in response to incoming events. An application can register with the framework any number
    of INTERCEPTORS that implement new services. The framework facilitates this registration
    through dispatchers that assign events to INTERCEPTORS. The framework also provides the applications
    with the means to introspect on the framework’s behavior in order to properly handle
    the events."

    What are these events and who invokes them?

    Friday, October 17, 2008 1:23 PM
  • The events can be any number of things like, LoadSessionState (ASP.NET), Before a Message is Dispatch to the service (WCF) or before a method call (AOP).

     

    For asp.net it's the ASP.NET runtime that invokes the events when a request is processed. For WCF it's the WCF runtime that invokes the events and for AOP frameworks it's some kind of object container. ¨

     

    In short it's another piece of code that works as a container for the code that you want intercepted. The CLR doesn't have such a mechanism publicly available for developers to use, so if you want to use it you need to eiter build your own object runtime on top of the CLR, like Spring.NET does for AOPish things, or utilize interception mechanisms from other parts of the framework like the ContextBound object from remoting och WCF.

     

    Friday, October 17, 2008 5:44 PM
  • OK, thanks. In general your post was helpful. I've understood what I wanted to.

    But I would like to add something.

    An event is a trigger initiating reaction(s).
    So if another piece of code wrapping my code pulls such a trigger, then it invokes an event.
    But it should know when to pull.
    And my code indicates when. Thus my code invokes the event de facto.
    That is different runtimes invoke those events mediately, while the primary code is the initiator being looked for.
    Friday, October 17, 2008 7:56 PM