Coverage Report - org.mule.config.spring.ExpressionEvaluatorPostProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
ExpressionEvaluatorPostProcessor
0%
0/12
0%
0/6
2.333
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.config.spring;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.expression.ExpressionEvaluator;
 11  
 import org.mule.api.expression.ExpressionManager;
 12  
 
 13  
 import org.springframework.beans.BeansException;
 14  
 import org.springframework.beans.factory.config.BeanPostProcessor;
 15  
 
 16  
 /**
 17  
  * Registers custom declarative expression evaluators configured via Spring config.
 18  
  *
 19  
  * @see ExpressionEvaluator
 20  
  */
 21  
 public class ExpressionEvaluatorPostProcessor implements BeanPostProcessor
 22  
 {
 23  
     private MuleContext muleContext;
 24  
 
 25  
     public ExpressionEvaluatorPostProcessor(MuleContext muleContext)
 26  0
     {
 27  0
         this.muleContext = muleContext;
 28  0
     }
 29  
 
 30  
     public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
 31  
     {
 32  0
         if (muleContext == null)
 33  
         {
 34  0
             return bean;
 35  
         }
 36  
 
 37  0
         if (bean instanceof ExpressionEvaluator)
 38  
         {
 39  0
             ExpressionEvaluator ee = (ExpressionEvaluator) bean;
 40  
 
 41  0
             final ExpressionManager expressionManager = muleContext.getExpressionManager();
 42  0
             if (!expressionManager.isEvaluatorRegistered(ee.getName()))
 43  
             {
 44  0
                 expressionManager.registerEvaluator(ee);
 45  
             }
 46  
         }
 47  0
         return bean;
 48  
     }
 49  
 
 50  
     public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
 51  
     {
 52  0
         return bean;
 53  
     }
 54  
 
 55  
 }