public static Function createFunction(String name) { try { if ( name == null ) throw new RuntimeException( "insufficient arguments" ); Class constructorArgs[] = new Class[0]; Class fclass = Class.forName( name ); if ( fclass == null ) throw new RuntimeException( "class not found" ); Constructor construct = fclass.getConstructor( constructorArgs ); if ( construct == null ) throw new RuntimeException( "constructor not found" ); Object initArgs[] = new Object[0]; Object obj = construct.newInstance( initArgs ); if ( obj instanceof Function ) return (Function) obj; else throw new RuntimeException( "function object does not implement interface function" ); } catch ( Exception e ) { System.out.println( e ); e.printStackTrace(); throw new RuntimeException( "function " + name + " not found" ); } }
public static Function createFunction( StaticContext context, String clazzName) { try { if (clazzName == null) throw new RuntimeException("insufficient arguments"); Class constructorArgs[] = { StaticContext.class }; Class fclass = Class.forName(clazzName); if (fclass == null) throw new RuntimeException("class not found"); Constructor construct = fclass.getConstructor(constructorArgs); if (construct == null) throw new RuntimeException("constructor not found"); Object initArgs[] = { context }; Object obj = construct.newInstance(initArgs); if (obj instanceof Function) return (Function) obj; else throw new RuntimeException("function object does not implement interface function"); } catch (Exception e) { LOG.debug(e.getMessage(), e); e.printStackTrace(); throw new RuntimeException("function " + clazzName + " not found"); } }
    public static Function createFunction(String name) {        try {            if ( name == null )                throw new RuntimeException( "insufficient arguments" );            Class constructorArgs[] = new Class[0];            Class fclass = Class.forName( name );            if ( fclass == null )                throw new RuntimeException( "class not found" );            Constructor construct = fclass.getConstructor( constructorArgs );            if ( construct == null )                throw new RuntimeException( "constructor not found" );            Object initArgs[] = new Object[0];            Object obj = construct.newInstance( initArgs );            if ( obj instanceof Function )                return (Function) obj;            else                throw new RuntimeException( "function object does not implement interface function" );        } catch ( Exception e ) {            System.out.println( e );            e.printStackTrace();            throw new RuntimeException( "function " + name + " not found" );        }    }