View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.client;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.api.config.MuleProperties;
11  import org.mule.api.transformer.TransformerException;
12  import org.mule.transformer.AbstractTransformer;
13  import org.mule.transformer.types.DataTypeFactory;
14  
15  import java.lang.reflect.Method;
16  
17  /**
18   * <code>AbstractEventTransformer</code> adds support for adding method details to
19   * the result message.
20   */
21  
22  public abstract class AbstractEventTransformer extends AbstractTransformer
23  {
24      protected AbstractEventTransformer()
25      {
26          setReturnDataType(DataTypeFactory.MULE_MESSAGE);
27      }
28  
29      public MuleMessage transform(Object src, Method method) throws TransformerException
30      {
31          MuleMessage message = (MuleMessage)transform(src);
32          message.setOutboundProperty(MuleProperties.MULE_METHOD_PROPERTY, method.getName());
33          return message;
34      }
35  }