Results 1 to 2 of 2

Thread: Intercepting Specific Methods

  1. #1

    Default Intercepting Specific Methods

    Hello.

    In our application we need to intercept some methods to include information in a Thread Local variable.
    Our sequence diagram:

    Controller -> DAO -> Queries -> Data Source

    I need to intercept some methods of the Controller layer because, depending on the method, the application should use one data source or another (actually there is more than 10), and this behaviour is dynamic, ie, it depends on parameters provided when calling the methods, so I can not use the Spring XML for this purpose.

    I would like something like this (the interceptor tag is just my imagination):

    <bean id="myController" singleton="false"
    class="MyController">
    <interceptor method="doSomething" class="MyInterceptorClass"/>
    </bean>

    Is there something in Spring I can use for this?

    Thanks

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Yes, take a look at ProxyFactoryBean. You can add an advice to your bean, which will intercept the methods and based on logic you desire, change the ThreadLocal variable.
    Take a look at the reference documentation and the javadocs for more information.,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •