List of usage examples for java.lang.reflect Method getDeclaringClass
@Override
public Class<?> getDeclaringClass()
From source file:org.LexGrid.LexBIG.caCore.client.proxy.DataServiceProxyHelperImpl.java
protected boolean isLazyLoadableMethod(Method method) { if (!method.getDeclaringClass().getName().startsWith("org.LexGrid")) { return false; }//www . jav a 2 s . c o m String methodName = method.getName(); //if this method has been flagged to be skipped from Lazy Loading, skip it here if (ArrayUtils.contains(NON_LAZY_LOAD_METHODS, methodName)) { return false; } if (methodName.startsWith("get") || methodName.startsWith("iterate") || methodName.startsWith("enumerate")) { return true; } return false; }
From source file:koper.aop.AbstractSendMessageAdvice.java
/** * ?topic name//from w w w. j a v a2s . c o m * @param method */ protected String buildTopicName(Method method) { String topic = method.getDeclaringClass().getName() + "." + method.getName(); return topic; }
From source file:org.kmnet.com.fw.web.logging.TraceLoggingInterceptor.java
/** * Logic to output start log//ww w. ja v a 2 s . c o m * <p> * Outputs the start log and sets start time (in nano-seconds) in {@code HttpServletRequest} * </p> * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, java.lang.Object) */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } if (logger.isTraceEnabled()) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); logger.trace("[START CONTROLLER] {}.{}({})", new Object[] { m.getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod) }); } long startTime = System.nanoTime(); request.setAttribute(START_ATTR, startTime); return true; }
From source file:org.callimachusproject.rewrite.RewriteAdvice.java
private String getSystemId(Method m) { if (m.isAnnotationPresent(Iri.class)) return m.getAnnotation(Iri.class).value(); Class<?> dclass = m.getDeclaringClass(); String mame = m.getName();/*from w w w.j a v a 2 s.co m*/ if (dclass.isAnnotationPresent(Iri.class)) { String url = dclass.getAnnotation(Iri.class).value(); if (url.indexOf('#') >= 0) return url.substring(0, url.indexOf('#') + 1) + mame; return url + "#" + mame; } String name = dclass.getSimpleName() + ".class"; URL url = dclass.getResource(name); if (url != null) return url.toExternalForm() + "#" + mame; return "java:" + dclass.getName() + "#" + mame; }
From source file:cf.spring.servicebroker.ServiceBrokerMethods.java
private void validateUnbindMethod(Method unbindMethod, boolean bindable) { if (unbindMethod == null) { return;//from w w w . j a v a 2s . c o m } if (!bindable) { throw new BeanCreationException("Service broker on class " + unbindMethod.getDeclaringClass().getName() + " is NOT bindable but has a method annotated with @" + Unbind.class.getName()); } validateReturnType(unbindMethod, Unbind.class, void.class); validateArgument(unbindMethod, Bind.class, UnbindRequest.class); }
From source file:org.nabucco.alfresco.enhScriptEnv.common.script.aop.ScriptableListLikeMapAdapterInterceptor.java
/** * {@inheritDoc}// w w w . ja v a 2 s. c om */ @Override public Object invoke(final MethodInvocation invocation) throws Throwable { final Object result; final Method method = invocation.getMethod(); final Class<?> declaringClass = method.getDeclaringClass(); if (Scriptable.class.equals(declaringClass) && invocation instanceof ProxyMethodInvocation) { final ProxyMethodInvocation pInvocation = (ProxyMethodInvocation) invocation; final Object proxy = pInvocation.getProxy(); final String methodName = method.getName(); final Object[] arguments = invocation.getArguments(); // String-switch not supported in Java < 8 switch (ScriptableMethodName.methodLiteralOf(methodName)) { case GET: if (proxy instanceof Map<?, ?> && arguments.length > 0 && arguments[0] instanceof Integer) { if (!((Map<?, ?>) proxy).containsKey(arguments[0])) { final Object[] keys = ((Map<?, ?>) proxy).keySet().toArray(new Object[0]); if (((Integer) arguments[0]).intValue() >= 0 && keys.length > ((Integer) arguments[0]).intValue()) { result = ((Map<?, ?>) proxy).get(keys[((Integer) arguments[0]).intValue()]); } else { // simply delegate further result = invocation.proceed(); } } else { // simply delegate further result = invocation.proceed(); } } else { // simply delegate further result = invocation.proceed(); } break; case HAS: if (proxy instanceof Map<?, ?> && arguments.length > 0 && arguments[0] instanceof Integer) { if (!((Map<?, ?>) proxy).containsKey(arguments[0])) { final Object[] keys = ((Map<?, ?>) proxy).keySet().toArray(new Object[0]); result = Boolean.valueOf(((Integer) arguments[0]).intValue() >= 0 && keys.length > ((Integer) arguments[0]).intValue()); } else { // simply delegate further result = invocation.proceed(); } } else { // simply delegate further result = invocation.proceed(); } break; case PUT: if (proxy instanceof Map<?, ?> && arguments.length > 2 && arguments[0] instanceof Integer) { if (!((Map<?, ?>) proxy).containsKey(arguments[0])) { // we only support indexed-put for existing keys final Object[] keys = ((Map<?, ?>) proxy).keySet().toArray(new Object[0]); if (((Integer) arguments[0]).intValue() >= 0 && keys.length > ((Integer) arguments[0]).intValue()) { @SuppressWarnings("unchecked") final Map<Object, Object> map = (Map<Object, Object>) proxy; map.put(keys[((Integer) arguments[0]).intValue()], arguments[2]); // void return type result = null; } else { // simply delegate further result = invocation.proceed(); } } else { // simply delegate further result = invocation.proceed(); } } else { // simply delegate further result = invocation.proceed(); } break; case DELETE: if (proxy instanceof Map<?, ?> && arguments.length > 0 && arguments[0] instanceof Integer) { if (!((Map<?, ?>) proxy).containsKey(arguments[0])) { final Object[] keys = ((Map<?, ?>) proxy).keySet().toArray(new Object[0]); if (((Integer) arguments[0]).intValue() >= 0 && keys.length > ((Integer) arguments[0]).intValue()) { ((Map<?, ?>) proxy).remove(keys[((Integer) arguments[0]).intValue()]); // void return type result = null; } else { // simply delegate further result = invocation.proceed(); } } else { // simply delegate further result = invocation.proceed(); } } else { // simply delegate further result = invocation.proceed(); } break; default: // simply delegate further result = invocation.proceed(); break; } } else { result = invocation.proceed(); } return result; }
From source file:org.crazydog.util.spring.ClassUtils.java
/** * Return the qualified name of the given method, consisting of * fully qualified interface/class name + "." + method name. * @param method the method/*from w w w . j av a 2 s .c om*/ * @return the qualified name of the method */ public static String getQualifiedMethodName(Method method) { org.springframework.util.Assert.notNull(method, "Method must not be null"); return method.getDeclaringClass().getName() + "." + method.getName(); }
From source file:introducitons.IsModifiedMixin.java
private Method getGetterFromSetter(Method setter) { Method getter = methodCache.get(setter); if (null != getter) { return getter; }/* w w w . j a va 2 s . c o m*/ String getterName = setter.getName().replaceFirst("set", "get"); try { getter = setter.getDeclaringClass().getMethod(getterName); synchronized (methodCache) { methodCache.put(setter, getter); } return getter; } catch (NoSuchMethodException ex) { return null; } }
From source file:com.opensource.frameworks.processframework.utils.ClassUtils.java
/** * Given a method, which may come from an interface, and a target class used * in the current reflective invocation, find the corresponding target method * if there is one. E.g. the method may be <code>IFoo.bar()</code> and the * target class may be <code>DefaultFoo</code>. In this case, the method may be * <code>DefaultFoo.bar()</code>. This enables attributes on that method to be found. * <p><b>NOTE:</b> In contrast to {@link org.springframework.aop.support.AopUtils#getMostSpecificMethod}, * this method does <i>not</i> resolve Java 5 bridge methods automatically. * Call {@link org.springframework.core.BridgeMethodResolver#findBridgedMethod} * if bridge method resolution is desirable (e.g. for obtaining metadata from * the original method definition).//ww w . ja v a2 s . c o m * <p><b>NOTE:</b>Since Spring 3.1.1, if java security settings disallow reflective * access (e.g. calls to {@code Class#getDeclaredMethods} etc, this implementation * will fall back to returning the originally provided method. * @param method the method to be invoked, which may come from an interface * @param targetClass the target class for the current invocation. * May be <code>null</code> or may not even implement the method. * @return the specific target method, or the original method if the * <code>targetClass</code> doesn't implement it or is <code>null</code> */ public static Method getMostSpecificMethod(Method method, Class<?> targetClass) { Method specificMethod = null; if (method != null && isOverridable(method, targetClass) && targetClass != null && !targetClass.equals(method.getDeclaringClass())) { try { specificMethod = ReflectionUtils.findMethod(targetClass, method.getName(), method.getParameterTypes()); } catch (AccessControlException ex) { // security settings are disallowing reflective access; leave // 'specificMethod' null and fall back to 'method' below } } return (specificMethod != null ? specificMethod : method); }
From source file:de.fischer.thotti.core.configuration.ConfigDenormalizer.java
private String getFQCNFromHolder(ThottiAnnotationHolder<NDTest> holder) { AnnotatedElement element = holder.getOrigin(); assert element instanceof Method : "Only methods are currently supported."; Method method = (Method) element; Class clazz = method.getDeclaringClass(); assert clazz.isInterface() == false : "Annotation of interfaces is not supported."; return clazz.getCanonicalName(); }