View Javadoc

1   /**
2    * This file Copyright (c) 2013 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.module.exchangesimple.monitor;
35  
36  import info.magnolia.cms.util.MBeanUtil;
37  import info.magnolia.module.ModuleRegistry;
38  import info.magnolia.module.exchangesimple.ExchangeSimpleModule;
39  
40  import java.util.Collection;
41  import java.util.Date;
42  import java.util.Map;
43  
44  import com.google.inject.Inject;
45  
46  /**
47   * Activation monitor which provides useful informations about activation.
48   */
49  public class ActivationMonitor implements ActivationMonitorMBean {
50  
51      private ActivationStorage activationStorage;
52  
53      @Inject
54      public ActivationMonitor(ModuleRegistry moduleRegistry) {
55          MBeanUtil.registerMBean("ActivationMonitor", this);
56          this.activationStorage = moduleRegistry.getModuleInstance(ExchangeSimpleModule.class).getActivationLogStorage();
57      }
58  
59      @Override
60      public void logActivation(String path, String user, String workspaceName, String subscriber, boolean deactivation, boolean success) {
61          this.activationStorage.logActivation(path, user, workspaceName, subscriber, deactivation, success);
62      }
63  
64      @Override
65      public int getActivations() {
66          return this.activationStorage.getActivations();
67      }
68  
69      @Override
70      public int getDeactivations() {
71          return this.activationStorage.getDeactivations();
72      }
73  
74      @Override
75      public int getActivationErrors() {
76          return this.activationStorage.getActivationErrors();
77      }
78  
79      @Override
80      public long getSizeOfActivatedContent() {
81          return this.activationStorage.getSizeOfActivatedContent();
82      }
83  
84      @Override
85      public Collection<ActivationLogEntry> getActivationLog() {
86          return this.activationStorage.getActivationLog();
87      }
88  
89      @Override
90      public Collection<ActivationLogEntry> getActivationsMadeByUser(String user) {
91          return this.activationStorage.getActivationsMadeByUser(user);
92      }
93  
94      @Override
95      public Map<String, Integer> getActivationsPerWorkspace() {
96          return this.activationStorage.getActivationsPerWorkspace();
97      }
98  
99      @Override
100     public Map<String, ResponseTimeEntry> getSubscriberResponseTimes() {
101         return this.activationStorage.getSubscriberResponseTimes();
102     }
103 
104     @Override
105     public void logError(String path, String user, String workspaceName, String subscriber, Throwable t, boolean deactivation) {
106         this.activationStorage.logError(path, user, workspaceName, subscriber, t, deactivation);
107     }
108 
109     @Override
110     public void setSubscriberResponseTime(String subscriber, long time) {
111         this.activationStorage.setSubscriberResponseTime(subscriber, time);
112     }
113 
114     @Override
115     public Collection<ActivationLogEntry> getActivationErrorLog() {
116         return this.activationStorage.getActivationErrorLog();
117     }
118 
119     @Override
120     public int getCommitedTransactions() {
121         return this.activationStorage.getCommitedTransactions();
122     }
123 
124     @Override
125     public int getRollbackedTransactions() {
126         return this.activationStorage.getRollbackedTransactions();
127     }
128 
129     @Override
130     public void addSizeOfActivatedContent(long size) {
131         this.activationStorage.addSizeOfActivatedContent(size);
132     }
133 
134     @Override
135     public void addActivationTime(long time) {
136         this.activationStorage.addActivationTime(time);
137     }
138 
139     @Override
140     public long getActivationTime() {
141         return this.activationStorage.getActivationTime();
142     }
143 
144     @Override
145     public Date getLastRestartDate() {
146         return this.activationStorage.getLastRestartDate();
147     }
148 
149     @Override
150     public void addCommitedTransaction() {
151         this.activationStorage.addCommitedTransaction();
152     }
153 
154     @Override
155     public void addRollbackedTransaction() {
156         this.activationStorage.addRollbackedTransaction();
157     }
158 }