Checks that given listener method has an argument of the valid type.

@param eventSetName
event set name
@param listenerMethod
listener method
@throws IntrospectionException
if check fails
977040
private static void checkEventType(String eventSetName,
            Method listenerMethod) throws IntrospectionException {
        Class<?>[] params = listenerMethod.getParameterTypes();
        String firstParamTypeName = null;
        String eventTypeName = prepareEventTypeName(eventSetName);

        if (params.length > 0) {
            firstParamTypeName = extractShortClassName(params[0]
                    .getName());
        }

        if (firstParamTypeName == null
                || !firstParamTypeName.equals(eventTypeName)) {
            throw new IntrospectionException("Listener method " +
                    listenerMethod.getName() + " should have parameter of type " + eventTypeName);
        }
    }
582990
@SuppressWarnings("unchecked")
    private PropertyDescriptor[] introspectProperties(Class<?> stopClass)
            throws IntrospectionException {

        // Get descriptors for the public methods
        MethodDescriptor[] methodDescriptors = introspectMethods();

        if (methodDescriptors == null) {
            return null;
        }

        ArrayList<MethodDescriptor> methodList = new ArrayList<MethodDescriptor>();
        // Loop over the methods found, looking for public non-static methods
        for (int index = 0; index < methodDescriptors.length; index++) {
            int modifiers = methodDescriptors[index].getMethod().getModifiers();
            if (!Modifier.isStatic(modifiers)) {
                methodList.add(methodDescriptors[index]);
            }
        }

        // Get the list of public non-static methods into an array
        int methodCount = methodList.size();
        MethodDescriptor[] theMethods = null;
        if (methodCount > 0) {
            theMethods = new MethodDescriptor[methodCount];
            theMethods = methodList.toArray(theMethods);
        }

        if (theMethods == null) {
            return null;
        }

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

        // Search for methods that either get or set a Property
        for (int i = 0; i < theMethods.length; i++) {
            introspectGet(theMethods[i].getMethod(), propertyTable);
            introspectSet(theMethods[i].getMethod(), propertyTable);
        }

        // fix possible getter & setter collisions
        fixGetSet(propertyTable);

        // If there are listener methods, should be bound.
        MethodDescriptor[] allMethods = introspectMethods(true);
        if (stopClass != null) {
            MethodDescriptor[] excludeMethods = introspectMethods(true,
                    stopClass);
            if (excludeMethods != null) {
                ArrayList<MethodDescriptor> tempMethods = new ArrayList<MethodDescriptor>();
                for (MethodDescriptor method : allMethods) {
                    if (!isInSuper(method, excludeMethods)) {
                        tempMethods.add(method);
                    }
                }
                allMethods = tempMethods
                        .toArray(new MethodDescriptor[0]);
            }
        }
        for (int i = 0; i < allMethods.length; i++) {
            introspectPropertyListener(allMethods[i].getMethod());
        }
        // Put the properties found into the PropertyDescriptor array
        ArrayList<PropertyDescriptor> propertyList = new ArrayList<PropertyDescriptor>();

        for (Map.Entry<String, HashMap> entry : propertyTable.entrySet()) {
            String propertyName = entry.getKey();
            HashMap table = entry.getValue();
            if (table == null) {
                continue;
            }
            String normalTag = (String) table.get(STR_NORMAL);
            String indexedTag = (String) table.get(STR_INDEXED);

            if ((normalTag == null) && (indexedTag == null)) {
                continue;
            }

            Method get = (Method) table.get(STR_NORMAL + PREFIX_GET);
            Method set = (Method) table.get(STR_NORMAL + PREFIX_SET);
            Method indexedGet = (Method) table.get(STR_INDEXED + PREFIX_GET);
            Method indexedSet = (Method) table.get(STR_INDEXED + PREFIX_SET);

            PropertyDescriptor propertyDesc = null;
            if (indexedTag == null) {
                propertyDesc = new PropertyDescriptor(propertyName, get, set);
            } else {
                try {
                    propertyDesc = new IndexedPropertyDescriptor(propertyName,
                            get, set, indexedGet, indexedSet);
                } catch (IntrospectionException e) {
                    // If the getter and the indexGetter is not compatible, try
                    // getter/setter is null;
                    propertyDesc = new IndexedPropertyDescriptor(propertyName,
                            null, null, indexedGet, indexedSet);
                }
            }
            // RI set propretyDescriptor as bound. FIXME
            // propertyDesc.setBound(true);
            if (canAddPropertyChangeListener && canRemovePropertyChangeListener) {
                propertyDesc.setBound(true);
            } else {
                propertyDesc.setBound(false);
            }
            if (table.get(STR_IS_CONSTRAINED) == Boolean.TRUE) { //$NON-NLS-1$
                propertyDesc.setConstrained(true);
            }
            propertyList.add(propertyDesc);
        }

        PropertyDescriptor[] theProperties = new PropertyDescriptor[propertyList
                .size()];
        propertyList.toArray(theProperties);
        return theProperties;
    }
