2 Replies Latest reply on Jul 4, 2012 12:13 AM by Tomohisa igarashi

    MixIn dependency management

    Tomohisa igarashi Master

      On my way to rebase my JCAMixIn onto new NamingMixIn, I have noticed the NamingMixIn#(un)initialize() would be invoked twice when using HornetQMixIn and JCAMixIn together(both of them extends NamingMixIn). As Keith suggested to me on IRC, it's time to bring some kind of dependency management into MixIns, instead of inheritance.

       

      One idea came to my mind is, injecting MixIn into MixIn. TestKit instantiates the MixIn instance only once, and inject them by the @DependOnMixIns annotation(or reuse SwitchYardTestCaseConfig?). TestKit should also take care of initalize/uninitialize invoking sequence - MixIns which is dependency of other MixIns sould be initialized first, and uninitialized last. In this way, application programmer don't have to know that HornetQMixIn depends on NamingMixIn, but still can specify NamingMixIn in the test case as well.

       

      One another thing I'm just thinking is the conditional dependency - for example, JCAMixIn doesn't always need HornetQMixIn, but when we use them together, HornetQMixIn should be initialized first, and uninitialized last. SwitchYardTestKit always initializes the mixins in order of the list specified in @SwitchYardTestCaseConfig annotation, and uninitializes in reverse order of it, so if we put the HornetQMixIn before JCAMixIn then it works fine though. Explicit dependency would be better to avoid user confusion.

       

      What do you think guys? Any advice would be appreciated!

       

      Thanks,

      Tomo