Java 工具包 MyTools

码农软件 · 软件分类 · 常用工具包 · 2019-08-15 18:43:14

软件介绍

该 jar 包对 java 调用 Groovy 、JavaScript、Clojure 脚本语言的接口进行封装,方便在java程序中进行多语言混合编程

在jar中增加对URLClassLoader类进行继承重写实现动态加载和拆卸jar,使用Message类进行jar插件间的解耦调用。

包管理工具采用 Gradle 进行管理

MyTools工具类旧版本git地址 : https://gitee.com/iproject/MyTools.git

MyTools工具类最新版本git地址:https://gitee.com/iproject/MyTools2.git

使用示例:

 

    @Test
    public void testJava() throws Exception {
        JavaHepler jh = new JavaHepler();
        //jh.putPath("Test", "test.Test");
        //IMethod d = jh.newInstance("Test");
        //or
        IMethod d = jh.newInstance("test.Test");
        IInvoke i = d.getMethod("p");
        i.invoke();
        i = d.getMethod("p2");
        i.invoke("MyTools");
    }

    //@Test
    public void javaScript() {
        long b = System.currentTimeMillis();
        String[] s = new String[] { "test/test.js" };
        JSHelper js = new JSHelper(s);
        js.addField("ca").javaToJs(System.out);
        System.out.println(js.getMethod("test").invoke());
        js.exit();
        long e = System.currentTimeMillis();
        System.out.println("js :" + (e - b));
    }

    //@Test
    public void groovy() throws Exception {
        String file = "test/Test.groovy";
        long b = System.currentTimeMillis();
        GroovyHelper gh = new GroovyHelper();
        //gh.putPath("Test", file);
        //gh.newInstance("Test").getMethod("t").invoke();
        //or
        gh.newInstance(file).getMethod("t").invoke();
        long e = System.currentTimeMillis();
        System.out.println("Groovy :" + (e - b));
    }

    //@Test
    public void clojure() throws Exception {
        String file = "test/test_t.clj";
        long b = System.currentTimeMillis();
        ClojureHelper cl = new ClojureHelper();
        //cl.putPath("test", file);
        //IMethod c = cl.newInstance("test");
        //or
        IMethod c = cl.newInstance(file);
        IInvoke i = c.getMethod("t3");
        System.out.println(i.invoke(4));
        long e = System.currentTimeMillis();
        System.out.println("clojure :" + (e - b));
    }

    //@Test
    public void jython() throws Exception {
           String file = "test/Test.py";
        long b = System.currentTimeMillis();
        JythonHelper jy = new JythonHelper();
        //jy.putPath("Test", file);
        //jy.newInstance("Test").getMethod("t").invoke();
        //or
        jy.newInstance(file).getMethod("t").invoke();
        long e = System.currentTimeMillis();
        System.out.println("jython :" + (e - b));
    }

    //@Test
    public void jruby() throws Exception {
        String file = "test/Rr.rb";
        long b = System.currentTimeMillis();
        JRubyHelper jr = new JRubyHelper();
        //jr.putPath("Rr", file);
        //Object obj = jr.newInstance("Rr").getMethod("c2f").invoke(100);
        //or
        Object obj = jr.newInstance(file).getMethod("c2f").invoke(100);
        System.out.println(obj);
        long e = System.currentTimeMillis();
        System.out.println("jruby :" + (e - b));
    }
    
    //@Test
    public void beanShell() throws EvalError, IOException{
        long b = System.currentTimeMillis();
        BeanShellHelper bsh = new BeanShellHelper();
        bsh.getFied("a").set("Hello World");
        bsh.load("test/test.bsh");
        System.out.println(bsh.getFied("b").get());
        long e = System.currentTimeMillis();
        System.out.println("jruby :" + (e - b));
    }

增加对beanShell调用的支持

 

本文地址:https://www.codercto.com/soft/d/12439.html

计算机和难解性

计算机和难解性

M.R 加里、D.S. 约翰逊 / 张立昂、沈泓 / 科学出版社 / 1987年 / 4.50

本书系统地介绍了NP完全性理论的概念和方法,全书共分为7章和两个附录。第一章粗略地介绍了计算复杂性的一些基本概念和NP完全性理论的意义。第二章至第五章介绍了NP完全性的基本理论和证明的方法。第六章集中研究NP难问题的近似算法。第七章概述了大量计算复杂性中的有关理论课题。 附录A收集了范围广泛、内容丰富的NP完全性和NP难的问题、附录B补充了NP问题的一些最新的进展,既有理论方面的,又有关于具体问题......一起来看看 《计算机和难解性》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码