Method[] listenerMethods = descriptor.getListenerMethods(); for (Method listenerMethod : listenerMethods) { final MetaMethod metaMethod = CachedMethod.find(descriptor.getAddListenerMethod());
method = eventSetDescriptors[i].getAddListenerMethod();
public String getAddListenerMethodName() { if(descriptor.getAddListenerMethod() != null) { return descriptor.getAddListenerMethod().getName(); } return null; }
/** * Get the descriptor for an event set of this bean indicated by the event set's adder method * name. * * @param adderName Event set adder method name. * @return The EventSetDescriptor for the given event set */ public EventSetDescriptor getEventSetDescriptorForAdder(String adderName) { EventSetDescriptor[] esds = beanInfo.getEventSetDescriptors(); for (int i = 0; i < esds.length; i++) { java.lang.reflect.Method m = esds[i].getAddListenerMethod(); if (m != null && m.getName().equals(adderName)) return esds[i]; } return null; }
private void addEventListener(Object producer, EventSetDescriptor set, Object consumer, Location location) { Method m = set.getAddListenerMethod(); try { m.invoke(producer, new Object[] { consumer }); } catch (Exception ex) { _errorLog.error(ServiceMessages.unableToAddListener( producer, set, consumer, location, ex), location, ex); } }
builder.append("name=").append(descriptor.getName()); if (descriptor.getAddListenerMethod() != null) builder.append(",").append("addMethod=").append(descriptor.getAddListenerMethod().getName());
/** * Start listening to the source object */ private void listenToSource() { try { if (source != null) { BeanInfo info = getBeanInfo(source.getClass(), source); EventSetDescriptor[] events = info.getEventSetDescriptors(); for (int i = 0; i < events.length; ++i) { EventSetDescriptor event = events[i]; Class listenerType = event.getListenerType(); Object listenerObj = this; if (listenerType.isInstance(listenerObj)) { Method method = event.getAddListenerMethod(); method.invoke(source, new Object[] { listenerObj }); } } } } catch (Exception err) { PropertyValueControl.theLogger.error("An error occurred", err); } }
/** * @throws PropertyResolutionException */ private static void addPropertyChangeListener(Object object, PropertyChangeListener listener) { EventSetDescriptor ed = getEventSetDescriptor(object); Method addPCMethod = null; if (ed == null || (addPCMethod = ed.getAddListenerMethod()) == null) { log("addPropertyChangeListener()", "can't add listener"); return; } invokeMethod(addPCMethod, object, listener); }
public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) { try { // check that the bean is listenable, otherwise, can't use // the validator on it BeanInfo infos = Introspector.getBeanInfo(beanClass); EventSetDescriptor[] events = infos.getEventSetDescriptors(); for (EventSetDescriptor event : events) { if ("propertyChange".equals(event.getName())) { if (event.getAddListenerMethod() == null) { // no property event listener, so can not use the validator throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass); } if (event.getRemoveListenerMethod() == null) { // no property event listener, so can not use the validator throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass); } return event; } } // no property event listener, so can not use the validator throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass); } catch (IntrospectionException ex) { throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex); } } }
/** * @throws PropertyResolutionException */ private static void addPropertyChangeListener(Object object, PropertyChangeListener listener) { EventSetDescriptor ed = getEventSetDescriptor(object); Method addPCMethod = null; if (ed == null || (addPCMethod = ed.getAddListenerMethod()) == null) { log("addPropertyChangeListener()", "can't add listener"); return; } invokeMethod(addPCMethod, object, listener); }
public BeanActionBinding(Component component, String actionExpression) { super(actionExpression); this.view = component; boolean foundActionEvents = false; try { BeanInfo info = Introspector.getBeanInfo(component.getClass()); EventSetDescriptor[] events = info.getEventSetDescriptors(); if (events != null && events.length > 0) { for (EventSetDescriptor event : events) { if (ActionListener.class .isAssignableFrom(event.getListenerType())) { event.getAddListenerMethod().invoke(component, new ActionListener() { public void actionPerformed(ActionEvent e) { fireAction(); } }); foundActionEvents = true; break; } } } } catch (Exception e) { throw new CayenneRuntimeException("Error binding to component", e); } if (!foundActionEvents) { throw new CayenneRuntimeException("Component does not define action events: %s", component); } }
public static void addListener(Object bean, EventSetDescriptor eventSetDescriptor, EventListener listener) { Method method = eventSetDescriptor.getAddListenerMethod(); try { method.invoke(bean, listener); } catch (IllegalAccessException exception) { throw new BeanException("Cannot add event set listener: " + eventSetDescriptor.getName(), exception); } catch (InvocationTargetException exception) { throw new BeanException("Cannot add event set listener: " + eventSetDescriptor.getName(), exception); } }
getBeanEventDescriptor(bean).getAddListenerMethod().invoke(bean, l); } catch (Exception eee) { log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
Method[] listenerMethods = descriptor.getListenerMethods(); for (Method listenerMethod : listenerMethods) { final MetaMethod metaMethod = CachedMethod.find(descriptor.getAddListenerMethod()); addToAllMethodsIfPublic(metaMethod); String name = listenerMethod.getName();
for (int j = 0; j < listenerMethods.length; j++) { Method listenerMethod = listenerMethods[j]; final MetaMethod metaMethod = CachedMethod.find(descriptor.getAddListenerMethod()); addToAllMethodsIfPublic(metaMethod); String name = listenerMethod.getName();
/** try to register PropertyChangeListener to instance to fire its changes.*/ private void initPList () { try { InstanceCookie ic = ic(); if (ic == null) return; BeanInfo info = Utilities.getBeanInfo(ic.instanceClass()); java.beans.EventSetDescriptor[] descs = info.getEventSetDescriptors(); Method setter = null; for (int i = 0; descs != null && i < descs.length; i++) { setter = descs[i].getAddListenerMethod(); if (setter != null && setter.getName().equals("addPropertyChangeListener")) { // NOI18N Object bean = ic.instanceCreate(); propertyChangeListener = new PropL(); setter.invoke(bean, new Object[] {org.openide.util.WeakListeners.propertyChange(propertyChangeListener, bean)}); } } } catch (Exception ex) { } catch (LinkageError ex) { // #30650 - catch also LinkageError. // Ignoring exception the same way as the Exception handler above. } }
public static boolean equals(EventSetDescriptor descriptor1, EventSetDescriptor descriptor2) { if (descriptor1 == descriptor2) { return true; } // TODO: check all properties return nullEquals(descriptor1.getAddListenerMethod(), descriptor2.getAddListenerMethod()) && nullEquals(descriptor1.getRemoveListenerMethod(), descriptor2.getRemoveListenerMethod()) && nullEquals(descriptor1.getGetListenerMethod(), descriptor2.getGetListenerMethod()) && Arrays.equals(descriptor1.getListenerMethods(), descriptor2.getListenerMethods()) && descriptor1.isUnicast() == descriptor2.isUnicast(); }
if (descriptor.getAddListenerMethod() != null) { stmt = method.addEventSetStatement(bean.getName(), descriptor.getAddListenerMethod().getName(), adapterClassName); adapterClass = stmt.getAdapterClass(); if (atype == null) {
public static EventSetDescriptor getDescriptor(BeanInfo beanInfo, String eventSetName, String listenerMethodName) { checkNotNull(beanInfo, "beanInfo"); checkNotNull(eventSetName, "eventSetName"); checkNotNull(listenerMethodName, "listenerMethodName"); EventSetDescriptor descriptor = getDescriptor(beanInfo, eventSetName); MethodDescriptor listenerMethodDescriptor = BeanUtils.getListenerMethodDescriptor(descriptor, listenerMethodName); Method[] listenerMethods = new Method[] {listenerMethodDescriptor.getMethod()}; try { return new EventSetDescriptor(descriptor.getName(), descriptor.getListenerType(), listenerMethods, descriptor.getAddListenerMethod(), descriptor.getRemoveListenerMethod(), descriptor.getGetListenerMethod()); } catch (IntrospectionException exception) { throw new BeanException("Cannot construct event set descriptor", exception); } }
eventSet.getAddListenerMethod(), eventSet.getRemoveListenerMethod(), eventSet.getGetListenerMethod());