Example usage for org.springframework.util ClassUtils getQualifiedMethodName

List of usage examples for org.springframework.util ClassUtils getQualifiedMethodName

Introduction

In this page you can find the example usage for org.springframework.util ClassUtils getQualifiedMethodName.

Prototype

public static String getQualifiedMethodName(Method method) 

Source Link

Document

Return the qualified name of the given method, consisting of fully qualified interface/class name + "."

Usage

From source file:org.dspace.app.rest.utils.RestRepositoryUtils.java

private Object[] prepareParameters(Method method, MultiValueMap<String, ? extends Object> rawParameters,
        Pageable pageable, Sort sort) {

    List<MethodParameter> parameters = new MethodParameters(method, PARAM_ANNOTATION).getParameters();

    if (parameters.isEmpty()) {
        return new Object[0];
    }/*from www.j  av  a2 s .com*/

    Object[] result = new Object[parameters.size()];
    Sort sortToUse = pageable == null ? sort : pageable.getSort();

    for (int i = 0; i < result.length; i++) {

        MethodParameter param = parameters.get(i);
        Class<?> targetType = param.getParameterType();

        if (Pageable.class.isAssignableFrom(targetType)) {
            result[i] = pageable;
        } else if (Sort.class.isAssignableFrom(targetType)) {
            result[i] = sortToUse;
        } else {

            String parameterName = param.getParameterName();

            if (StringUtils.isBlank(parameterName)) {
                throw new IllegalArgumentException(
                        String.format(NAME_NOT_FOUND, ClassUtils.getQualifiedMethodName(method)));
            }

            Object value = unwrapSingleElement(rawParameters.get(parameterName));

            result[i] = targetType.isInstance(value) ? value : convert(value, param);
        }
    }

    return result;
}

From source file:org.springframework.aop.interceptor.CustomizableTraceInterceptor.java

/**
 * Writes a log message before the invocation based on the value of {@code enterMessage}.
 * If the invocation succeeds, then a log message is written on exit based on the value
 * {@code exitMessage}. If an exception occurs during invocation, then a message is
 * written based on the value of {@code exceptionMessage}.
 * @see #setEnterMessage//w  ww.java2  s.  com
 * @see #setExitMessage
 * @see #setExceptionMessage
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
    String name = ClassUtils.getQualifiedMethodName(invocation.getMethod());
    StopWatch stopWatch = new StopWatch(name);
    Object returnValue = null;
    boolean exitThroughException = false;
    try {
        stopWatch.start(name);
        writeToLog(logger, replacePlaceholders(this.enterMessage, invocation, null, null, -1));
        returnValue = invocation.proceed();
        return returnValue;
    } catch (Throwable ex) {
        if (stopWatch.isRunning()) {
            stopWatch.stop();
        }
        exitThroughException = true;
        writeToLog(logger, replacePlaceholders(this.exceptionMessage, invocation, null, ex,
                stopWatch.getTotalTimeMillis()), ex);
        throw ex;
    } finally {
        if (!exitThroughException) {
            if (stopWatch.isRunning()) {
                stopWatch.stop();
            }
            writeToLog(logger, replacePlaceholders(this.exitMessage, invocation, returnValue, null,
                    stopWatch.getTotalTimeMillis()));
        }
    }
}

From source file:org.springframework.cache.interceptor.CacheAspectSupport.java

/**
 * Convenience method to return a String representation of this Method
 * for use in logging. Can be overridden in subclasses to provide a
 * different identifier for the given method.
 * @param method the method we're interested in
 * @param targetClass class the method is on
 * @return log message identifying this method
 * @see org.springframework.util.ClassUtils#getQualifiedMethodName
 *//*  ww w.  j  a  v a 2  s.c o m*/
protected String methodIdentification(Method method, Class<?> targetClass) {
    Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
    return ClassUtils.getQualifiedMethodName(specificMethod);
}

From source file:org.springframework.remoting.support.RemoteInvocationTraceInterceptor.java

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    Method method = invocation.getMethod();
    if (logger.isDebugEnabled()) {
        logger.debug("Incoming " + this.exporterNameClause + "remote call: "
                + ClassUtils.getQualifiedMethodName(method));
    }//from   w w w .  j  a  v  a  2 s. c  o  m
    try {
        Object retVal = invocation.proceed();
        if (logger.isDebugEnabled()) {
            logger.debug("Finished processing of " + this.exporterNameClause + "remote call: "
                    + ClassUtils.getQualifiedMethodName(method));
        }
        return retVal;
    } catch (Throwable ex) {
        if (ex instanceof RuntimeException || ex instanceof Error) {
            if (logger.isWarnEnabled()) {
                logger.warn(
                        "Processing of " + this.exporterNameClause + "remote call resulted in fatal exception: "
                                + ClassUtils.getQualifiedMethodName(method),
                        ex);
            }
        } else {
            if (logger.isInfoEnabled()) {
                logger.info("Processing of " + this.exporterNameClause + "remote call resulted in exception: "
                        + ClassUtils.getQualifiedMethodName(method), ex);
            }
        }
        throw ex;
    }
}

From source file:spring.test.RemoteInvocationTraceInterceptor.java

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    Method method = invocation.getMethod();

    if (logger.isDebugEnabled()) {
        logger.debug("Incoming " + this.exporterNameClause + "remote call: "
                + ClassUtils.getQualifiedMethodName(method));
    }//from ww w  .j  a va  2s . c o m

    try {
        Object retVal = invocation.proceed();

        if (logger.isDebugEnabled()) {
            logger.debug("Finished processing of " + this.exporterNameClause + "remote call: "
                    + ClassUtils.getQualifiedMethodName(method));
        }

        return retVal;
    } catch (Throwable ex) {
        if (ex instanceof RuntimeException || ex instanceof Error) {
            if (logger.isWarnEnabled()) {
                logger.warn(
                        "Processing of " + this.exporterNameClause + "remote call resulted in fatal exception: "
                                + ClassUtils.getQualifiedMethodName(method),
                        ex);
            }
        } else {
            if (logger.isInfoEnabled()) {
                logger.info("Processing of " + this.exporterNameClause + "remote call resulted in exception: "
                        + ClassUtils.getQualifiedMethodName(method), ex);
            }
        }

        throw ex;
    }
}