Java 工具库集合 Gadtry

码农软件 · 软件分类 · 常用工具包 · 2019-08-12 15:59:20

软件介绍

Gadtry是一个java工具库集合。包含:ioc, exec(fork进程), graph(图计算)等等常用工具集,并且完全零依赖。

Use

maven

<dependency>
  <groupId>com.github.harbby</groupId>
  <artifactId>gadtry</artifactId>
  <version>1.1.0</version>
</dependency>

gradle

compile group: 'com.github.harbby', name: 'gadtry', version: '1.0.0'

Ioc

Create Factory:

IocFactory iocFactory = IocFactory.create(binder -> {
    binder.bind(Set.class).by(HashSet.class).withSingle();
    binder.bind(HashSet.class).withSingle();
    binder.bind(List.class).byCreator(ArrayList::new);  //Single object
    binder.bind(Object.class, new Object());
    binder.bind(Map.class).byCreator(HashMap::new).withSingle();  //Single object
    binder.bind(TestInject.class);
});

Set a1 = iocFactory.getInstance(Set.class);
Set a2 = iocFactory.getInstance(Set.class);
Assert.assertEquals(true, a1 == a2); // Single object

Class Inject

public class TestInject
{
    @Autowired
    private TestInject test;

    @Autowired
    public TestInject(HashMap set){
        System.out.println(set);
    }
}

Exec New Jvm

Throw the task to the child process

JVMLauncher launcher = JVMLaunchers.newJvm()
    .setCallable(() -> {
        // this is child process
        System.out.println("************ runing your task ***************");
        return 1;
    })
    .addUserjars(Collections.emptyList())
    .setXms("16m")
    .setXmx("16m")
    .setConsole((msg) -> System.out.println(msg))
    .build();

VmFuture out = launcher.startAndGet();
Assert.assertEquals(out.get().get().intValue(), 1);

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

Java Web高级编程

Java Web高级编程

威廉斯 (Nicholas S.Williams) / 王肖锋 / 清华大学出版社 / 2015-6-1 / CNY 99.80

Java成为世界上编程语言之一是有其优势的。熟悉JavaSE的程序员可以轻松地进入到Java EE开发中,构建出安全、可靠和具有扩展性的企业级应用程序。编写《Java Web高级编程——涵盖WebSockets、Spring Framework、JPA Hibernate和 Spring Security》一书的目的正是如此。 《Java Web高级编程:涵盖WebSockets、Sp......一起来看看 《Java Web高级编程》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

SHA 加密
SHA 加密

SHA 加密工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具