374205
function applyEventListener(inst, node, nodeInfo) {
  if (nodeInfo.events && nodeInfo.events.length) {
    for (let j=0, e$=nodeInfo.events, e; (j<e$.length) && (e=e$[j]); j++) {
      inst._addMethodEventListenerToNode(node, e.name, e.value, inst);
    }
  }
}
941298
public Object invokeMethod(String name, Object args) {
        final Object[] argsArr = args instanceof Object[] ? (Object[]) args : new Object[]{args};
        MetaMethod metaMethod = myMetaClass.getMetaMethod(name, argsArr);
        if (metaMethod != null) {
            // we have to use doMethodInvoke here instead of simply invoke,
            // because getMetaMethod may provide a method that can not be called
            // without further argument transformation, which is done only in 
            // doMethodInvoke
            return metaMethod.doMethodInvoke(this, argsArr);
        }

        if (argsArr.length == 2 && argsArr[0] instanceof Class && argsArr[1] instanceof Closure) {
            if (argsArr[0] == theClass)
                registerInstanceMethod(name, (Closure) argsArr[1]);
            else {
                registerSubclassInstanceMethod(name, (Class) argsArr[0], (Closure) argsArr[1]);
            }
            return null;
        }

        if (argsArr.length == 1 && argsArr[0] instanceof Closure) {
            registerInstanceMethod(name, (Closure) argsArr[0]);
            return null;
        }

        throw new MissingMethodException(name, getClass(), argsArr);
    }
880251
@Override
    public Object invokeMethod(String name, Object arg) {
        Object[] args = (Object[])arg;

        if (CREATE_APPCTX.equals(name)) {
            return createApplicationContext();
        }

        if (REGISTER_BEANS.equals(name) && args.length == 1 && args[0] instanceof GenericApplicationContext) {
            registerBeans((GenericApplicationContext)args[0]);
            return null;
        }

        if (BEANS.equals(name) && args.length == 1 && args[0] instanceof Closure) {
            return beans((Closure<?>)args[0]);
        }

        if (REF.equals(name)) {
            String refName;
            Assert.notNull(args[0], "Argument to ref() is not a valid bean or was not found");

            if (args[0] instanceof RuntimeBeanReference) {
                refName = ((RuntimeBeanReference)args[0]).getBeanName();
            }
            else {
                refName = args[0].toString();
            }

            boolean parentRef = false;
            if (args.length > 1) {
                if (args[1] instanceof Boolean) {
                    parentRef = (Boolean) args[1];
                }
            }
            return new RuntimeBeanReference(refName, parentRef);
        }

        if (namespaceHandlers.containsKey(name) && args.length > 0 && (args[0] instanceof Closure)) {
            createDynamicElementReader(name, true).invokeMethod("doCall", args);
            return this;
        }

        if (args.length > 0 && args[0] instanceof Closure) {
            // abstract bean definition
            return invokeBeanDefiningMethod(name, args);
        }

        if (args.length > 0 && args[0] instanceof Class || args.length > 0 && args[0] instanceof RuntimeBeanReference || args.length > 0 && args[0] instanceof Map) {
            return invokeBeanDefiningMethod(name, args);
        }

        if (args.length > 1 && args[args.length - 1] instanceof Closure) {
            return invokeBeanDefiningMethod(name, args);
        }

        ApplicationContext ctx = springConfig.getUnrefreshedApplicationContext();
        MetaClass mc = DefaultGroovyMethods.getMetaClass(ctx);
        if (!mc.respondsTo(ctx, name, args).isEmpty()) {
            return mc.invokeMethod(ctx,name, args);
        }

        return this;
    }
588753
@Override
    public boolean validateEventsAndOutcomes(String handlerName, List<Map<String, Object>> configuredEvents) {

        if (configuredEvents.isEmpty()) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "configuredEvents is empty, returning true as all events are valid");
            }
            return true;
        }
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "configuredEvents: " + configuredEvents.toString());
        }
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "size of configuredEvents: " + configuredEvents.size());
        }

        for (Map<String, Object> events : configuredEvents) {

            if (events.isEmpty()) {
                if (tc.isDebugEnabled()) {
                    Tr.debug(tc, "no events or outcomes specified, all events and outcomes are honoured");
                }
                return true;
            } else {
                boolean isFoundEventName = false;
                String foundEventName = null;
                boolean isFoundOutcome = false;
                String foundOutcome = null;
                for (Entry<String, Object> entry : events.entrySet()) {
                    if (tc.isDebugEnabled()) {
                        Tr.debug(tc, "entry: " + entry.toString());
                    }

                    // if the event is a custom one, we cannot validate, so return true:  buyer beware
                    if (entry.getKey().equals(AuditConstants.CUSTOM) && entry.getValue().equals(Boolean.TRUE)) {
                        return true;
                    } else {
                        if (entry.getKey().equals(AuditConstants.EVENT_NAME)) {
                            isFoundEventName = true;
                            foundEventName = (String) entry.getValue();
                            if (!validateEventName((String) entry.getValue())) {
                                String eventsList = "";
                                for (String temp : AuditConstants.validEventNamesList) {
                                    eventsList = eventsList.concat(temp).concat(" ");
                                }
                                Tr.error(tc, INCORRECT_AUDIT_EVENT_CONFIGURATION, new Object[] { foundEventName, handlerName, eventsList });
                                return false;
                            }
                        } else if (entry.getKey().equals(AuditConstants.OUTCOME)) {
                            isFoundOutcome = true;
                            foundOutcome = (String) entry.getValue();
                            if (!validateOutcomeName((String) entry.getValue())) {
                                String outcomesList = "";
                                for (String temp : AuditConstants.validOutcomesList) {
                                    outcomesList = outcomesList.concat(temp).concat(" ");
                                }
                                Tr.error(tc, INCORRECT_AUDIT_OUTCOME_CONFIGURATION, new Object[] { foundOutcome, handlerName, outcomesList });
                                return false;
                            }
                        }
                    }
                }
                if (!isFoundEventName && isFoundOutcome) {
                    String eventsList = "";
                    for (String temp : AuditConstants.validEventNamesList) {
                        eventsList = eventsList.concat(temp).concat(" ");
                    }
                    Tr.error(tc, "INCORRECT_AUDIT_CONFIGURATION_OUTCOME_SPECIFIED_MISSING_EVENTNAME",
                             new Object[] { foundOutcome, handlerName, eventsList });
                    return false;
                }
            }
        }
        return true;
    }
347520
private Method findAddRemoveListenerMethod(Class<?> sourceClass, String methodName) throws IntrospectionException
	{
		try
		{
			return sourceClass.getMethod(methodName, listenerType);
		}
		catch (NoSuchMethodException e)
		{
			return findAddRemoveListnerMethodWithLessCheck(sourceClass, methodName);
		}
		catch (Exception e)
		{
			throw new IntrospectionException(Messages.getString("beans.31", //$NON-NLS-1$
					methodName, listenerType.getName()));
		}
	}
1156891
function on(eventName, callback) {
  	if (objectType(eventName) !== "string") {
  		throw new TypeError("eventName must be a string when registering a listener");
  	} else if (!inArray(eventName, SUPPORTED_EVENTS)) {
  		var events = SUPPORTED_EVENTS.join(", ");
  		throw new Error("\"" + eventName + "\" is not a valid event; must be one of: " + events + ".");
  	} else if (objectType(callback) !== "function") {
  		throw new TypeError("callback must be a function when registering a listener");
  	}

  	if (!LISTENERS[eventName]) {
  		LISTENERS[eventName] = [];
  	}

  	// Don't register the same callback more than once
  	if (!inArray(callback, LISTENERS[eventName])) {
  		LISTENERS[eventName].push(callback);
  	}
  }
