0 Replies Latest reply on Oct 3, 2017 5:50 AM by Per Norrman

    Can I create truly module internal classes in jboss-modules?

    Per Norrman Newbie

      Couldn't find a forum dedicated to jboss-modules, so I'll try here.

       

      I'm trying to figure out if I can tell jboss-modules that some portions of the resources are "module-internal", i.e. that they cannot be accessed from any other module, not even the modules that has the target module as a direct dependency. So I tried experimenting with the module global <exports> directive. I have an "application" module like so:

       

      <module xmlns="urn:jboss:module:1.3" name="x.app">
         <main-class name="xyzzy.app.Main" />
         <resources>
            <resource-root path="x-app-1.0.jar" />
         </resources>
         <dependencies>
            <module name="x.alpha" services="import"> </module>
         </dependencies>
      </module>
      

       

      and a the x-alpha module:

       

      <module xmlns="urn:jboss:module:1.3" name="x.alpha">
         <exports>
            <include path="xyzzy/**" />
            <exclude path="org/reflections/**"/>
         </exports>
         <resources>
            <resource-root path="public/x-alpha-1.0.jar" />
            <resource-root path="private/reflections-0.9.10.jar" />
         </resources>
      </module>
      

       

      Then I try loading the class org.reflections.Reflections from the Main class

       

                  Class<?> c = Class.forName("org.reflections.Reflections", true, Main.class.getClassLoader());
      

       

      Based on exclude pattern, my guess is that it should fail, but it works. Do the exports directive have any effect at all? Well, if I put a top level wildcard in the exclude directive

       

         <exports>
            <include path="xyzzy/**" />
            <exclude path="*"/>
         </exports>
      

       

      then loading fails, but then I cannot use any of the "public" classes.

       

      Is this module global directive supposed to work the way I think, or am I using something unsupported/undocumented?

       

      UPDATE

       

      After some more experiments, setting the exports directive to

       

         <exports>
            <include path="xyzzy/**" />
            <exclude path="org/**"/>
         </exports>
      

       

      yields the expected result, i.e. that

       

                  Class<?> c = Class.forName("org.reflections.Reflections", true, Main.class.getClassLoader());
      

       

      fails. Testing GlobPathFilter from master, though, suggest that something else is going on:

       

              assertTrue(new GlobPathFilter("org/**").accept("org/reflections/Reflections"));
              assertTrue(new GlobPathFilter("org/reflections/**").accept("org/reflections/Reflections"));
      

       

       

      Both assertions succeeds.