View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.management.mbean;
8   
9   import org.apache.commons.logging.Log;
10  import org.apache.commons.logging.LogFactory;
11  import org.mule.management.stats.FlowConstructStatistics;
12  
13  import javax.management.MBeanRegistration;
14  import javax.management.MBeanServer;
15  import javax.management.ObjectName;
16  
17  /**
18   * A concrete class that holds management information for a Mule managed flow.
19   */
20  public class FlowConstructStats implements FlowConstructStatsMBean, MBeanRegistration
21  {
22      private final FlowConstructStatistics statistics;
23  
24  
25      protected MBeanServer server;
26  
27      protected ObjectName name;
28  
29      /**
30       * logger used by this class
31       */
32      private static Log LOGGER = LogFactory.getLog(FlowConstructStats.class);
33  
34      public FlowConstructStats(FlowConstructStatistics statistics)
35      {
36          this.statistics = statistics;
37      }
38  
39      public long getAverageProcessingTime()
40      {
41          return statistics.getAverageProcessingTime();
42      }
43  
44      public long getProcessedEvents()
45      {
46          return statistics.getProcessedEvents();
47      }
48  
49      public long getMaxProcessingTime()
50      {
51          return statistics.getMaxProcessingTime();
52      }
53  
54      public long getMinProcessingTime()
55      {
56          return statistics.getMinProcessingTime();
57      }
58  
59      public long getTotalProcessingTime()
60      {
61          return statistics.getTotalProcessingTime();
62      }
63  
64      public void clearStatistics()
65      {
66          statistics.clear();
67      }
68  
69      public long getAsyncEventsReceived()
70      {
71          return statistics.getAsyncEventsReceived();
72      }
73  
74      public long getSyncEventsReceived()
75      {
76          return statistics.getSyncEventsReceived();
77      }
78  
79      public long getTotalEventsReceived()
80      {
81          return statistics.getTotalEventsReceived();
82      }
83  
84      public long getExecutionErrors()
85      {
86          return statistics.getExecutionErrors();
87      }
88  
89      public long getFatalErrors()
90      {
91          return statistics.getFatalErrors();
92      }
93  
94      public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
95      {
96          this.server = server;
97          this.name = name;
98          return name;
99      }
100 
101     public void postRegister(Boolean registrationDone)
102     {
103         // nothing to do
104     }
105 
106     public void preDeregister() throws Exception
107     {
108         // nothing to do
109     }
110 
111     public void postDeregister()
112     {
113         // nothing to do
114     }
115 }