View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.jdiagnose.library;
17  
18  import org.jdiagnose.DiagnosticUnit;
19  import org.jdiagnose.Pingable;
20  
21  /***
22   * Diagnoses an object that implements the Pingable interface
23   *
24   * @see org.jdiagnose.Pingable
25   * @author jmccrindle
26   */
27  public class PingableDiagnostic extends DiagnosticUnit {
28  
29      private Pingable pingable = null;
30  
31      /***
32       * Creates a new DiagnosticUnit. It's name defaults to the FQ class name.
33       */
34      public PingableDiagnostic() {
35      }
36  
37      /***
38       * Create a new DiagnosticUnit with a Fully Qualified Name
39       *
40       * @param name the name of this diagnostic.
41       */
42      public PingableDiagnostic(String name, Pingable pingable) {
43          super(name);
44          this.pingable = pingable;
45      }
46  
47      /***
48       * Creates a new DiagnosticUnit. It's name defaults to the FQ class name.
49       */
50      public PingableDiagnostic(Pingable pingable) {
51          this.pingable = pingable;
52      }
53  
54      public void diagnosePing() throws Throwable {
55          pingable.ping();
56      }
57      
58      public Pingable getPingable() {
59          return pingable;
60      }
61  
62      public void setPingable(Pingable pingable) {
63          this.pingable = pingable;
64      }
65  
66  }