View Javadoc

1   package com.explosion.expfmodules.monitoring;
2   
3   /*
4    * =============================================================================
5    * 
6    * Copyright 2004 Stephen Cowx
7    * 
8    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
9    * use this file except in compliance with the License. You may obtain a copy of
10   * the License at
11   * 
12   * http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   * 
20   * =============================================================================
21   */
22  
23  import org.apache.log4j.LogManager;
24  import org.apache.log4j.Logger;
25  
26  import com.explosion.utilities.exception.ExceptionManagerFactory;
27  import com.explosion.utilities.process.StackableSimpleProcess;
28  import com.explosion.utilities.process.threads.Updateable;
29  
30  /***
31   * @author Stephen Cowx Date created:@14-Feb-2003
32   */
33  public class SystemMonitoringProcess extends StackableSimpleProcess
34  {
35  
36      private static Logger log = LogManager.getLogger(SystemMonitoringProcess.class);
37      private long interval = 1000;
38  
39      /***
40       * Constructor for SystemMonitoringProcess.
41       */
42      public SystemMonitoringProcess(Updateable updateable)
43      {
44          super(updateable, null);
45          this.setIsUserProcess(true);
46      }
47  
48      public void process()
49      {
50          try
51          {
52              while (!this.isStopped())
53              {
54                  this.setPercentComplete(0);
55                  this.setStatusText("Monitoring system");
56                  getUpdateable().update(null);
57                  Thread.sleep(interval);
58              }
59          } catch (Exception e)
60          {
61              ExceptionManagerFactory.getExceptionManager().manageException(e, null);
62              setStatusText("Monitoring aborted");
63              setPercentComplete(100);
64          }
65      }
66  }