Introspects the given listener class and finds all methods that should receive callback event
notifications.

@param listenerClass
the listener class
960789
private void processExternalListener(Class<?> listenerClass) {
    ExternalListenerMetadata listenerMetadata = ExternalListenerIntrospector
        .introspect(listenerClass);
    Map<CallbackType, Method> callbacks = listenerMetadata.getCallbacks();
    if (callbacks != null) {
      for (Map.Entry<CallbackType, Method> entry : callbacks.entrySet()) {
        validateExternalCallback(entry.getValue(), entry.getKey());
      }
    }
  }
1120744
public Object getListener(Class<?> listenerClass) {
    Object listener = listeners.get(listenerClass);
    if (listener == null) {
      listener = loadListener(listenerClass);
    }
    return listener;
  }
567190
@SuppressWarnings("unchecked")
    private EventSetDescriptor[] introspectEvents() throws IntrospectionException {
        // Get descriptors for the public methods
        // FIXME: performance
        MethodDescriptor[] theMethods = introspectMethods();

        if (theMethods == null)
            return null;

        HashMap<String, HashMap> eventTable = new HashMap<String, HashMap>(
                theMethods.length);

        // Search for methods that add an Event Listener
        for (int i = 0; i < theMethods.length; i++) {
            introspectListenerMethods(PREFIX_ADD, theMethods[i].getMethod(),
                    eventTable);
            introspectListenerMethods(PREFIX_REMOVE, theMethods[i].getMethod(),
                    eventTable);
            introspectGetListenerMethods(theMethods[i].getMethod(), eventTable);
        }

        ArrayList<EventSetDescriptor> eventList = new ArrayList<EventSetDescriptor>();
        for (Map.Entry<String, HashMap> entry : eventTable.entrySet()) {
            HashMap table = entry.getValue();
            Method add = (Method) table.get(PREFIX_ADD);
            Method remove = (Method) table.get(PREFIX_REMOVE);

            if ((add == null) || (remove == null)) {
                continue;
            }

            Method get = (Method) table.get(PREFIX_GET);
            Class<?> listenerType = (Class) table.get("listenerType"); //$NON-NLS-1$
            Method[] listenerMethods = (Method[]) table.get("listenerMethods"); //$NON-NLS-1$
            EventSetDescriptor eventSetDescriptor = new EventSetDescriptor(
                    decapitalize(entry.getKey()), listenerType, listenerMethods, add,
                    remove, get);

            eventSetDescriptor.setUnicast(table.get("isUnicast") != null); //$NON-NLS-1$
            eventList.add(eventSetDescriptor);
        }

        EventSetDescriptor[] theEvents = new EventSetDescriptor[eventList
                .size()];
        eventList.toArray(theEvents);

        return theEvents;
    }
944425
public final void addLayerListener(MapLayerListener listener) {
		if (this.listeners == null) {
			this.listeners = new ListenerCollection<>();
		}
		this.listeners.add(MapLayerListener.class, listener);
	}
1285062
private List<Class<?>> getAllExternalListeners() {
    Class<?> clazz = entityClass;
    List<Class<?>> allListeners = new ArrayList<>();
    boolean stop = false;
    while (!stop) {
      EntityListeners entityListenersAnnotation = clazz.getAnnotation(EntityListeners.class);
      if (entityListenersAnnotation != null) {
        Class<?>[] listeners = entityListenersAnnotation.value();
        if (listeners.length > 0) {
          allListeners.addAll(0, Arrays.asList(listeners));
        }
      }
      boolean excludeDefaultListeners = clazz.isAnnotationPresent(ExcludeDefaultListeners.class);
      boolean excludeSuperClassListeners = clazz
          .isAnnotationPresent(ExcludeSuperclassListeners.class);
      if (excludeDefaultListeners) {
        metadata.setExcludeDefaultListeners(true);
      }
      if (excludeSuperClassListeners) {
        metadata.setExcludeSuperClassListeners(true);
      }
      clazz = clazz.getSuperclass();
      stop = excludeSuperClassListeners || clazz == null
          || !clazz.isAnnotationPresent(MappedSuperClass.class);
    }
    return allListeners;
  }
1254342
@SuppressWarnings("rawtypes")
  public B camundaTaskListenerClass(String eventName, Class listenerClass) {
    return camundaTaskListenerClass(eventName, listenerClass.getName());
  }
799465
@Override
    final public void addConnectionEventListener(
                                                 final ConnectionEventListener listener) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "addConnectionEventListener", listener);
        }

        synchronized (_connectionListeners) {
            _connectionListeners.add(listener);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "addConnectionEventListener");
        }

    }
736833
public static InternalListenerMetadata introspect(Class<?> listenerClass) {
    InternalListenerMetadata cachedMetadata = cache.get(listenerClass);
    if (cachedMetadata != null) {
      return cachedMetadata;
    }
    synchronized (listenerClass) {
      cachedMetadata = cache.get(listenerClass);
      if (cachedMetadata != null) {
        return cachedMetadata;
      }
      InternalListenerIntrospector introspector = new InternalListenerIntrospector(listenerClass);
      introspector.introspect();
      cache.put(listenerClass, introspector.metadata);
      return introspector.metadata;
    }
  }
622534
private static void invokeCallbackMethod(Method callbackMethod, Object listener, Object entity) {
    try {
      callbackMethod.invoke(listener, entity);
    } catch (Exception exp) {
      String message = String.format("Failed to execute callback method %s of class %s",
          callbackMethod.getName(), callbackMethod.getDeclaringClass().getName());
      throw new EntityManagerException(message, exp);
    }

  }
