0 Replies Latest reply on Sep 21, 2012 7:22 PM by Tonio Caputo

    Jboss-modules standalone (Without module MAIN)

    Tonio Caputo Newbie

      Seems this is the place where to ask for it, sorry if its not.

       

      Trying to implement a basic module example, no UI just command line stuff, using 1.1.3.GA

       

      Basically the project  consists of 3 things

       

      1 - EchoService API

      2 - EchoService SPI (Implementation)

      3 - MAIN - Standard java class with main calling EchoService

       

      Module - contains and exports jmod.echo.impl.EchoServiceImpl (does not include API as part of it).

       

      module xmlns="urn:jboss:module:1.1" name="jmod.echo"
          exports
              include path="jmod.echo"/
          /exports
      
          dependencies
              system
                  paths
                      path name="jmod.echo.api"/
                  /paths
              /system
          /dependencies
          
          resources
              resource-root path="jmod-impl.jar"/
          /resources
          
      /module
      

      MAIN - Depends on the API and gets the module

       

       

          public static void main(final String[] args) throws Exception {
              System.setProperty("module.path", "/u/jdesa/payment/jmod/modules");
      
              // Need to do this, so EchoService API is seen by the module
              System.setProperty("jboss.modules.system.pkgs", "jmod.echo.api");
      
              Module.setModuleLogger(new StreamModuleLogger(System.out));
      
              ModuleIdentifier echoId = ModuleIdentifier.create("jmod.echo");
              ModuleLoader moduleLoader = Module.getBootModuleLoader();
              Module module = moduleLoader.loadModule(echoId);
      
              ServiceLoader<EchoService> loader = module.loadService(EchoService.class);
              EchoService service = loader.iterator().next();
              System.out.println(service.echoService("Hello world !"));
          }
      
      

      Seems that the system dependency defined in the module.xml is not used,  (looking at the Module source code seems System ClassLoader classes are kind of fix and cannot be changed)

       

      So my kind of questions are these:

      1. Someone knows if what I've just said is correct or may be I'm missing something ?
        I've not seen any issue in JIRA regarding this thing.
        If this is true dealing with multiple modules API/IMPL is a kind of mess, may be my approach is not good on how to do this ?
      2. Has some-one worked on something similar, I'll like to share thoughts as Jboss-modules docs are really "short" ?
      3. If some one worked on something similar, is my approach good or may be I'm missing a very basic thing about how Jboss Modules works ?

       

      Thanks in advance

      tonio