Grails 3.3.2 extending "NavigableMapConfig" and overriding "get" method

61 Views Asked by At

I have a scienario like to get dynamic config properties whenever user try to access properties from "Holders", for eg: "Holder.config.testPropertyKey.userSpecific".

I debugged this and it goes to method "get" of "NavigableMapConfig" class which implements "NavigableMap".

I tried to extend the "NavigableMapConfig" class to ovveride the "get" method and no luck.

If any one knows how to do this or need suggestion if i am in wrong path to achieve this.

1

There are 1 best solutions below

0
user3515080 On BEST ANSWER

I found the solution for this:

In "BootStrap.groovy" file i overriden the "getConfig" for "Holders" method by the help of "Metaprogramming" as bellow:

    ExpandoMetaClass.enableGlobally();
    Holders.metaClass.static.getConfig = {
        <you code goes here...>
    }