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