Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AutoTransformer |
|
| 2.0;2 |
1 | /* | |
2 | * $Id: AutoTransformer.java 11604 2008-04-18 22:39:51Z rossmason $ | |
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 | package org.mule.transformer.simple; | |
11 | ||
12 | import org.mule.transformer.AbstractMessageAwareTransformer; | |
13 | import org.mule.api.MuleMessage; | |
14 | import org.mule.api.lifecycle.InitialisationException; | |
15 | import org.mule.api.transformer.TransformerException; | |
16 | import org.mule.config.i18n.CoreMessages; | |
17 | ||
18 | /** | |
19 | * A transformer that uses the transform discovery mechanism to convert the message payload. This transformer | |
20 | * works much better when transforming custom object types rather that java types since there is less chance for | |
21 | * ambiguity. | |
22 | * If an exact match cannot be made an execption will be thrown. | |
23 | */ | |
24 | 0 | public class AutoTransformer extends AbstractMessageAwareTransformer |
25 | { | |
26 | /** | |
27 | * Template method where deriving classes can do any initialisation after the | |
28 | * properties have been set on this transformer | |
29 | * | |
30 | * @throws org.mule.api.lifecycle.InitialisationException | |
31 | * | |
32 | */ | |
33 | //@Override | |
34 | public void initialise() throws InitialisationException | |
35 | { | |
36 | 0 | super.initialise(); |
37 | 0 | if(getReturnClass().equals(Object.class)) |
38 | { | |
39 | 0 | throw new InitialisationException(CoreMessages.transformerInvalidReturnType(Object.class, getName()), this); |
40 | } | |
41 | 0 | } |
42 | ||
43 | public Object transform(MuleMessage message, String outputEncoding) throws TransformerException | |
44 | { | |
45 | 0 | return message.getPayload(getReturnClass()); |
46 | } | |
47 | } |