PDA

View Full Version : strange problem with BeanNameAutoProxyCreator



kainz
Nov 19th, 2004, 10:12 AM
Hi at all.
I have a strange problem with BeanNameAutoProxyCreator.
My cfg file is:

<bean id="com.bytecode.osw.interfaces.IObjectLocator" class=".."/>

<bean id="oswBeanNameProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNa meAutoProxyCreator">
<property name="beanNames"><value>com.bytecode.osw.interfaces.I*</value></property>
<property name="interceptorNames">
<list>
<value>myInterceptor</value>
</list>
</property>
</bean>

But this doesn't work, but if I use:
<property name="beanNames"><value>com.bytecode.osw.interfaces.IObject*</value></property>

it works!!!

Can someone help me?

irbouho
Nov 20th, 2004, 06:54 PM
This is quite strange!!!
What version are you using? could you show the log result?
following method, from BeanNameAutoProxyCreator source returns true in both cases:

/**
* Return if the given bean name matches the mapped name.
* The default implementation checks for "xxx*" and "*xxx" matches.
* Can be overridden in subclasses.
* @param beanName the bean name to check
* @param mappedName the name in the configured list of names
* @return if the names match
*/
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;

kainz
Nov 21st, 2004, 06:23 AM
I'm using 1.1.2 vesrion.

Now I haven't the log , but spring simlply don't cretae a proxy and so the intreceptor
does'nt fire.
I have looked at source of isMatch too, and i really don't know why it doese't work.