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  
  * $Id: MuleObjectNameProcessor.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.config.spring.processors;
 12  
 
 13  
 import org.mule.api.agent.Agent;
 14  
 import org.mule.api.model.Model;
 15  
 import org.mule.api.service.Service;
 16  
 import org.mule.api.transformer.Transformer;
 17  
 import org.mule.api.transport.Connector;
 18  
 
 19  
 import org.springframework.beans.BeansException;
 20  
 import org.springframework.beans.factory.config.BeanPostProcessor;
 21  
 
 22  
 /**
 23  
  * <code>MuleObjectNameProcessor</code> is used to set spring ids to Mule object
 24  
  * names so the the bean id and name property on the object don't both have to be
 25  
  * set.
 26  
  */
 27  
 
 28  0
 public class MuleObjectNameProcessor implements BeanPostProcessor
 29  
 {
 30  0
     private boolean overwrite = false;
 31  
 
 32  
     public Object postProcessBeforeInitialization(Object o, String s) throws BeansException
 33  
     {
 34  
 
 35  0
         if (o instanceof Connector)
 36  
         {
 37  0
             if (((Connector)o).getName() == null || overwrite)
 38  
             {
 39  0
                 ((Connector)o).setName(s);
 40  
             }
 41  
         }
 42  0
         else if (o instanceof Transformer)
 43  
         {
 44  0
             if (((Transformer)o).getName() == null || overwrite)
 45  
             {
 46  0
                ((Transformer)o).setName(s);
 47  
             }
 48  
         }
 49  0
         else if (o instanceof Service)
 50  
         {
 51  0
             if (((Service)o).getName() == null || overwrite)
 52  
             {
 53  0
                 ((Service)o).setName(s);
 54  
             }
 55  
         }
 56  0
         else if (o instanceof Model)
 57  
         {
 58  0
             if (((Model)o).getName() == null || overwrite)
 59  
             {
 60  0
                 ((Model)o).setName(s);
 61  
             }
 62  
         }
 63  0
         else if (o instanceof Agent)
 64  
         {
 65  0
             ((Agent)o).setName(s);
 66  
         }
 67  0
         return o;
 68  
     }
 69  
 
 70  
     public Object postProcessAfterInitialization(Object o, String s) throws BeansException
 71  
     {
 72  0
         return o;
 73  
     }
 74  
 
 75  
     public boolean isOverwrite()
 76  
     {
 77  0
         return overwrite;
 78  
     }
 79  
 
 80  
     public void setOverwrite(boolean overwrite)
 81  
     {
 82  0
         this.overwrite = overwrite;
 83  0
     }
 84  
 
 85  
 }