01: /*
02:
03: Derby - Class org.apache.derby.iapi.services.diag.Diagnosticable
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of 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,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.iapi.services.diag;
23:
24: import org.apache.derby.iapi.error.StandardException;
25:
26: import java.util.Properties;
27:
28: /**
29:
30: The Diagnosticable class implements the Diagnostics protocol, and can
31: be used as the parent class for all other Diagnosticable objects.
32:
33: **/
34:
35: public interface Diagnosticable {
36: /*
37: ** Methods of Diagnosticable
38: */
39: public void init(Object obj);
40:
41: /**
42: * Default implementation of diagnostic on the object.
43: * <p>
44: * This routine returns a string with whatever diagnostic information
45: * you would like to provide about this associated object passed in
46: * the init() call.
47: * <p>
48: * This routine should be overriden by a real implementation of the
49: * diagnostic information you would like to provide.
50: * <p>
51: *
52: * @return A string with diagnostic information about the object.
53: *
54: * @exception StandardException Standard cloudscape exception policy
55: **/
56: public String diag() throws StandardException;
57:
58: /**
59: * Default implementation of detail diagnostic on the object.
60: * <p>
61: * This interface provides a way for an object to pass back pieces of
62: * information as requested by the caller. The information is passed
63: * back and forth through the properties argument. It is expected that
64: * the caller knows what kind of information to ask for, and correctly
65: * handles the situation when the diagnostic object can't provide the
66: * information.
67: * <p>
68: * As an example assume an object TABLE exists, and that we have created
69: * an object D_TABLE that knows how to return the number of pages in the
70: * TABLE object. The code to get that information out would looks something
71: * like the following:
72: * <p>
73: * print_num_pages(Object table)
74: * {
75: * Properties prop = new Properties();
76: * prop.put(Page.DIAG_NUM_PAGES, "");
77: *
78: * DiagnosticUtil.findDiagnostic(table).diag_detail(prop);
79: *
80: * System.out.println(
81: * "number of pages = " + prop.getProperty(Page.DIAG_NUM_PAGES));
82: * }
83: * <p>
84: * This routine should be overriden if there is detail diagnostics to
85: * be provided by a real implementation.
86: * <p>
87: *
88: * @exception StandardException Standard cloudscape exception policy
89: **/
90: public void diag_detail(Properties prop) throws StandardException;
91: }
|