protected Method getMethod()

in src/java/org/apache/turbine/modules/ActionEvent.java [135:183]


	protected Method getMethod(String name, Class<?>[] signature, ParameterParser pp) throws NoSuchMethodException
	{
	    String cacheKey =
				Arrays.stream(signature)
						.map(clazz -> ':' + clazz.getCanonicalName())
						.collect(Collectors.joining("", name, ""));

		Method method = this.methodCache.get(cacheKey);

	    if (method == null)
	    {
	        // Try annotations of public methods
	        Method[] methods = getClass().getMethods();

        methodLoop:
	        for (Method m : methods)
	        {
	            Annotation[] annotations = AnnotationProcessor.getAnnotations(m);
	            for (Annotation a : annotations)
	            {
    	            if (a instanceof TurbineActionEvent)
    	            {
    	                TurbineActionEvent tae = (TurbineActionEvent) a;
    	                if (name.equals(pp.convert(tae.value()))
                            && Arrays.equals(signature, m.getParameterTypes()))
    	                {
    	                    method = m;
    	                    break methodLoop;
    	                }
    	            }
	            }
	        }

	        // Try legacy mode
	        if (method == null)
	        {
                String tmp = name.toLowerCase().substring(METHOD_NAME_LENGTH);
	            method = getClass().getMethod(METHOD_NAME_PREFIX + StringUtils.capitalize(tmp), signature);
	        }

	        Method oldMethod = this.methodCache.putIfAbsent(cacheKey, method);
	        if (oldMethod != null)
	        {
	            method = oldMethod;
	        }
	    }

	    return method;
	}