Announcement Announcement Module
Collapse
No announcement yet.
autoproxy infrastrature filter allow "NOT?" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • autoproxy infrastrature filter allow "NOT?"

    Hi there,
    I am new to spring and cannot find an answer to this in any book or online documentation. I would like to use the BeanNameAutoProxyCreator to intercept almost all objects in the application context. The catch is it's *almost* all.

    I need this option if I use a dynamic proxy (such as DebugInterceptor) since it cannot proxy concrete classes, or alternatively, I need this option if I use CGLIB in order to exclude final classes.


    My question is, is there a way to specify the NOT flag in the config file?
    e.g.:,
    Code:
      <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
          <property name="beanNames"><value>*</value></property>
    <!--want to specify NOT ExcudedClass1*, ExcudedClass2* here-->
    
        <property name="interceptorNames">
          <list>
            <value>myInterceptor</value>
          </list>
        </property>
        <property  name="proxyTargetClass"><value>true</value></property>
        <property name="optimize"><value>true</value></property>
      </bean>
    </beans>
    I woiuld appreciate anyone's help. Could anyone point me to some documentation on this?

  • #2
    I would just create a class called ExcludedBeanNameAutoProxyCreator that extends BeanNameAutoProxyCreator. The method you want to override in BeanNameAutoProxyCreator is the following:

    Code:
    	protected boolean isMatch&#40;String beanName, String mappedName&#41; 
       &#123;
    		return &#40;mappedName.endsWith&#40;"*"&#41; && beanName.startsWith&#40;mappedName.substring&#40;0, mappedName.length&#40;&#41; - 1&#41;&#41;&#41; ||
    				&#40;mappedName.startsWith&#40;"*"&#41; && beanName.endsWith&#40;mappedName.substring&#40;1, mappedName.length&#40;&#41;&#41;&#41;&#41;;
    	&#125;
    Changing this method to return false instead of true in the event of a match should be pretty straightforward.

    Comment


    • #3
      thanks!

      Hi Colby,
      This looks really reasonable. Thanks a lot!!
      Melinda

      Comment

      Working...
      X