cascading.util.Util.invokeStaticMethod()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中cascading.util.Util.invokeStaticMethod()方法的一些代码示例,展示了Util.invokeStaticMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.invokeStaticMethod()方法的具体详情如下:
包路径:cascading.util.Util
类名称:Util
方法名:invokeStaticMethod

Util.invokeStaticMethod介绍

暂无

代码示例

代码示例来源:origin: cwensel/cascading

public static Object invokeStaticMethod( String typeString, String methodName, Object[] parameters, Class[] parameterTypes )
 {
 Class type = loadClass( typeString );
 return invokeStaticMethod( type, methodName, parameters, parameterTypes );
 }

代码示例来源:origin: cwensel/cascading

public static String setLog4jLevel( String logger, String level )
 {
 // removing logj4 dependency
 // org.apache.log4j.Logger.getLogger( logger[ 0 ] ).setLevel( org.apache.log4j.Level.toLevel( logger[ 1 ] ) );
 Object loggerObject = Util.invokeStaticMethod( "org.apache.log4j.Logger", "getLogger",
  new Object[]{logger}, new Class[]{String.class} );
 Object levelObject = null;
 if( level != null )
  levelObject = Util.invokeStaticMethod( "org.apache.log4j.Level", "toLevel",
   new Object[]{level}, new Class[]{String.class} );
 Object oldLevel = Util.invokeInstanceMethod( loggerObject, "getLevel",
  new Object[]{}, new Class[]{} );
 Util.invokeInstanceMethod( loggerObject, "setLevel",
  new Object[]{levelObject}, new Class[]{Util.loadClass( "org.apache.log4j.Level" )} );
 if( oldLevel == null )
  return null;
 return oldLevel.toString();
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testSetLogLevel()
 {
 Configuration jobConf = new Configuration();
 jobConf.set( "log4j.logger", "cascading=DEBUG" );
 HadoopUtil.initLog4j( jobConf );
 Object loggerObject = Util.invokeStaticMethod( "org.apache.log4j.Logger", "getLogger",
  new Object[]{"cascading"}, new Class[]{String.class} );
 Object levelObject = Util.invokeStaticMethod( "org.apache.log4j.Level", "toLevel",
  new Object[]{"DEBUG"}, new Class[]{String.class} );
 Object returnedLevel = Util.invokeInstanceMethod( loggerObject, "getLevel",
  new Object[]{}, new Class[]{} );
 assertEquals( levelObject, returnedLevel );
 }
}

代码示例来源:origin: cascading/cascading-hadoop2-common

@Test
public void testSetLogLevel()
 {
 Configuration jobConf = new Configuration();
 jobConf.set( "log4j.logger", "cascading=DEBUG" );
 HadoopUtil.initLog4j( jobConf );
 Object loggerObject = Util.invokeStaticMethod( "org.apache.log4j.Logger", "getLogger",
  new Object[]{"cascading"}, new Class[]{String.class} );
 Object levelObject = Util.invokeStaticMethod( "org.apache.log4j.Level", "toLevel",
  new Object[]{"DEBUG"}, new Class[]{String.class} );
 Object returnedLevel = Util.invokeInstanceMethod( loggerObject, "getLevel",
  new Object[]{}, new Class[]{} );
 assertEquals( levelObject, returnedLevel );
 }
}

相关文章