Skip to content

Add support for Channel Interceptors to be applied "globally" and based on name patterns [INT-789] #4796

Closed

Description

@spring-operator

Mark Fisher opened INT-789 and commented


Issue Links:

Activity

  1. spring-operator commented on Sep 25, 2009

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    Another somewhat related idea:

    Channels could maybe support an "abstract" boolean attribute and then others use "parent" (to inherit interceptors, etc). This would be consistent with Spring beans in general and also Spring Batch "step" elements.

  2. spring-operator commented on Mar 4, 2010

    @spring-operator
    ContributorAuthor

    Oleg Zhurakousky commented

    Did you mean something like this (besides the abstract channels idea from the previous comment):

    <int:interceptors id="customInterceptoStack">
       <int:ref bean="fooIniterceptor"/>
       <int:ref bean="barIniterceptor"/>
    </int:interceptors>
    
    <int:channel id="output">
       <int:interceptors ref="customInterceptoStack"/>
    </int:channel>
  3. spring-operator commented on Mar 4, 2010

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    We might want to support that style also (should be easy enough by creating a stack impl that is itself a single ChannelInterceptor), but I was thinking about something more like this:

    <int:channel-interceptor channel-name-pattern="admin.*">
        <ref bean="securityInterceptor"/>
    </int:channel-interceptor>
    
  4. spring-operator commented on Mar 26, 2010

    @spring-operator
    ContributorAuthor

    Oleg Zhurakousky commented

    Support for global channel interceptors was added.
    Example (global interceptors below will be added to both channels):

    <int:channel-interceptor-chain channel-name-pattern="input*, bar*, foo" order="3">
        <bean class="foo.barSampleInterceptor"/>
        <ref bean="someOtherInterceptor"
    </int:channel-interceptor-chain>
    
    <int:channel id="bar">
        <int:interceptors>
           <bean class="foo.barSampleInterceptor"/>
        </int:interceptors>
    </int:channel>
    
    <int:channel id="bartender"/>
    

    The 'order' attribute signifies where this interceptor chain will be added to the channel if it already has interceptors defined locally (e.g., see 'bar' channel above). Positive value will ensure that global interceptors are added AFTER the existing interceptors. Negative value would add them before.
    The reason why we use number instead of enumeration 'BEFORE' and 'AFTER' is because we need to manage the order of those global interceptor between one another.

    This issue is READY TO RESOLVE pending review.

    Documentation must be added before resolving it!!!

  5. spring-operator commented on May 7, 2010

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    Add the docs if you get a chance, and I'll review in the morning.

  6. spring-operator commented on May 7, 2010

    @spring-operator
    ContributorAuthor

    Oleg Zhurakousky commented

    Documentation was added. See Global Channel Interceptors Configuration section

  7. spring-operator commented on Jun 15, 2010

    @spring-operator
    ContributorAuthor

    Oleg Zhurakousky commented

    Still looks a bit confusing, would like to simplify it further

  8. spring-operator commented on Jun 15, 2010

    @spring-operator
    ContributorAuthor

    Oleg Zhurakousky commented

    One of the suggestion is to eliminate the explicit chaining and have global interceptor defined as top level elements with order attribute.

    <channel-interceptor ref="someInterceptor" pattern="*" order="5"/>
    
    <channel-interceptor pattern="foo*">
        <beans:bean class="org.foo.SomeChannelInterceptorThatImplementsOrdered"/>
    </channel-interceptor>
    

    A few notes:

    • the fact that the <channel-interceptor/> is a top-level element (instead of a sub-element in a channel) should be enough to signify that it's "global".
    • the "channel-name-pattern" can just be "pattern" since we know it's applying to channels (that's also what the secured-channels configuration has)
    • if "order" is provided as an attribute, we can wrap the interceptor bean in OrderedChannelInterceptor (a delegate that also implements Ordered).
    • we should just set all interceptors on the AbstractMessageChannel instance and let it handle the sorting internally (we would need to define an addInterceptor method for the BPP to invoke)

    I think I am OK with not defining an explicit interceptor-chain and simply have an order attribute on individual interceptors. This will result in natural chaining anyway, so should be fine and easy to understand.
    Although even with this scenario we could still have individual interceptors defined within the channels, which means we still have to maintain order semantics for global interceptors as BEFORE < 0 (e.g., order="-1") and AFTER (e.g., order="6") allowing global interceptors to be applied before and after local interceptors.
    THoughts?

  9. spring-operator commented on Jun 17, 2010

    @spring-operator
    ContributorAuthor

    Oleg Zhurakousky commented

    Global interceptors can now be applied as described in the last comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions