173 |
174 |
174 setAddListenerMethod(getMethod(sourceClass, addListenerMethodName, 1)); |
175 setAddListenerMethod(getMethod(sourceClass, addListenerMethodName, 1)); |
175 setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1)); |
176 setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1)); |
176 |
177 |
177 // Be more forgiving of not finding the getListener method. |
178 // Be more forgiving of not finding the getListener method. |
178 Method method = Introspector.findMethod(sourceClass, |
179 if (getListenerMethodName != null) { |
179 getListenerMethodName, 0); |
180 setGetListenerMethod(Introspector.findInstanceMethod(sourceClass, getListenerMethodName)); |
180 if (method != null) { |
|
181 setGetListenerMethod(method); |
|
182 } |
181 } |
183 } |
182 } |
184 |
183 |
185 private static Method getMethod(Class cls, String name, int args) |
184 private static Method getMethod(Class cls, String name, int args) |
186 throws IntrospectionException { |
185 throws IntrospectionException { |
187 if (name == null) { |
186 if (name == null) { |
188 return null; |
187 return null; |
189 } |
188 } |
190 Method method = Introspector.findMethod(cls, name, args); |
189 Method method = Introspector.findMethod(cls, name, args); |
191 if (method == null) { |
190 if ((method == null) || Modifier.isStatic(method.getModifiers())) { |
192 throw new IntrospectionException("Method not found: " + name + |
191 throw new IntrospectionException("Method not found: " + name + |
193 " on class " + cls.getName()); |
192 " on class " + cls.getName()); |
194 } |
193 } |
195 return method; |
194 return method; |
196 } |
195 } |