1 2 3 Previous Next 36 Replies Latest reply on Sep 13, 2011 1:05 PM by lmcdasi Go to original post
      • 30. Re: META-INF/services for module extensions - question/issue
        lmcdasi

        Another test - and I do not want to change classloaders I just want to use the module.xml setup

         

        Now - with the debugger one can see the classes BUT the META-INF/services are no part of the classpath. So the ServiceLoader does not work ! Sorry I may not have worded correctly but that is what I get.

         

        ME module.xml has only one dependecy : <module name="com.module.first"/>    ==> ME has visibility on M1

        M1 only one dependency : <module name="com.module.second" export="true"/>  ==> M1 has visibility on M2

        M2 only one dependency : <module name="com.module.third" export="true"/>      ==> M1 has visibility on M3

         

        M1: ServiceLoader<com.module.second.services.TestServicesIfc> myTt = ServiceLoader.load(com.module.second.services.TestServicesIfc.class);

         

         

        11:51:28,185 INFO  [com.modext.dans.services.TCCLSingletonService] (MSC service thread 1-3) TCCLSingletonService - start

        ed

        11:51:28,188 INFO  [com.modext.dans.services.TCCLSingletonService] (MSC service thread 1-3) TestServicesIfc -------> Fou

        nd services class <<-- that is due to jboss-module api

        11:51:28,192 INFO  [com.module.first.services.TestServicesImpl] (MSC service thread 1-3) HELLO

        11:51:28,238 INFO  [com.module.first.TestPackage] (MSC service thread 1-3) I am in TestPackage - Module#1

        11:51:28,240 INFO  [com.module.first.TestPackage] (MSC service thread 1-3) I am in loadLib

        11:51:28,243 INFO  [com.module.first.TestPackage] (MSC service thread 1-3) contextInitialized -------> NOT Found service

        s class from Module#2  <-- ServiceLoader.load(com.module.second.services.TestServicesIfc.class)           FAILS <----

        11:51:28,245 INFO  [com.modext.dans.services.TCCLSingletonService] (MSC service thread 1-3) TestServicesIfc -------> NOT

        Second Found services class  <-- that is the ServiceLoader.load from the TCCL but that can be viewed as ok since it is jboss-module specific.

         

        BR,

        Dan S.

        • 31. Re: META-INF/services for module extensions - question/issue
          dmlloyd

          You did not do it correctly.  To see services from a dependency, you must add "services="import"" or "service="export"".  Normally you just do the former, and have a dependency for every module that you need to see services for.

          • 32. Re: META-INF/services for module extensions - question/issue
            lmcdasi

            OK - didn't got that propely. Here is what I have done:

             

            ME only one dep: <module name="com.module.first" services="export" />

             

            M1 only one dep: <module name="com.module.second" export="true" services="export"/>

             

            M2 only one dep: <module name="com.module.third" export="true" services="export"/>

             

            Looks to be the right now. Let me double check && I still have one test to go.

             

            Thanks!

             

            BR,

            Dan S.

            • 33. Re: META-INF/services for module extensions - question/issue
              brian.stansberry

              Sorry about that; I should have mentioned the services="import" or services="export" bit. Thanks, David.

              • 34. Re: META-INF/services for module extensions - question/issue
                lmcdasi

                Looks great. One extra question related to it - and the last one.

                 

                If for example module M2 does define a singleton class that it is instantiated when M1 executes the service impl from M2, then if ME does add a deployment dependency of WAR's deployments for module M2, would the singleton be respected or I will end up having two instances of the same class ?

                 

                I already tried and it looked to respect the singleton but I just want to be sure that what I do is correct.

                 

                Thanks,

                Dan S.

                • 35. Re: META-INF/services for module extensions - question/issue
                  brian.stansberry

                  Yes, the singleton will be respected.

                   

                  Say you have com.foo.Singleton.class and it only exists in jar singleton.jar. So long as there is only one module Mx that includes singleton.jar in its <resources> element, there will only be one classloader that defines a class named com.foo.Singleton.

                   

                  Other modules that add a dependency on Mx only declare that they want to have access to whatever classes Mx exposes; they aren't declaring that they can be a defining classloader for the bits described in Mx's <resources> element.

                  • 36. Re: META-INF/services for module extensions - question/issue
                    lmcdasi

                    Thanks!

                    1 2 3 Previous Next