1
2
3
4
5
6
7 package org.mule.construct.processor;
8
9 import org.mule.api.MuleEvent;
10 import org.mule.api.MuleException;
11 import org.mule.api.construct.FlowConstruct;
12 import org.mule.api.construct.FlowConstructAware;
13 import org.mule.api.processor.MessageProcessor;
14 import org.mule.util.ObjectUtils;
15
16 public class FlowConstructStatisticsMessageProcessor implements MessageProcessor, FlowConstructAware
17 {
18 protected FlowConstruct flowConstruct;
19
20 public MuleEvent process(MuleEvent event) throws MuleException
21 {
22 if (flowConstruct.getStatistics().isEnabled())
23 {
24 if (event.getEndpoint().getExchangePattern().hasResponse())
25 {
26 flowConstruct.getStatistics().incReceivedEventSync();
27 }
28 else
29 {
30 flowConstruct.getStatistics().incReceivedEventASync();
31 }
32 }
33
34 return event;
35 }
36
37 public void setFlowConstruct(FlowConstruct flowConstruct)
38 {
39 this.flowConstruct = flowConstruct;
40 }
41
42 @Override
43 public String toString()
44 {
45 return ObjectUtils.toString(this);
46 }
47 }