Example usage for java.lang.reflect Method toString

List of usage examples for java.lang.reflect Method toString

Introduction

In this page you can find the example usage for java.lang.reflect Method toString.

Prototype

public String toString() 

Source Link

Document

Returns a string describing this Method .

Usage

From source file:org.eclipse.wb.internal.core.eval.evaluators.InvocationEvaluator.java

/**
 * Finds method using {@link IMethodBinding} and invokes it for given object instance.
 */// ww  w.  j  a v  a  2s  .  co  m
private static Object invokeMethod(EvaluationContext context, Object targetValue,
        ITypeBinding targetTypeBinding, MethodInvocation invocation, IMethodBinding methodBinding)
        throws Exception {
    // prepare class
    Class<?> clazz;
    if (targetTypeBinding != null) {
        clazz = getTypeBindingClass(context, targetTypeBinding);
    } else {
        clazz = targetValue.getClass();
    }
    // prepare argument values
    Object[] argumentValues = getArgumentValues(context, DomGenerics.arguments(invocation), false);
    argumentValues = updateForVarArgs(context, methodBinding, argumentValues);
    // prepare method
    Method method = getReflectionMethod(clazz, methodBinding);
    // try to use interceptors
    {
        Object result = tryInterceptors(context, invocation, methodBinding, clazz, method, argumentValues);
        if (result != AstEvaluationEngine.UNKNOWN) {
            return result;
        }
    }
    // invoke method
    try {
        return method.invoke(targetValue, argumentValues);
    } catch (Throwable e) {
        throw new DesignerException(ICoreExceptionConstants.EVAL_METHOD, e, context.getSource(invocation),
                method.toString(), getArguments_toString(argumentValues));
    }
}

From source file:net.nelz.simplesm.aop.InvalidateMultiCacheAdvice.java

@Around("invalidateMulti()")
public Object cacheInvalidateMulti(final ProceedingJoinPoint pjp) throws Throwable {
    // This is injected caching.  If anything goes wrong in the caching, LOG the crap outta it,
    // but do not let it surface up past the AOP injection itself.
    List<String> cacheKeys = null;
    final AnnotationData annotationData;
    final String methodDescription;
    try {/*from   ww  w  . j  a  va2s.c o m*/
        final Method methodToCache = getMethodToCache(pjp);
        methodDescription = methodToCache.toString();
        final InvalidateMultiCache annotation = methodToCache.getAnnotation(InvalidateMultiCache.class);
        annotationData = AnnotationDataBuilder.buildAnnotationData(annotation, InvalidateMultiCache.class,
                methodToCache);
        if (annotationData.getKeyIndex() > -1) {
            final Object keyObject = getIndexObject(annotationData.getKeyIndex(), pjp, methodToCache);
            final List<Object> keyObjects = convertToKeyObjects(keyObject, annotationData.getKeyIndex(),
                    methodDescription);
            cacheKeys = getCacheKeys(keyObjects, annotationData);
        }
    } catch (Throwable ex) {
        LOG.warn("Caching on " + pjp.toShortString() + " aborted due to an error.", ex);
        return pjp.proceed();
    }

    final Object result = pjp.proceed();

    // This is injected caching.  If anything goes wrong in the caching, LOG the crap outta it,
    // but do not let it surface up past the AOP injection itself.
    try {
        // If we have a -1 key index, then build the cacheKeys now.
        if (annotationData.getKeyIndex() == -1) {
            final List<Object> keyObjects = convertToKeyObjects(result, annotationData.getKeyIndex(),
                    methodDescription);
            cacheKeys = getCacheKeys(keyObjects, annotationData);
        }
        if (cacheKeys != null && cacheKeys.size() > 0) {
            for (final String key : cacheKeys) {
                if (key != null && key.trim().length() > 0) {
                    cache.delete(key);
                }
            }
        }
    } catch (Throwable ex) {
        LOG.warn("Caching on " + pjp.toShortString() + " aborted due to an error.", ex);
    }
    return result;

}

From source file:org.eclipse.gemini.blueprint.compendium.internal.cm.UpdateMethodAdapter.java

/**
 * Determines the update method.//from w  w w  .  j  a va 2  s  .c om
 * 
 * @param target
 * @param methodName
 * @return
 */
static Map determineUpdateMethod(final Class<?> target, final String methodName) {
    Assert.notNull(target);
    Assert.notNull(methodName);

    final Map methods = new LinkedHashMap(2);
    final boolean trace = log.isTraceEnabled();

    org.springframework.util.ReflectionUtils.doWithMethods(target,
            new org.springframework.util.ReflectionUtils.MethodCallback() {

                public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
                    // consider filtering bridge non-void and non-public methods as well
                    if (!method.isBridge() && Modifier.isPublic(method.getModifiers())
                            && (void.class.equals(method.getReturnType()))
                            && methodName.equals(method.getName())) {
                        // check the argument types
                        Class<?>[] args = method.getParameterTypes();

                        // Properties can be passed as Map or Dictionary
                        if (args != null && args.length == 1) {
                            Class<?> propertiesType = args[0];
                            if (propertiesType.isAssignableFrom(Map.class)
                                    || propertiesType.isAssignableFrom(Dictionary.class)) {

                                if (trace)
                                    log.trace("Discovered custom method [" + method.toString() + "] on "
                                            + target);
                                // see if there was a method already found
                                Method m = (Method) methods.get(propertiesType);

                                if (m != null) {
                                    if (trace)
                                        log.trace(
                                                "Type " + propertiesType + " already has an associated method ["
                                                        + m.toString() + "];ignoring " + method);
                                } else
                                    methods.put(propertiesType, method);
                            }
                        }
                    }
                }
            });

    return methods;
}