902753
@SuppressWarnings("unchecked")
	public <T extends EventListener> T[] getListeners(Class<T> type) {
		final Object[] iListeners = this.listeners;
		final int listenerCount = getListenerCount(iListeners, type);
		final T[] result = (T[]) Array.newInstance(type, listenerCount);
		int j = 0;
		for (int i = iListeners.length - 2; i >= 0; i -= 2) {
			if (iListeners[i] == type) {
				result[j++] = type.cast(iListeners[i + 1]);
			}
		}
		return result;
	}
680421
public <T extends ObjectAttachableListener> void removeObjectListener(
            Class<?> objectClass, long objectId, Class<T> listenerClass, T listener) {
        synchronized (objectListeners) {
            if (objectClass == null) {
                return;
            }
            Map<Long, Map<Class<? extends ObjectAttachableListener>, Map<ObjectAttachableListener,
                    ListenerManagerImpl<? extends ObjectAttachableListener>>>> objectListener =
                    objectListeners.get(objectClass);
            if (objectListener == null) {
                return;
            }
            Map<Class<? extends ObjectAttachableListener>, Map<ObjectAttachableListener,
                    ListenerManagerImpl<? extends ObjectAttachableListener>>> listeners = objectListener.get(objectId);
            if (listeners == null) {
                return;
            }
            Map<ObjectAttachableListener, ListenerManagerImpl<? extends ObjectAttachableListener>> classListeners =
                    listeners.get(listenerClass);
            if (classListeners == null) {
                return;
            }
            ListenerManagerImpl<? extends ObjectAttachableListener> listenerManager = classListeners.get(listener);
            if (listenerManager == null) {
                return;
            }
            classListeners.remove(listener);
            listenerManager.removed();
            // Clean it up
            if (classListeners.isEmpty()) {
                listeners.remove(listenerClass);
                if (listeners.isEmpty()) {
                    objectListener.remove(objectId);
                    if (objectListener.isEmpty()) {
                        objectListeners.remove(objectClass);
                    }
                }
            }
        }
    }
1326377
private <T extends Rdp4jListener> void notifyListeners(Class<T> listenerType, Notifier<T> notifier)
            throws InterruptedException {
        for (Rdp4jListener listener : listeners) {
            if (isInstanceOf(listener, listenerType)) {
                /*
                 * This cast is correct, since we check if listener
                 * is instance of listenerType.
                 */
                @SuppressWarnings("unchecked")
                T listener2 = (T) listener;
                try {
                    notifier.notify(listener2);
                } catch (InterruptedException e) {
                    throw e;
                } catch (Throwable e) {
                    logErrorMessage(e);
                }
            }
        }
    }
1091789
private void exploreClass(Class<?>  clazzToAdd) throws IntrospectionException{
		List<InnerPropertyDescriptor> classList=getProperties(clazzToAdd);
	
		for (InnerPropertyDescriptor descriptor:classList){
			map.put(descriptor.getName(),descriptor);
		}
			
		this.list.addAll(classList);

		Class<?>  superClazz=clazzToAdd.getSuperclass();
		if (superClazz !=null){
			exploreClass(superClazz);
		}
	}
836544
function ListenerList (emitter, eventId) {
    this._count = 0; // count of "listeners"
    this._methods = null; // null, function, or array of functions
    this._objects = null; // null, context, or array of contexts

    if (debugLevel > 0) {
        this._emitter = emitter; // our parent EventEmitter
        this._eventId = eventId;
        this._counterMap = null; // key: listenerKey, value: count of listeners with same listenerKey
    }
}
866372
public void setListeners(java.util.Collection<Listener> listeners) {
        if (listeners == null) {
            this.listeners = null;
            return;
        }

        this.listeners = new java.util.ArrayList<Listener>(listeners);
    }
569708
private void introspectMethods(JavaClass jClass)
  {
    for (Method method : getMethods()) {
      Class<?> []paramTypes = method.getParameterTypes();
      int paramLen = paramTypes.length;

      if (! Modifier.isAbstract(method.getModifiers())) {
        continue;
      }
      
      if (Modifier.isStatic(method.getModifiers())) {
        continue;
      }
      
      if (Modifier.isFinal(method.getModifiers())) {
        continue;
      }
      
      /*
      if (! Modifier.isPublic(method.getModifiers())) {
        throw new IllegalArgumentException("Method must be public {0}", method);
      }
      */
      
      if (method.getDeclaringClass().equals(Object.class)) {
        continue;
      }
      
      if (method.getName().equals("toString")
          && paramLen == 0) {
        continue;
      }
      
      if (method.getName().equals("hashCode")
          && paramLen == 0) {
        continue;
      }
      
      if (method.getName().equals("equals")
          && paramLen == 1 && paramTypes[0].equals(Object.class)) {
        continue;
      }
      
      // XXX: Need QA
      
      
      int ampResult = findAmpResult(paramTypes, Result.class);

      if (isCreate(method) || isFind(method)) {
        if (ampResult < 0) {
          throw new IllegalStateException(L.l("Result argument is required {0}",
                                              method));
        }
      
        if (! void.class.equals(method.getReturnType())) {
          throw new IllegalArgumentException(L.l("method must return void {0}",
                                                 method));
        }
      }
      
      if (paramLen > 0 
          && ampResult >= 0) {
        /*
        if (ampResult != paramTypes.length - 1) {
          throw new IllegalStateException(L.l("invalid Result position. Result must be the final argument."));
        }
        */
        
        createAmpResultMethod(jClass, method, ampResult);
      }
      else if (ampResult < 0) {
        createAmpSendMethod(jClass, method);
      }
      else {
        throw new IllegalStateException(method.toString());
      }
    }
  }
437653
@Override
    public List<String> introspect() {
        List<String> rc = super.introspect();
        String prefix = getClass().getSimpleName() + "@" + hashCode() + ": ";
        rc.add(prefix + "callback=" + callback);
        return rc;
    }