1 /*
2 * $Id: TransformerConverter.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.umo.transformer.UMOTransformer;
14
15 import org.apache.commons.beanutils.ConversionException;
16 import org.apache.commons.beanutils.Converter;
17
18 /**
19 * <code>TransformerConverter</code> will obtain a transformer name and convert it
20 * to a transformer instance by looking up the transformer from the
21 * <code>MuleManager</code>.
22 */
23 public class TransformerConverter implements Converter
24 {
25 /**
26 * Convert the specified input object into an output object of the specified
27 * type.
28 *
29 * @param type Data type to which this value should be converted
30 * @param value The input value to be converted
31 * @throws ConversionException if conversion cannot be performed successfully
32 */
33 public Object convert(Class type, Object value)
34 {
35 if (value == null)
36 {
37 throw new ConversionException("No value specified");
38 }
39 if (value instanceof UMOTransformer)
40 {
41 return value;
42 }
43 return null;
44 }
45 }