private static void addRedisService()

in plugin/src/main/groovy/grails/plugins/redis/ast/AbstractMemoizeASTTransformation.groovy [118:144]


    private static void addRedisService(ClassNode cNode,
                                        String propertyName,
                                        Class propertyType = Object.class,
                                        Expression initialValue = null) {
        //def ast = new AstBuilder().buildFromString("Holders?.findApplicationContext()")
        //?.getBean('redisService')")

        FieldNode fieldNode = new FieldNode(
                propertyName,
                ACC_PUBLIC,
                new ClassNode(propertyType),
                new ClassNode(cNode.class),
                initialValue
        )

        def holderExpression = new StaticMethodCallExpression(ClassHelper.make(Holders.class), 'findApplicationContext', null)
        ArgumentListExpression argumentListExpression = new ArgumentListExpression()
        argumentListExpression.addExpression(makeConstantExpression('redisService'))
        def getBeanExpression = new MethodCallExpression(holderExpression, 'getBean', argumentListExpression)
        getBeanExpression.setSafe(true)

        def returnStatement = new ReturnStatement(getBeanExpression)


        def propertyNode = new PropertyNode(fieldNode, ACC_PUBLIC, returnStatement, null)
        cNode.addProperty(propertyNode)
    }