Coverage Report - org.mule.config.spring.processors.MuleObjectNameProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleObjectNameProcessor
0%
0/21
0%
0/26
3.25
 
 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.processors;
 8  
 
 9  
 import org.mule.api.agent.Agent;
 10  
 import org.mule.api.model.Model;
 11  
 import org.mule.api.service.Service;
 12  
 import org.mule.api.transformer.Transformer;
 13  
 import org.mule.api.transport.Connector;
 14  
 
 15  
 import org.springframework.beans.BeansException;
 16  
 import org.springframework.beans.factory.config.BeanPostProcessor;
 17  
 
 18  
 /**
 19  
  * <code>MuleObjectNameProcessor</code> is used to set spring ids to Mule object
 20  
  * names so the the bean id and name property on the object don't both have to be
 21  
  * set.
 22  
  */
 23  
 
 24  0
 public class MuleObjectNameProcessor implements BeanPostProcessor
 25  
 {
 26  0
     private boolean overwrite = false;
 27  
 
 28  
     public Object postProcessBeforeInitialization(Object o, String s) throws BeansException
 29  
     {
 30  
 
 31  0
         if (o instanceof Connector)
 32  
         {
 33  0
             if (((Connector)o).getName() == null || overwrite)
 34  
             {
 35  0
                 ((Connector)o).setName(s);
 36  
             }
 37  
         }
 38  0
         else if (o instanceof Transformer)
 39  
         {
 40  0
             if (((Transformer)o).getName() == null || overwrite)
 41  
             {
 42  0
                ((Transformer)o).setName(s);
 43  
             }
 44  
         }
 45  0
         else if (o instanceof Service)
 46  
         {
 47  0
             if (((Service)o).getName() == null || overwrite)
 48  
             {
 49  0
                 ((Service)o).setName(s);
 50  
             }
 51  
         }
 52  0
         else if (o instanceof Model)
 53  
         {
 54  0
             if (((Model)o).getName() == null || overwrite)
 55  
             {
 56  0
                 ((Model)o).setName(s);
 57  
             }
 58  
         }
 59  0
         else if (o instanceof Agent)
 60  
         {
 61  0
             ((Agent)o).setName(s);
 62  
         }
 63  0
         return o;
 64  
     }
 65  
 
 66  
     public Object postProcessAfterInitialization(Object o, String s) throws BeansException
 67  
     {
 68  0
         return o;
 69  
     }
 70  
 
 71  
     public boolean isOverwrite()
 72  
     {
 73  0
         return overwrite;
 74  
     }
 75  
 
 76  
     public void setOverwrite(boolean overwrite)
 77  
     {
 78  0
         this.overwrite = overwrite;
 79  0
     }
 80  
 
 81  
 }