1 10 11 package org.mule.config.converters; 12 13 import org.apache.commons.beanutils.ConversionException; 14 import org.apache.commons.beanutils.Converter; 15 import org.mule.MuleManager; 16 import org.mule.impl.endpoint.MuleEndpoint; 17 import org.mule.impl.endpoint.MuleEndpointURI; 18 import org.mule.umo.endpoint.UMOEndpoint; 19 import org.mule.umo.endpoint.UMOEndpointURI; 20 import org.mule.umo.endpoint.UMOImmutableEndpoint; 21 import org.mule.umo.manager.UMOManager; 22 23 26 public class EndpointConverter implements Converter 27 { 28 29 31 39 public Object convert(Class type, Object value) 40 { 41 UMOManager manager = MuleManager.getInstance(); 42 if (value == null) 43 { 44 throw new ConversionException("No value specified"); 45 } 46 if (value instanceof UMOEndpoint) 47 { 48 return (value); 49 } 50 try 51 { 52 String endpointString = manager.lookupEndpointIdentifier(value.toString(), value.toString()); 53 UMOImmutableEndpoint globalEndpoint = (UMOImmutableEndpoint)manager.getEndpoints().get( 54 endpointString); 55 if (globalEndpoint == null) 56 { 57 UMOEndpointURI endpointUri = new MuleEndpointURI(endpointString); 58 if (!endpointString.equals(value.toString())) 59 { 60 endpointUri.setEndpointName(value.toString()); 61 } 62 UMOEndpoint endpoint = MuleEndpoint.createEndpointFromUri(endpointUri, null); 63 if (endpointUri.getEndpointName() == null && !endpointString.equals(value.toString())) 67 { 68 endpoint.setName(value.toString()); 69 } 70 return endpoint; 71 } 72 else 73 { 74 return null; 79 } 80 } 81 catch (Exception e) 82 { 83 throw new ConversionException(e); 84 } 85 } 86 } 87 | Popular Tags |