propertyChangeListener = new PropL(); method.invoke(o, new Object[] { WeakListeners.propertyChange(propertyChangeListener, o) }); removePCLMethod = eventSetDescriptors[i].getRemoveListenerMethod(); } catch (Exception e) {
/** * Stop listening to the source object */ private void stopListeningToSource() { try { if (source != null) { BeanInfo info = getBeanInfo(source.getClass(), source); EventSetDescriptor[] events = info.getEventSetDescriptors(); Object listenerObj = this; for (int i = 0; i < events.length; ++i) { EventSetDescriptor event = events[i]; Class listenerType = event.getListenerType(); if (listenerType.isInstance(listenerObj)) { Method method = event.getRemoveListenerMethod(); method.invoke(source, new Object[] { this }); } } } } catch (Exception err) { PropertyValueControl.theLogger.error("An error occurred", err); } }
if (descriptor.getRemoveListenerMethod() != null) builder.append(",").append("removeMethod=").append(descriptor.getRemoveListenerMethod().getName());
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 removePropertyChangeListener(Object object, PropertyChangeListener listener) { EventSetDescriptor ed = getEventSetDescriptor(object); Method removePCMethod = null; if (ed == null || (removePCMethod = ed.getRemoveListenerMethod()) == null) { log("removePropertyChangeListener()", "can't remove listener from source"); return; } invokeMethod(removePCMethod, object, listener); }
/** * @throws PropertyResolutionException */ private static void removePropertyChangeListener(Object object, PropertyChangeListener listener) { EventSetDescriptor ed = getEventSetDescriptor(object); Method removePCMethod = null; if (ed == null || (removePCMethod = ed.getRemoveListenerMethod()) == null) { log("removePropertyChangeListener()", "can't remove listener from source"); return; } invokeMethod(removePCMethod, object, listener); }
getBeanEventDescriptor(oldBean).getRemoveListenerMethod().invoke(oldBean, l); } catch (Exception eee) { log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
public static void removeListener(Object bean, EventSetDescriptor eventSetDescriptor, EventListener listener) { Method method = eventSetDescriptor.getRemoveListenerMethod(); try { method.invoke(bean, new Object[] {listener}); } catch (IllegalAccessException exception) { throw new BeanException("Cannot remove event set listener: " + eventSetDescriptor.getName(), exception); } catch (InvocationTargetException exception) { throw new BeanException("Cannot remove event set listener: " + eventSetDescriptor.getName(), exception); } }
Method deregisterMethod = tempEsd.getRemoveListenerMethod(); Object targetBean = tempTarget.getBean(); Object[] args = new Object[1];
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(); }
Method deregisterMethod = tempEsd.getRemoveListenerMethod(); Object targetBean = tempTarget.getBean(); Object[] args = new Object[1];
/** * Remove this connection */ public void remove(Integer... tab) { int tabIndex = 0; if (tab.length > 0) { tabIndex = tab[0].intValue(); } Vector<BeanConnection> connections = TABBED_CONNECTIONS.get(tabIndex); EventSetDescriptor tempEsd = getSourceEventSetDescriptor(); // try to deregister the target as a listener for the source try { Method deregisterMethod = tempEsd.getRemoveListenerMethod(); Object targetBean = getTarget().getBean(); Object[] args = new Object[1]; args[0] = targetBean; deregisterMethod.invoke(getSource().getBean(), args); // System.err.println("Deregistering listener"); } catch (Exception ex) { ex.printStackTrace(); } if (getTarget().getBean() instanceof BeanCommon) { // tell the target that this connection is going away ((BeanCommon) getTarget().getBean()).disconnectionNotification( tempEsd.getName(), getSource().getBean()); } connections.remove(this); }
/** * Remove this connection */ public void remove(Integer... tab) { int tabIndex = 0; if (tab.length > 0) { tabIndex = tab[0].intValue(); } Vector<BeanConnection> connections = TABBED_CONNECTIONS.get(tabIndex); EventSetDescriptor tempEsd = getSourceEventSetDescriptor(); // try to deregister the target as a listener for the source try { Method deregisterMethod = tempEsd.getRemoveListenerMethod(); Object targetBean = getTarget().getBean(); Object[] args = new Object[1]; args[0] = targetBean; deregisterMethod.invoke(getSource().getBean(), args); // System.err.println("Deregistering listener"); } catch (Exception ex) { ex.printStackTrace(); } if (getTarget().getBean() instanceof BeanCommon) { // tell the target that this connection is going away ((BeanCommon) getTarget().getBean()).disconnectionNotification( tempEsd.getName(), getSource().getBean()); } connections.remove(this); }
propertyChangeListener = new PropL (); method.invoke (o, new Object[] { WeakListeners.propertyChange (propertyChangeListener, o) }); removePCLMethod = eventSetDescriptors [i].getRemoveListenerMethod (); } catch (Exception e) {
propertyChangeListener = new PropL (); method.invoke (o, new Object[] { WeakListeners.propertyChange (propertyChangeListener, o) }); removePCLMethod = eventSetDescriptors [i].getRemoveListenerMethod (); } catch (Exception e) {
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());