1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.endpoint.inbound; |
12 | |
|
13 | |
import org.mule.api.MuleEvent; |
14 | |
import org.mule.api.MuleException; |
15 | |
import org.mule.api.MuleMessage; |
16 | |
import org.mule.api.endpoint.InboundEndpoint; |
17 | |
import org.mule.api.processor.MessageProcessor; |
18 | |
import org.mule.util.ObjectUtils; |
19 | |
import org.mule.util.StringMessageUtils; |
20 | |
|
21 | |
import org.apache.commons.logging.Log; |
22 | |
import org.apache.commons.logging.LogFactory; |
23 | |
|
24 | |
public class InboundLoggingMessageProcessor implements MessageProcessor |
25 | |
{ |
26 | 0 | protected final transient Log logger = LogFactory.getLog(getClass()); |
27 | |
protected InboundEndpoint endpoint; |
28 | |
|
29 | |
public InboundLoggingMessageProcessor(InboundEndpoint endpoint) |
30 | 0 | { |
31 | 0 | this.endpoint = endpoint; |
32 | 0 | } |
33 | |
|
34 | |
public MuleEvent process(MuleEvent event) throws MuleException |
35 | |
{ |
36 | 0 | MuleMessage message = event.getMessage(); |
37 | 0 | if (logger.isDebugEnabled()) |
38 | |
{ |
39 | 0 | logger.debug("Message Received on: " + endpoint.getEndpointURI()); |
40 | |
} |
41 | 0 | if (logger.isTraceEnabled()) |
42 | |
{ |
43 | |
try |
44 | |
{ |
45 | 0 | logger.trace("Message Payload: \n" |
46 | |
+ StringMessageUtils.truncate(StringMessageUtils.toString(message.getPayload()), |
47 | |
200, false)); |
48 | 0 | logger.trace("Message detail: \n" + StringMessageUtils.headersToString(message)); |
49 | |
} |
50 | 0 | catch (Exception e) |
51 | |
{ |
52 | |
|
53 | 0 | } |
54 | |
} |
55 | |
|
56 | 0 | return event; |
57 | |
} |
58 | |
|
59 | |
@Override |
60 | |
public String toString() |
61 | |
{ |
62 | 0 | return ObjectUtils.toString(this); |
63 | |
} |
64 | |
} |