KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > CallbackUtil


1 package org.enhydra.shark;
2
3 import java.util.Properties JavaDoc;
4 import org.enhydra.shark.SharkEngineManager;
5 import org.enhydra.shark.api.RootException;
6 import org.enhydra.shark.api.internal.working.CallbackUtilities;
7
8 /**
9  * Implementation of Callback Utilities interface.
10  *
11  * @author Sasa Bojanic
12  * @author Tanja Jovanovic
13  */

14 public class CallbackUtil implements CallbackUtilities {
15
16    private Properties JavaDoc properties;
17
18    protected CallbackUtil () {
19    }
20
21    //////////////////////////////////////////////////////////////////
22
// Callback API implementation
23
//////////////////////////////////////////////////////////////////
24

25    /**
26     * Returns value of property <i>propertyName</i> used for Shark configuration.
27     *
28     * @param name property name.
29     * @return Value of property <i>name</i>.
30     *
31     */

32    public String JavaDoc getProperty (String JavaDoc name) {
33       return properties.getProperty(name);
34    }
35
36    /**
37     * Returns value of property <i>name</i> used for Shark configuration.
38     * If doesn't exist the default value is returned.
39     *
40     * @param name property name.
41     * @param defaultValue default property value.
42     * @return Value of property <i>name</i> or default value.
43     *
44     */

45    public String JavaDoc getProperty (String JavaDoc name,String JavaDoc defaultValue) {
46       return properties.getProperty(name,defaultValue);
47    }
48
49    /**
50     * Returns all properties used for Shark configuration.
51     *
52     * @return Properties object.
53     *
54     */

55    public Properties JavaDoc getProperties () {
56       return properties;
57    }
58
59    /**
60     * Sets properties for Shark configuration.
61     *
62     * @param props Properties object.
63     *
64     */

65    public void setProperties (Properties JavaDoc props) {
66       this.properties=props;
67    }
68
69    /**
70     * Log a message object with the <i>ERROR</i> Level.
71     *
72     * @param msg the message to log.
73     *
74     */

75    public void error (String JavaDoc msg) {
76       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
77          try {
78            SharkEngineManager.getInstance().getLoggingManager().error(msg);
79          }
80          catch (Exception JavaDoc e){
81            System.err.println("Error in logging - errMsg="+e.getMessage());
82          }
83       }
84    }
85
86    /**
87     * Log a message object with the <i>ERROR</i> Level.
88     *
89     * @param msg the message to log.
90     * @param ex the exception to log, including its stack trace.
91     *
92     */

93    public void error (String JavaDoc msg,RootException ex) {
94      if (SharkEngineManager.getInstance().getLoggingManager() != null) {
95         try {
96           SharkEngineManager.getInstance().getLoggingManager().error(msg, ex);
97         }
98         catch (Exception JavaDoc e){
99           System.err.println("Error in logging - errMsg="+e.getMessage());
100         }
101      }
102    }
103
104    /**
105     * Log a message object with the <i>ERROR</i> Level.
106     *
107     * @param channel the log channel to be used for logging.
108     * @param msg the message to log.
109     *
110     */

111    public void error (String JavaDoc channel,String JavaDoc msg) {
112       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
113          try {
114            SharkEngineManager.getInstance().getLoggingManager().error(channel, msg);
115          }
116          catch (Exception JavaDoc e){
117            System.err.println("Error in logging - errMsg="+e.getMessage());
118          }
119       }
120    }
121
122    /**
123     * Log a message object with the <i>ERROR</i> Level.
124     *
125     * @param channel the log channel to be used for logging.
126     * @param msg the message to log.
127     * @param ex the exception to log, including its stack trace.
128     *
129     */

130    public void error (String JavaDoc channel,String JavaDoc msg,RootException ex) {
131       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
132          try {
133            SharkEngineManager.getInstance().getLoggingManager().error(channel, msg, ex);
134          }
135          catch (Exception JavaDoc e){
136            System.err.println("Error in logging - errMsg="+e.getMessage());
137          }
138       }
139    }
140
141    /**
142     * Log a message object with the <i>WARN</i> Level.
143     *
144     * @param msg the message to log.
145     *
146     */

147    public void warn (String JavaDoc msg) {
148       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
149          try {
150            SharkEngineManager.getInstance().getLoggingManager().warn(msg);
151          }
152          catch (Exception JavaDoc e){
153            System.err.println("Error in logging - errMsg="+e.getMessage());
154          }
155       }
156    }
157
158    /**
159     * Log a message object with the <i>WARN</i> Level.
160     *
161     * @param msg the message to log.
162     * @param ex the exception to log, including its stack trace.
163     *
164     */

165    public void warn (String JavaDoc msg,RootException ex) {
166       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
167          try {
168            SharkEngineManager.getInstance().getLoggingManager().warn(msg, ex);
169          }
170          catch (Exception JavaDoc e){
171            System.err.println("Error in logging - errMsg="+e.getMessage());
172          }
173       }
174    }
175
176    /**
177     * Log a message object with the <i>WARN</i> Level.
178     *
179     * @param channel the log channel to be used for logging.
180     * @param msg the message to log.
181     *
182     */