From source file:org.wicketstuff.datatable_autocomplete.trie.LargeTrieTestCase.java

public void testSpecificWords() {

    List<Method> wordList = trie.getWordList("assign");

    for (Method method : wordList) {

        System.out.println("match = " + method.toString());
    }/*w  w  w  . j  a v a  2s . c om*/

    System.out.println("assign matches " + wordList.size() + " methods.");

    wordList = trie.getWordList("access");

    for (Method method : wordList) {

        System.out.println("match = " + method.toString());
    }

    System.out.println("access matches " + wordList.size() + " methods.");

}

From source file:org.wicketstuff.datatable_autocomplete.tst.LargeTrieTestCase.java

public void testSpecificWords() {

    List<Method> wordList = trie.getWordList("assign", -1);

    for (Method method : wordList) {

        System.out.println("match = " + method.toString());
    }/* ww w  . j a v a  2  s.  c  om*/

    System.out.println("assign matches " + wordList.size() + " methods.");

    wordList = trie.getWordList("access", -1);

    for (Method method : wordList) {

        System.out.println("match = " + method.toString());
    }

    System.out.println("access matches " + wordList.size() + " methods.");

}

From source file:org.openhab.model.script.ui.contentassist.ActionEObjectHoverProvider.java

private Method getActionMethod(XFeatureCall call) {
    if (call.getFeature().eContainer() instanceof JvmGenericType) {
        JvmGenericType type = (JvmGenericType) call.getFeature().eContainer();
        Object[] services = ScriptUIActivator.actionServiceTracker.getServices();
        if (services != null) {
            for (Object service : services) {
                ActionService actionService = (ActionService) service;
                if (actionService.getActionClassName().equals(type.getIdentifier())) {
                    for (Method m : actionService.getActionClass().getMethods()) {
                        if (m.toString().contains((call.getFeature().getIdentifier()))) {
                            return m;
                        }/*  w ww.  j a  v  a  2s . c o m*/
                    }
                }
            }
        }
    }
    return null;
}

From source file:mangotiger.bus.BusImpl.java

public void register(final Object consumer) {
    final Class clazz = consumer.getClass();
    for (Method method : clazz.getMethods()) {
        final Matcher matcher = eventMethod.matcher(method.toString());
        final boolean isEventMethod = matcher.matches();
        if (isEventMethod) {
            final String eventName = Strings.decapitalize(matcher.group(2));
            register(consumer, eventName);
        }//from   w w w.  j a  va2s. c  om
    }
}

From source file:org.mb.bo.SpringTxInterceptor.java

/**
 * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
 *///from w ww  . j a v  a 2s .co  m
public Object invoke(final MethodInvocation invocation) throws Throwable {

    final Method method = invocation.getMethod();

    SessionFactory.getSession().open();
    try {
        LOG.finer("invoking service method: " + method.toString());

        final Object result = method.invoke(invocation.getThis(), invocation.getArguments());
        SessionFactory.getSession().commit();
        return result;

    } catch (final Exception e) {
        SessionFactory.getSession().rollback();
        throw new OrmException("error during execution of service method: " + invocation.toString(), e);
    }
}

From source file:net.ymate.platform.core.beans.intercept.InterceptProxy.java

private List<Class<? extends IInterceptor>> __doGetBeforeIntercepts(Class<?> targetClass, Method targetMethod) {
    String _cacheKey = DigestUtils.md5Hex(targetClass.toString() + targetMethod.toString());
    ////from  ww  w.  ja v a2s  .co m
    if (__beforeInterceptsCache.containsKey(_cacheKey)) {
        return __beforeInterceptsCache.get(_cacheKey);
    }
    synchronized (__beforeCacheLocker) {
        List<Class<? extends IInterceptor>> _classes = __beforeInterceptsCache.get(_cacheKey);
        if (_classes != null) {
            return _classes;
        }
        _classes = InterceptAnnoHelper.getBeforeIntercepts(targetClass, targetMethod);
        //
        if (!_classes.isEmpty()) {
            __beforeInterceptsCache.put(_cacheKey, _classes);
        }
        //
        return _classes;
    }
}

From source file:net.ymate.platform.core.beans.intercept.InterceptProxy.java

private List<Class<? extends IInterceptor>> __doGetAfterIntercepts(Class<?> targetClass, Method targetMethod) {
    String _cacheKey = DigestUtils.md5Hex(targetClass.toString() + targetMethod.toString());
    ////from   w w  w  .j  ava  2s.  c om
    if (__afterInterceptsCache.containsKey(_cacheKey)) {
        return __afterInterceptsCache.get(_cacheKey);
    }
    synchronized (__afterCacheLocker) {
        List<Class<? extends IInterceptor>> _classes = __afterInterceptsCache.get(_cacheKey);
        if (_classes != null) {
            return _classes;
        }
        _classes = InterceptAnnoHelper.getAfterIntercepts(targetClass, targetMethod);
        //
        if (!_classes.isEmpty()) {
            __afterInterceptsCache.put(_cacheKey, _classes);
        }
        //
        return _classes;
    }
}