當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodUtils.invokeStaticMethod方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodUtils.invokeStaticMethod方法的具體用法?Java MethodUtils.invokeStaticMethod怎麽用?Java MethodUtils.invokeStaticMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.reflect.MethodUtils的用法示例。


在下文中一共展示了MethodUtils.invokeStaticMethod方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkCommands

import org.apache.commons.lang3.reflect.MethodUtils; //導入方法依賴的package包/類
private void checkCommands(final String os, final String... command) throws ReflectiveOperationException {
	final URL[] urLs = ((URLClassLoader) Main.class.getClassLoader()).getURLs();
	ThreadClassLoaderScope scope = null;
	try {
		System.setProperty("os.name", os);
		final URLClassLoader urlClassLoader = new URLClassLoader(urLs, null);
		scope = new ThreadClassLoaderScope(urlClassLoader);
		final Object terra = urlClassLoader.loadClass("org.ligoj.app.plugin.prov.terraform.TerraformUtils").newInstance();
		final Object mock = MethodUtils.invokeStaticMethod(urlClassLoader.loadClass("org.mockito.Mockito"), "mock",
				urlClassLoader.loadClass("org.ligoj.bootstrap.resource.system.configuration.ConfigurationResource"));
		FieldUtils.writeField(terra, "configuration", mock, true);
		Assert.assertEquals(Arrays.asList(command),
				((ProcessBuilder) MethodUtils.invokeMethod(terra, true, "newBuilder", new Object[] { new String[] { "terraform" } }))
						.command());
	} finally {
		IOUtils.closeQuietly(scope);
	}
}
 
開發者ID:ligoj,項目名稱:plugin-prov,代碼行數:19,代碼來源:TerraformUtilsTest.java

示例2: getDescriptor

import org.apache.commons.lang3.reflect.MethodUtils; //導入方法依賴的package包/類
private Descriptors.Descriptor getDescriptor(Class<M> messageClass) {
	try {
		return (Descriptors.Descriptor) MethodUtils.invokeStaticMethod(
				messageClass, "getDescriptor");
	} catch (NoSuchMethodException | IllegalAccessException
			| InvocationTargetException ex) {
		throw new RuntimeException(ex);
	}
}
 
開發者ID:jigsaw-projects,項目名稱:jigsaw-payment,代碼行數:10,代碼來源:JdbcProtobufTemplate.java

示例3: newBuilder

import org.apache.commons.lang3.reflect.MethodUtils; //導入方法依賴的package包/類
/**
 * get Builder from messageClass
 *
 * @param messageClass
 * @return
 * @throws InvocationTargetException
 * @throws IllegalAccessException
 * @throws NoSuchMethodException
 */
public static <T extends Message> T.Builder newBuilder(Class<T> messageClass) {
	T.Builder builder = null;
	try {
		builder = (T.Builder) MethodUtils.invokeStaticMethod(messageClass,
				"newBuilder");
	} catch (NoSuchMethodException | IllegalAccessException
			| InvocationTargetException e) {
		throw new RuntimeException(e);
	}
	return builder;
}
 
開發者ID:jigsaw-projects,項目名稱:jigsaw-payment,代碼行數:21,代碼來源:JdbcProtobufTemplate.java

示例4: cleanSandboxClassLoader

import org.apache.commons.lang3.reflect.MethodUtils; //導入方法依賴的package包/類
private ClassLoader cleanSandboxClassLoader(final Class<?> classOfAgentLauncher)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    // 清理AgentLauncher.sandboxClassLoaderMap
    final ClassLoader sandboxClassLoader = (ClassLoader) MethodUtils.invokeStaticMethod(
            classOfAgentLauncher,
            "cleanClassLoader",
            configInfo.getNamespace()
    );
    logger.info("clean jvm-sandbox ClassLoader[namespace={}] success, for jvm-sandbox shutdown.",
            configInfo.getNamespace());
    return sandboxClassLoader;
}
 
開發者ID:alibaba,項目名稱:jvm-sandbox,代碼行數:13,代碼來源:ControlModule.java

示例5: launchHsqlGUI

import org.apache.commons.lang3.reflect.MethodUtils; //導入方法依賴的package包/類
private static void launchHsqlGUI() {
    Class<?> cls;
    try {
        cls = ClassUtils.getClass("org.hsqldb.util.DatabaseManagerSwing");
        MethodUtils.invokeStaticMethod(cls, "main", new Object[]{new String[]{"--url", "jdbc:hsqldb:mem:alfio", "--noexit"}});
    } catch (ReflectiveOperationException e) {
        log.warn("error starting db manager", e);
    }
}
 
開發者ID:alfio-event,項目名稱:alf.io,代碼行數:10,代碼來源:SpringBootLauncher.java


注:本文中的org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。