183    public void warn (String JavaDoc channel,String JavaDoc msg) {
184       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
185          try {
186            SharkEngineManager.getInstance().getLoggingManager().warn(channel, msg);
187          }
188          catch (Exception JavaDoc e){
189            System.err.println("Error in logging - errMsg="+e.getMessage());
190          }
191       }
192    }
193
194    /**
195     * Log a message object with the <i>WARN</i> Level.
196     *
197     * @param channel the log channel to be used for logging.
198     * @param msg the message to log.
199     * @param ex the exception to log, including its stack trace.
200     *
201     */

202    public void warn (String JavaDoc channel,String JavaDoc msg,RootException ex) {
203       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
204          try {
205            SharkEngineManager.getInstance().getLoggingManager().warn(channel, msg, ex);
206          }
207          catch (Exception JavaDoc e){
208            System.err.println("Error in logging - errMsg="+e.getMessage());
209          }
210       }
211    }
212
213     /**
214     * Log a message object with the <i>INFO</i> Level.
215     *
216     * @param msg the message to log.
217     *
218     */

219    public void info (String JavaDoc msg) {
220       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
221          try {
222            SharkEngineManager.getInstance().getLoggingManager().info(msg);
223          }
224          catch (Exception JavaDoc e){
225            System.err.println("Error in logging - errMsg="+e.getMessage());
226          }
227       }
228    }
229
230   /**
231     * Log a message object with the <i>INFO</i> Level.
232     *
233     * @param msg the message to log.
234     * @param ex the exception to log, including its stack trace.
235     *
236     */

237   public void info (String JavaDoc msg,RootException ex) {
238       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
239          try {
240            SharkEngineManager.getInstance().getLoggingManager().info(msg, ex);
241          }
242          catch (Exception JavaDoc e){
243            System.err.println("Error in logging - errMsg="+e.getMessage());
244          }
245       }
246    }
247
248    /**
249     * Log a message object with the <i>INFO</i> Level.
250     *
251     * @param channel the log channel to be used for logging.
252     * @param msg the message to log.
253     *
254     */

255    public void info (String JavaDoc channel,String JavaDoc msg) {
256       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
257          try {
258            SharkEngineManager.getInstance().getLoggingManager().info(channel, msg);
259          }
260          catch (Exception JavaDoc e){
261            System.err.println("Error in logging - errMsg="+e.getMessage());
262          }
263       }
264    }
265
266    /**
267     * Log a message object with the <i>INFO</i> Level.
268     *
269     * @param channel the log channel to be used for logging.
270     * @param msg the message to log.
271     * @param ex the exception to log, including its stack trace.
272     *
273     */

274    public void info (String JavaDoc channel,String JavaDoc msg,RootException ex) {
275       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
276          try {
277            SharkEngineManager.getInstance().getLoggingManager().info(channel, msg, ex);
278          }
279          catch (Exception JavaDoc e){
280             System.err.println("Error in logging - errMsg="+e.getMessage());
281          }
282       }
283    }
284
285    /**
286     * Log a message object with the <i>DEBUG</i> level.
287     *
288     * @param msg the message to log.
289     *
290     */

291    public void debug (String JavaDoc msg) {
292       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
293          try {
294            SharkEngineManager.getInstance().getLoggingManager().debug(msg);
295          }
296          catch (Exception JavaDoc e){
297            System.err.println("Error in logging - errMsg="+e.getMessage());
298          }
299       }
300    }
301
302    /**
303     * Log a message object with the <i>DEBUG</i> level.
304     *
305     * @param msg the message to log.
306     * @param ex the exception to log, including its stack trace.
307     *
308     */

309    public void debug (String JavaDoc msg,RootException ex) {
310       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
311          try {
312            SharkEngineManager.getInstance().getLoggingManager().debug(msg, ex);
313          }
314          catch (Exception JavaDoc e){
315            System.err.println("Error in logging - errMsg="+e.getMessage());
316          }
317       }
318    }
319
320    /**
321     * Log a message object with the <i>DEBUG</i> level.
322     *
323     * @param channel the log channel to be used for logging.
324     * @param msg the message to log.
325     *
326     */

327    public void debug (String JavaDoc channel,String JavaDoc msg) {
328       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
329          try {
330            SharkEngineManager.getInstance().getLoggingManager().debug(channel, msg);
331          }
332          catch (Exception JavaDoc e){
333            System.err.println("Error in logging - errMsg="+e.getMessage());
334          }
335       }
336    }
337
338    /**
339     * Log a message object with the <i>DEBUG</i> level.
340     *
341     * @param channel the log channel to be used for logging.
342     * @param msg the message to log.
343     * @param ex the exception to log, including its stack trace.
344     *
345     */

346    public void debug (String JavaDoc channel,String JavaDoc msg,RootException ex) {
347       if (SharkEngineManager.getInstance().getLoggingManager() != null) {
348          try {
349            SharkEngineManager.getInstance().getLoggingManager().debug(channel, msg, ex);
350          }
351          catch (Exception JavaDoc e){
352            System.err.println("Error in logging - errMsg="+e.getMessage());
353          }
354       }
355    }
356
357 }
358
359
Popular Tags