Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EndpointURIConverter |
|
| 8.0;8 |
1 | /* | |
2 | * $Id: EndpointURIConverter.java 7976 2007-08-21 14:26:13Z dirk.olmes $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.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.converters; | |
12 | ||
13 | import org.mule.MuleManager; | |
14 | import org.mule.impl.endpoint.MuleEndpointURI; | |
15 | import org.mule.umo.endpoint.UMOEndpointURI; | |
16 | import org.mule.umo.manager.UMOManager; | |
17 | import org.mule.util.XMLEntityCodec; | |
18 | ||
19 | import org.apache.commons.beanutils.ConversionException; | |
20 | import org.apache.commons.beanutils.Converter; | |
21 | ||
22 | /** | |
23 | * <code>EndpointURIConverter</code> TODO | |
24 | */ | |
25 | 0 | public class EndpointURIConverter implements Converter |
26 | { | |
27 | ||
28 | /** | |
29 | * Convert the specified input object into an output object of the specified | |
30 | * type. | |
31 | * | |
32 | * @param type Data type to which this value should be converted | |
33 | * @param value The input value to be converted | |
34 | * @throws org.apache.commons.beanutils.ConversionException if conversion cannot | |
35 | * be performed successfully | |
36 | */ | |
37 | public Object convert(Class type, Object value) | |
38 | { | |
39 | 0 | if (value == null) |
40 | { | |
41 | 0 | throw new ConversionException("No value specified"); |
42 | } | |
43 | ||
44 | 0 | if (value instanceof UMOEndpointURI) |
45 | { | |
46 | 0 | return value; |
47 | } | |
48 | ||
49 | try | |
50 | { | |
51 | 0 | UMOManager manager = MuleManager.getInstance(); |
52 | 0 | String endpoint = manager.lookupEndpointIdentifier(value.toString(), value.toString()); |
53 | 0 | endpoint = XMLEntityCodec.decodeString(endpoint); |
54 | 0 | return new MuleEndpointURI(endpoint); |
55 | } | |
56 | 0 | catch (Exception e) |
57 | { | |
58 | 0 | throw new ConversionException(e); |
59 | } | |
60 | } | |
61 | ||
62 | } |