List of usage examples for java.lang.reflect Method getDeclaringClass
@Override
public Class<?> getDeclaringClass()
From source file:be.fgov.kszbcss.rhq.websphere.config.ConfigObjectInvocationHandler.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Class<?> declaringClass = method.getDeclaringClass(); if (declaringClass == ConfigObject.class || declaringClass == Object.class) { // TODO: not correct for Object#equals return method.invoke(this, args); } else {// w ww.ja va 2 s .c o m return getAttributeValue(type.getAttributeDescriptor(method)); } }
From source file:jsst.core.client.dispatcher.impl.HTTPDispatcher.java
@Override public HTTPServerResponse dispatch(Method method) throws DispatcherException { HttpClient httpClient = new HttpClient(); PostMethod postMethod = new PostMethod(url); postMethod.setParameter(REQUEST_PARAM_CLASS_NAME, method.getDeclaringClass().getCanonicalName()); postMethod.setParameter(REQUEST_PARAM_METHOD_NAME, method.getName()); try {/* www .jav a2 s .c o m*/ try { httpClient.executeMethod(postMethod); } catch (ConnectException ex) { throw new DispatcherException("Failed to connect to \"" + url + "\". Seems like server is down"); } return new HTTPServerResponse(url, postMethod.getResponseBodyAsString(), postMethod.getStatusCode()); } catch (IOException e) { throw new DispatcherException("Exception caught while sending request to \"" + url + "\"", e); } finally { postMethod.releaseConnection(); } }
From source file:io.cloudslang.worker.execution.reflection.ReflectionAdapterImpl.java
private Object[] buildParametersArray(Method actionMethod, Map<String, ?> actionData) { String actionFullName = actionMethod.getDeclaringClass().getName() + "." + actionMethod.getName(); String[] paramNames = cacheParamNames.get(actionFullName); if (paramNames == null) { paramNames = parameterNameDiscoverer.getParameterNames(actionMethod); cacheParamNames.put(actionFullName, paramNames); }//from w w w .j a va 2 s . c o m List<Object> args = new ArrayList<>(paramNames.length); for (String paramName : paramNames) { if (ExecutionParametersConsts.NON_SERIALIZABLE_EXECUTION_DATA.equals(paramName)) { Long executionId = getExecutionIdFromActionData(actionData); Map<String, Object> nonSerializableExecutionData = sessionDataHandler .getNonSerializableExecutionData(executionId); args.add(nonSerializableExecutionData); // If the control action requires non-serializable session data, we add it to the arguments array // and set the session data as active, so that it won't be cleared sessionDataHandler.setSessionDataActive(executionId); continue; } Object param = actionData.get(paramName); args.add(param); } return args.toArray(new Object[args.size()]); }
From source file:com.github.hateoas.forms.spring.AffordanceBuilderFactory.java
@Override public AffordanceBuilder linkTo(final Method method, final Object... parameters) { return linkTo(method.getDeclaringClass(), method, parameters); }
From source file:com.dianping.resource.io.util.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 a v a 2 s. c o m*/ * @return the qualified name of the method */ public static String getQualifiedMethodName(Method method) { Assert.notNull(method, "Method must not be null"); return method.getDeclaringClass().getName() + "." + method.getName(); }
From source file:org.slc.sli.dashboard.util.UserCacheKeyGenerator.java
@Override public Object generate(Object target, Method method, Object... params) { String token = SecurityUtil.getToken(); int hashCode = 17; hashCode = 31 * hashCode + (token == null ? NULL_PARAM_KEY : token.hashCode()); hashCode = 31 * hashCode + method.getDeclaringClass().hashCode(); hashCode = 31 * hashCode + method.getName().hashCode(); for (Object object : params) { hashCode = 31 * hashCode + (object == null ? NULL_PARAM_KEY : object.hashCode()); }// w w w .j a v a 2 s . co m return Integer.valueOf(hashCode); }
From source file:org.alfresco.test.TestServiceImpl.java
/** * Prepares map of all test ids and test location. * Tests marked with an annotated {@link AlfrescoTest} are collected into * the hash map along with details of the path which is then used to populate * the testng configuration file. //from w w w . j a v a 2 s. com */ private void prepareTestMap() { //Start reflection store Reflections reflections = new Reflections("org.alfresco", new SubTypesScanner(false), new TypeAnnotationsScanner(), new MethodAnnotationsScanner()); //Get all classes with alfresco test annotation Set<Method> allAnonMethods = reflections.getMethodsAnnotatedWith(org.alfresco.test.AlfrescoTest.class); Set<Class<?>> allAnonClasses = reflections.getTypesAnnotatedWith(org.alfresco.test.AlfrescoTest.class, false); for (Method m : allAnonMethods) { String path = m.getDeclaringClass().getName(); AlfrescoTest a = m.getAnnotation(AlfrescoTest.class); String testlinkId = a.testlink(); TestCase testcase = new TestCase(testlinkId, path); testcase.setMethodName(m.getName()); testdata.put(testlinkId, testcase); } for (Class<?> c : allAnonClasses) { String path = c.getName(); AlfrescoTest a = (AlfrescoTest) c.getAnnotation(AlfrescoTest.class); String testlinkId = a.testlink(); testdata.put(testlinkId, new TestCase(testlinkId, path)); } }
From source file:com.tmind.framework.pub.utils.MethodUtils.java
/** * <p>Return an accessible method (that is, one that can be invoked via * reflection) that implements the specified Method. If no such method * can be found, return <code>null</code>.</p> * * @param method The method that we wish to call *///from w w w . j a v a 2s.c o m public static Method getAccessibleMethod(Method method) { // Make sure we have a method to check if (method == null) { return (null); } // If the requested method is not public we cannot call it if (!Modifier.isPublic(method.getModifiers())) { return (null); } // If the declaring class is public, we are done Class clazz = method.getDeclaringClass(); if (Modifier.isPublic(clazz.getModifiers())) { return (method); } // Check the implemented interfaces and subinterfaces method = getAccessibleMethodFromInterfaceNest(clazz, method.getName(), method.getParameterTypes()); return (method); }
From source file:io.pravega.test.system.framework.RemoteSequential.java
@Override public CompletableFuture<Void> startTestExecution(Method testMethod) { log.debug("Starting test execution for method: {}", testMethod); String className = testMethod.getDeclaringClass().getName(); String methodName = testMethod.getName(); String jobId = (methodName + ".testJob").toLowerCase(); //All jobIds should have lowercase for metronome. return CompletableFuture.runAsync(() -> { CLIENT.createJob(newJob(jobId, className, methodName)); Response response = CLIENT.triggerJobRun(jobId); if (response.status() != CREATED.code()) { throw new TestFrameworkException(TestFrameworkException.Type.ConnectionFailed, "Error while starting " + "test " + testMethod); }//from w w w . j a v a 2 s. c o m }).thenCompose(v2 -> waitForJobCompletion(jobId)).<Void>thenApply(v1 -> { if (CLIENT.getJob(jobId).getHistory().getFailureCount() != 0) { throw new AssertionError("Test failed, detailed logs can be found at " + "https://MasterIP/mesos, under metronome framework tasks. MethodName: " + methodName); } return null; }).whenComplete((v, ex) -> { deleteJob(jobId); //deletejob once execution is complete. if (ex != null) { log.error("Error while executing the test. ClassName: {}, MethodName: {}", className, methodName); } }); }
From source file:com.freetmp.common.util.ClassUtils.java
public static String getQualifiedMethodName(Method method) { Assert.notNull(method, "Method must not be null"); return method.getDeclaringClass().getName() + "." + method.getName(); }