1 10 11 package org.mule.extras.spring.config; 12 13 import org.mule.impl.endpoint.MuleEndpoint; 14 import org.mule.umo.UMODescriptor; 15 import org.mule.umo.endpoint.UMOEndpoint; 16 import org.mule.umo.manager.UMOAgent; 17 import org.mule.umo.model.UMOModel; 18 import org.mule.umo.provider.UMOConnector; 19 import org.mule.umo.transformer.UMOTransformer; 20 import org.mule.util.MuleObjectHelper; 21 import org.springframework.beans.BeansException; 22 import org.springframework.beans.factory.config.BeanPostProcessor; 23 24 29 30 public class MuleObjectNameProcessor implements BeanPostProcessor 31 { 32 private boolean overwrite = false; 33 34 public Object postProcessBeforeInitialization(Object o, String s) throws BeansException 35 { 36 if (!MuleObjectHelper.class.getName().equals(s)) 37 { 38 if (o instanceof UMOConnector) 39 { 40 if (((UMOConnector)o).getName() == null || overwrite) 41 { 42 ((UMOConnector)o).setName(s); 43 } 44 } 45 else if (o instanceof UMOTransformer) 46 { 47 ((UMOTransformer)o).setName(s); 48 } 49 else if (o instanceof UMOEndpoint) 50 { 51 if ((((UMOEndpoint)o).getName() == null || overwrite) 54 && !MuleEndpoint.class.getName().equals(s)) 55 { 56 ((UMOEndpoint)o).setName(s); 57 } 58 } 59 else if (o instanceof UMODescriptor) 60 { 61 if (((UMODescriptor)o).getName() == null || overwrite) 62 { 63 ((UMODescriptor)o).setName(s); 64 } 65 } 66 else if (o instanceof UMOModel) 67 { 68 if (((UMOModel)o).getName() == null || overwrite) 69 { 70 ((UMOModel)o).setName(s); 71 } 72 } 73 else if (o instanceof UMOAgent) 74 { 75 ((UMOAgent)o).setName(s); 76 } 77 } 78 return o; 79 } 80 81 public Object postProcessAfterInitialization(Object o, String s) throws BeansException 82 { 83 return o; 84 } 85 86 public boolean isOverwrite() 87 { 88 return overwrite; 89 } 90 91 public void setOverwrite(boolean overwrite) 92 { 93 this.overwrite = overwrite; 94 } 95 96 } 97 | Popular Tags |