public static void bind(Object destBean, Map<String, ?> src) { Method bind = Cls.findMethod(destBean.getClass(), "bind", Map.class); if (bind != null) { Cls.invoke(bind, destBean, src); } else { update(destBean, src, false, false); } }
public static Class<?> getCallingMainClass() { StackTraceElement[] trace = Thread.currentThread().getStackTrace(); // skip the first 2 elements: // [0] java.lang.Thread.getStackTrace // [1] THIS METHOD for (int i = 2; i < trace.length; i++) { String cls = trace[i].getClassName(); if (couldBeCaller(cls) && U.eq(trace[i].getMethodName(), "main")) { Class<?> clazz = Cls.getClassIfExists(cls); if (clazz != null) { Method main = Cls.findMethod(clazz, "main", String[].class); if (main != null && main.getReturnType() == void.class && !main.isVarArgs() && main.getDeclaringClass().equals(clazz)) { int modif = main.getModifiers(); if (Modifier.isStatic(modif) && Modifier.isPublic(modif)) { return clazz; } } } } } return null; }
public static Method getLambdaMethod(Serializable lambda, String functionalMethodName) { Method writeReplace = findMethod(lambda.getClass(), "writeReplace"); Method getImplClass = Cls.findMethod(serializedLambda.getClass(), "getImplClass"); Method getImplMethodName = Cls.findMethod(serializedLambda.getClass(), "getImplMethodName"); String lambdaMethodName = Cls.invoke(getImplMethodName, serializedLambda);
public static void bootstrap() { if (!once.go()) return; Log.info("Bootstraping metrics"); os = ManagementFactory.getOperatingSystemMXBean(); sysCpuM = Cls.findMethod(os.getClass(), "getSystemCpuLoad"); procCpuM = Cls.findMethod(os.getClass(), "getProcessCpuLoad"); openFileDescriptorCount = Cls.findMethod(os.getClass(), "getOpenFileDescriptorCount"); threads = ManagementFactory.getThreadMXBean(); register("cpu/system", SYSTEM_CPU); register("cpu/process", PROCESS_CPU); register("mem/used", MEM_USED); register("mem/total", MEM_TOTAL); register("threads", NUM_THREADS); register("descriptors", NUM_FILE_DESC); // FIXME there are too many metrics // JMXMetrics.bootstrap(); Metrics updateMetrics = new Metrics(); updateMetrics.run(); Jobs.scheduleAtFixedRate(updateMetrics, 1, 1, TimeUnit.SECONDS); }
@Override public Object runManageableAction(String action) { Method method = Cls.findMethod(source().getClass(), Str.uncapitalized(action)); if (method != null) { return Cls.invoke(method, source()); } else { return doManageableAction(action); } }
Method m2 = Cls.findMethod(SpecificTag.class, name, paramTypes); if (m2 != null && m2.getAnnotation(Special.class) != null) { m2 = Cls.findMethod(TagBase.class, name, paramTypes); U.notNull(m2, "special tag method in TagBase"); return m2.invoke(tag, args);
Method getParameters = Cls.findMethod(method.getClass(), "getParameters");
public static void bind(Object destBean, Map<String, Object> src) { Method bind = Cls.findMethod(destBean.getClass(), "bind", Map.class); if (bind != null) { Cls.invoke(bind, destBean, src); } else { update(destBean, src, false, false); } }