<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          GadtryJava 工具庫集合

          聯合創(chuàng)作 · 2023-09-28 11:33

          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);
          瀏覽 16
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  成人网站在线免费观看 | 亚洲欧美精品性爱 | 日逼好舒服 | 人操人碰| 啪啪啪无码网站 |