1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.component.simple; |
12 | |
|
13 | |
import org.mule.api.MuleEventContext; |
14 | |
import org.mule.api.component.simple.LogService; |
15 | |
import org.mule.api.lifecycle.Callable; |
16 | |
import org.mule.util.StringMessageUtils; |
17 | |
|
18 | |
import org.apache.commons.logging.Log; |
19 | |
import org.apache.commons.logging.LogFactory; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | 0 | public class LogComponent implements Callable, LogService |
26 | |
{ |
27 | 0 | private static Log logger = LogFactory.getLog(LogComponent.class); |
28 | |
|
29 | |
public Object onCall(MuleEventContext context) throws Exception |
30 | |
{ |
31 | 0 | String contents = context.getMessageAsString(); |
32 | 0 | String msg = "Message received in service: " + context.getFlowConstruct().getName(); |
33 | 0 | msg = StringMessageUtils.getBoilerPlate(msg + ". Content is: '" |
34 | |
+ StringMessageUtils.truncate(contents, 100, true) + "'"); |
35 | 0 | log(msg); |
36 | 0 | return context.getMessage(); |
37 | |
} |
38 | |
|
39 | |
public void log(String message) |
40 | |
{ |
41 | 0 | logger.info(message); |
42 | 0 | } |
43 | |
} |