|
From: Thierry T. <te...@ya...> - 2005-12-12 14:01:48
|
Hi all,
I want to know if the use of multiple setters (with
the same name but not the same signature) for the same
property must be supported by the Spring framework.
For example, the first setter is a method with the
type of the property and the second with a different
type which converts this type to the type of the
property.
My question comes from the support of notifications in
the JMX support of Spring. It allows applications to
define notification listeners both with a list or a
map with the following methods:
1°) public void
setNotificationListeners(NotificationListenerBean[]
notificationListeners) {...}
2°) public void setNotificationListeners(Map
listeners) throws MalformedObjectNameException {...}
You can only use the second within the application
context because the use of the other throws this
exception:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'exporter' defined in
class path resource [applicationContext.xml]: Error
setting property values; nested exception is
org.springframework.beans.PropertyAccessExceptionsException:
PropertyAccessExceptionsException (1 errors); nested
propertyAccessExceptions are:
[org.springframework.beans.TypeMismatchException:
Failed to convert property value of type
[java.util.ArrayList] to required type [java.util.Map]
for property 'notificationListeners']
PropertyAccessExceptionsException (1 errors)
org.springframework.beans.TypeMismatchException:
Failed to convert property value of type
[java.util.ArrayList] to required type [java.util.Map]
for property 'notificationListeners'
at
org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:947)
at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:693)
at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:574)
at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:734)
at
org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:761)
at
org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:750)
Thanks for any help you can provide.
Thierry
Take a look at my blog:
http://jroller.com/page/Templth/
(old: http://templth.blogspot.com/)
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com
|