223918
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
  public boolean isCompatible(@NonNull EventType eventType) {
    switch (eventType) {
      case CREATED:
        return (listener instanceof CacheEntryCreatedListener<?, ?>);
      case UPDATED:
        return (listener instanceof CacheEntryUpdatedListener<?, ?>);
      case REMOVED:
        return (listener instanceof CacheEntryRemovedListener<?, ?>);
      case EXPIRED:
        return (listener instanceof CacheEntryExpiredListener<?, ?>);
    }
    throw new IllegalStateException("Unknown event type: " + eventType);
  }
215249
private void validateExternalCallback(Method method, CallbackType callbackType) {
    Class<?>[] parameters = method.getParameterTypes();
    if (!parameters[0].isAssignableFrom(entityClass)) {
      String message = String.format("Method %s in class %s is not valid for entity %s",
          method.getName(), method.getDeclaringClass().getName(), entityClass.getName());
      throw new EntityManagerException(message);
    }
    CallbackMetadata callbackMetadata = new CallbackMetadata(EntityListenerType.EXTERNAL,
        callbackType, method);
    metadata.put(callbackType, callbackMetadata);
  }
929479
function warnEventListenMethod(eventBind, owner) {
    var valid = true;
    var method = owner;
    each(eventBind.expr.name.paths, function (path) {
        method = method[path.value];
        valid = !!method;
        return valid;
    });

    if (!valid) {
        var paths = [];
        each(eventBind.expr.name.paths, function (path) {
            paths.push(path.value);
        });

        warn(eventBind.name + ' listen fail,"' + paths.join('.') + '" not exist');
    }
}
451180
public static void validateArgument(Method method, Class<? extends Annotation> annotationType,
                                        Class<?> expectedParameterType) {
        if (method.getParameterTypes().length != 1 || !method.getParameterTypes()[0].equals(expectedParameterType)) {
            throw new BeanCreationException(String.format(
                  "Method %s with @%s MUST take a single argument of type %s",
                  method,
                  annotationType.getName(),
                  expectedParameterType.getName()
            ));
        }
    }
1313052
public static void forEachMethods(TypeElement typeElement, MethodFoundListener listener) {
		Elements elementUtils = BaseProcessor.elementUtils;
		List<? extends Element> list = elementUtils.getAllMembers(typeElement);

		for (Element item : list) {
			if (item.getKind() == ElementKind.METHOD) {
				listener.onMethod((ExecutableElement) item);
			}
		}
	}
849580
public void executeEntityListeners(CallbackType callbackType, Object entity) {
    // We may get null entities here. For example loading a nonexistent ID
    // or IDs.
    if (entity == null) {
      return;
    }
    EntityListenersMetadata entityListenersMetadata = EntityIntrospector
        .getEntityListenersMetadata(entity);
    List<CallbackMetadata> callbacks = entityListenersMetadata.getCallbacks(callbackType);
    if (!entityListenersMetadata.isExcludeDefaultListeners()) {
      executeGlobalListeners(callbackType, entity);
    }
    if (callbacks == null) {
      return;
    }
    for (CallbackMetadata callback : callbacks) {
      switch (callback.getListenerType()) {
        case EXTERNAL:
          Object listener = ListenerFactory.getInstance().getListener(callback.getListenerClass());
          invokeCallbackMethod(callback.getCallbackMethod(), listener, entity);
          break;
        case INTERNAL:
          invokeCallbackMethod(callback.getCallbackMethod(), entity);
          break;
        default:
          String message = String.format("Unknown or unimplemented callback listener type: %s",
              callback.getListenerType());
          throw new EntityManagerException(message);
      }
    }
  }
345918
function(event_name, event_args) {

		if (Lava.schema.DEBUG && typeof(event_name) == "undefined") Lava.t();

		if (this._listeners[event_name] != null) {

			this._callListeners(this._listeners[event_name], event_args);

		}

	}
437822
@Beta
    public static boolean containsMappingFor(final String eventType) {
        if (eventType == null || eventType.isEmpty()) {
            return false;
        } else {
            return systemEventMappings.containsKey(canonicalizeEventType(eventType));
        }
    }
907783
public void addEventListener(EventListener listener)
    throws IllegalArgumentException
    {
        
        if (listener instanceof HttpSessionAttributeListener)
            _sessionAttributeListeners.add(listener);
        if (listener instanceof HttpSessionListener)
            _sessionListeners.add(listener);
    }