KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > config > converters > TransactionFactoryConverter


1 /*
2  * $Id: TransactionFactoryConverter.java 3831 2006-11-07 22:29:59Z aperepel $
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 MuleSource MPL
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.apache.commons.beanutils.ConversionException;
14 import org.apache.commons.beanutils.Converter;
15 import org.mule.umo.UMOTransactionFactory;
16 import org.mule.util.ClassUtils;
17
18 /**
19  * <code>TransactionFactoryConverter</code> TODO
20  */

21 public class TransactionFactoryConverter implements Converter
22 {
23     // --------------------------------------------------------- Public Methods
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 org.apache.commons.beanutils.ConversionException if conversion cannot
32      * be performed successfully
33      */

34     public Object JavaDoc convert(Class JavaDoc type, Object JavaDoc value)
35     {
36         if (value == null)
37         {
38             throw new ConversionException("No value specified");
39         }
40         if (value instanceof UMOTransactionFactory)
41         {
42             return (value);
43         }
44         try
45         {
46             Object JavaDoc factory = ClassUtils.loadClass(value.toString(), getClass()).newInstance();
47             return factory;
48         }
49         catch (Exception JavaDoc e)
50         {
51             throw new ConversionException(e);
52         }
53     }
54 }
55
Popular Tags