1
2
3
4
5
6
7
8
9
10
11 package org.mule.processor;
12
13 import org.mule.DefaultMuleEvent;
14 import org.mule.api.MuleEvent;
15 import org.mule.api.MuleException;
16 import org.mule.api.endpoint.OutboundEndpoint;
17 import org.mule.api.processor.InterceptingMessageProcessor;
18 import org.mule.api.processor.MessageProcessor;
19 import org.mule.util.ObjectUtils;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24
25
26
27
28
29 public abstract class AbstractInterceptingMessageProcessor implements InterceptingMessageProcessor
30 {
31 protected Log logger = LogFactory.getLog(getClass());
32
33 public void setListener(MessageProcessor next)
34 {
35 this.next = next;
36 }
37
38 protected MessageProcessor next;
39
40 protected MuleEvent processNext(MuleEvent event) throws MuleException
41 {
42 if (next == null)
43 {
44 return event;
45 }
46 else
47 {
48 if (logger.isTraceEnabled())
49 {
50 logger.trace("Invoking next MessageProcessor: '" + next.getClass().getName() + "' ");
51 }
52
53 if (next instanceof OutboundEndpoint)
54 {
55 event = new DefaultMuleEvent(event.getMessage(), (OutboundEndpoint) next, event.getSession());
56 }
57 return next.process(event);
58 }
59 }
60
61 @Override
62 public String toString()
63 {
64 return ObjectUtils.toString(this);
65 }
66 }