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