Announcement Announcement Module
No announcement yet.
Suppress interface from a class Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Suppress interface from a class


    I see that it's possible to remove an interface from a class with a subclass of DelegatingIntroductionInterceptor and the method suppressInterface.
    Is there an exemple in documentation?

    I try the following:


    import tionInterceptor;
    import org.aopalliance.intercept.MethodInvocation;

    public class SuppressInterfaceMixin extends DelegatingIntroductionInterceptor {
    public SuppressInterfaceMixin() {


    -- applicationContext.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC


    <bean id="businesslogicbean" class="org.springframework.aop.framework.ProxyFact oryBean">

    <property name="proxyInterfaces">

    <property name="target">
    <ref local="beanTarget"/>

    <property name="interceptorNames">


    <!-- Bean Classes -->
    <bean id="beanTarget" class="BusinessLogic"/>

    <bean id="suppressionAdvisor" class="SuppressInterfaceMixin"/>


    PS: I want to suppress Test interface from BusinessLogic class...

    Thanks for your help.

  • #2
    It's possible to suppress an interface that would otherwise have been introuced by a DelegatingIntroductionInterceptor, but not suppress an interface implemented by the target. You can either:

    1. use an introduction interceptor to introduce something that disables all methods on that interface, e.g. by throwing UnsupportedOperationException

    2. simply hide the fact that the target implements that interface. If you're using JDK proxies, rather than CGLIB proxies (proxying interfaces only) just omit that interface from the proxied interfaces list and it will be impossible to cast the advised object to the interface you want to suppress. So simply remove "Test" from proxyInterfaces and you're done.


    • #3
      Hi Rod,

      Thanks for your answer and all the works you made on the framework!! Thanks too for your books that are really interesting...

      I have tested the 2. and will look at the 1.
      But in which case can we use the suppressInterface method of class DelegatingIntroductionInterceptor? and what is its utility?



      • #4
        But in which case can we use the suppressInterface method of class DelegatingIntroductionInterceptor? and what is its utility?
        You would use it if the delegate implemented more interfaces than you wanted to expose, and you were using the DefaultIntroductionAdvisor constructor that takes an DelegatingIntroductionInterceptor and automatically picks up the implemented interfaces.


        • #5
          Thanks for your help...