Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ConnectorConverter |
|
| 10.0;10 |
1 | /* | |
2 | * $Id: ConnectorConverter.java 7963 2007-08-21 08:53:15Z 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.umo.provider.UMOConnector; | |
15 | ||
16 | import org.apache.commons.beanutils.ConversionException; | |
17 | import org.apache.commons.beanutils.Converter; | |
18 | ||
19 | /** | |
20 | * <code>ConnectorConverter</code> TODO | |
21 | */ | |
22 | 0 | public class ConnectorConverter implements Converter |
23 | { | |
24 | ||
25 | // --------------------------------------------------------- Public Methods | |
26 | ||
27 | /** | |
28 | * Convert the specified input object into an output object of the specified | |
29 | * type. | |
30 | * | |
31 | * @param type Data type to which this value should be converted | |
32 | * @param value The input value to be converted | |
33 | * @throws ConversionException if conversion cannot be performed successfully | |
34 | */ | |
35 | public Object convert(Class type, Object value) | |
36 | { | |
37 | 0 | if (value == null) |
38 | { | |
39 | 0 | throw new ConversionException("No value specified"); |
40 | } | |
41 | 0 | if (value instanceof UMOConnector) |
42 | { | |
43 | 0 | return (value); |
44 | } | |
45 | try | |
46 | { | |
47 | 0 | UMOConnector c = MuleManager.getInstance().lookupConnector(value.toString()); |
48 | 0 | if (c == null) |
49 | { | |
50 | 0 | throw new ConversionException("UMOConnector: " + value.toString() |
51 | + " has not been registered with Mule"); | |
52 | } | |
53 | 0 | return c; |
54 | } | |
55 | 0 | catch (Exception e) |
56 | { | |
57 | 0 | throw new ConversionException(e); |
58 | } | |
59 | } | |
60 | } |