KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > util > Logger


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "OpenEJB" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of The OpenEJB Group. For written permission,
18  * please contact dev@openejb.org.
19  *
20  * 4. Products derived from this Software may not be called "OpenEJB"
21  * nor may "OpenEJB" appear in their names without prior written
22  * permission of The OpenEJB Group. OpenEJB is a registered
23  * trademark of The OpenEJB Group.
24  *
25  * 5. Due credit should be given to the OpenEJB Project
26  * (http://www.openejb.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
42  *
43  * $Id: Logger.java 2059 2005-08-04 20:17:43Z dblevins $
44  */

45 package org.openejb.util;
46
47 import java.io.File JavaDoc;
48 import java.io.FileInputStream JavaDoc;
49 import java.io.IOException JavaDoc;
50 import java.io.FileNotFoundException JavaDoc;
51 import java.io.InputStream JavaDoc;
52 import java.io.FileOutputStream JavaDoc;
53 import java.util.HashMap JavaDoc;
54 import java.util.Properties JavaDoc;
55 import java.net.URL JavaDoc;
56
57 import org.apache.log4j.Category;
58 import org.apache.log4j.Level;
59 import org.apache.log4j.PropertyConfigurator;
60 import org.openejb.loader.SystemInstance;
61 import org.openejb.OpenEJBException;
62
63
64 /**
65  * This is a wrapper class to the log4j facility. In addition to the
66  * internationalization of messages, it sets a default log4j configuration,
67  * if one is not already set in the system properties.
68  * <p>
69  * If the log4j system complains that there is no configuration set, then it's
70  * probably one of two things. First, the config file does not exist. Second,
71  * and more likely, the OpenEJB URL handler has not been registered. (Note
72  * that the log4j.configuration default setting uses the protocol resource.)
73  * <p>
74  *
75  * TODO: Create a wrapper to Tomcat logging facility; Make Logger class a factory
76  *
77  * @author <a HREF="mailto:adc@toolazydogs.com">Alan Cabrera</a>
78  * @version $Revision: 2059 $ $Date: 2005-08-04 13:17:43 -0700 (Thu, 04 Aug 2005) $
79  */

80 public class Logger {
81     // Make interface and make an i18n logger
82
protected static final HashMap JavaDoc _loggers = new HashMap JavaDoc();
83     protected Category _logger = null;
84     public I18N i18n = null;
85
86     public static void initialize(Properties JavaDoc props)
87     {
88         Log4jConfigUtils log4j = new Logger.Log4jConfigUtils(props);
89
90         log4j.configure();
91     }
92
93     /**
94      * Returns a shared instance of Logger.
95      *
96      * @param category the class whose name log4j category will use
97      * @param resourceName the name log4j category will use
98      *
99      * @return Instance of logger.
100      */

101     static public Logger getInstance( String JavaDoc category, String JavaDoc resourceName ) {
102     HashMap JavaDoc bundles = (HashMap JavaDoc)_loggers.get( category );
103     Logger logger = null;
104
105     if ( bundles == null ) {
106         synchronized (Logger.class) {
107         bundles = (HashMap JavaDoc)_loggers.get( category );
108         if ( bundles == null ) {
109             bundles = new HashMap JavaDoc();
110             _loggers.put( category, bundles );
111         }
112         }
113     }
114
115     logger = (Logger)bundles.get( resourceName );
116     if ( logger == null ) {
117         synchronized (Logger.class) {
118         logger = (Logger)bundles.get( resourceName );
119         if ( logger == null ) {
120             logger = new Logger( resourceName );
121             logger._logger = Category.getInstance( category );
122
123             bundles.put( resourceName, logger );
124         }
125         }
126     }
127
128     return logger;
129     }
130
131     /**
132      * Protected constructor. Users must invoke getInstance() to
133      * an instance of Logger.
134      *
135      * @param resourceName the name of the log4j category to use
136      *
137      * @see I18N
138      */

139     protected Logger( String JavaDoc resourceName ) {
140     i18n = new I18N( resourceName );
141     }
142
143     /**
144      * Wrapper function for log4j's isDebugEnabled() method.
145      *
146      * @return if debug is enabled.
147      */

148     public boolean isDebugEnabled() {
149     return _logger.isDebugEnabled();
150     }
151
152     /**
153      * Check to see if error messages are enabled.
154      *
155      * @return if error messages are enabled.
156      */

157     public boolean isErrorEnabled() {
158     return _logger.isEnabledFor( Level.ERROR );
159     }
160
161     /**
162      * Check to see if fatal messages are enabled.
163      *
164      * @return if fatal messages are enabled.
165      */

166     public boolean isFatalEnabled() {
167     return _logger.isEnabledFor( Level.FATAL );
168     }
169
170     /**
171      * Wrapper function for log4j's isInfoEnabled() method.
172      *
173      * @return if info messages are enabled.
174      */

175     public boolean isInfoEnabled() {
176     return _logger.isInfoEnabled();
177     }
178
179
180     /**
181      * Check to see if warning messages are enabled.
182      *
183      * @return if warning messages are enabled.
184      */

185     public boolean isWarningEnabled() {
186     return _logger.isEnabledFor( Level.WARN );
187     }
188
189
190     /**
191      * A wrapper call to log4j's debug method
192      *
193      * @param message The debug message to be logged.
194      */

195     public void debug( String JavaDoc message ) {
196     if ( isDebugEnabled() ) _logger.debug( message );
197     }
198
199     /**
200      * An wrapper call to log4j's debug method
201      *
202      * @param message The debug message to be logged.
203      * @param t the exception to log, including its stack trace
204      *
205      * @see org.openejb.util.Messages
206      */

207     public void debug( String JavaDoc message, Throwable JavaDoc t ) {
208     if ( isDebugEnabled() ) _logger.debug( message, t );
209     }
210
211     /**
212      * A wrapper call to log4j's error method
213      *
214      * @param message The error message to be logged.
215      */

216     public void error( String JavaDoc message ) {
217     if ( isErrorEnabled() ) _logger.error( message );
218     }
219
220     /**
221      * An wrapper call to log4j's error method
222      *
223      * @param message The error message to be logged.
224      * @param t the exception to log, including its stack trace
225      *
226      * @see org.openejb.util.Messages
227      */

228     public void error( String JavaDoc message, Throwable JavaDoc t ) {
229     if ( isErrorEnabled() ) _logger.error( message, t );
230     }
231
232     /**
233      * A wrapper call to log4j's error method
234      *
235      * @param message The fatal message to be logged.
236      */

237     public void fatal( String JavaDoc message ) {
238     if ( isFatalEnabled() ) _logger.fatal( message );
239     }
240
241     /**
242      * An wrapper call to log4j's fatal method
243      *
244      * @param message The fatal message to be logged.
245      * @param t the exception to log, including its stack trace
246      *
247      * @see org.openejb.util.Messages
248      */

249     public void fatal( String JavaDoc message, Throwable JavaDoc t ) {
250     if ( isFatalEnabled() ) _logger.fatal( message, t );
251     }
252
253     /**
254      * A wrapper call to log4j's error method
255      *
256      * @param message The info message to be logged.
257      */

258     public void info( String JavaDoc message ) {
259     if ( isInfoEnabled() ) _logger.info( message );
260     }
261
262     /**
263      * An wrapper call to log4j's info method
264      *
265      * @param message The info message to be logged.
266      * @param t the exception to log, including its stack trace
267      *
268      * @see org.openejb.util.Messages
269      */

270     public void info( String JavaDoc message, Throwable JavaDoc t ) {
271     if ( isInfoEnabled() ) _logger.info( message, t );
272     }
273
274     /**
275      * A wrapper call to log4j's warning method
276      *
277      * @param message The warning message to be logged.
278      */

279     public void warning( String JavaDoc message ) {
280     if ( isWarningEnabled() ) _logger.warn( message );
281     }
282
283     /**
284      * An wrapper call to log4j's warning method
285      *
286      * @param message The warning message to be logged.
287      * @param t the exception to log, including its stack trace
288      *
289      * @see org.openejb.util.Messages
290      */

291     public void warning( String JavaDoc message, Throwable JavaDoc t ) {
292     if ( isWarningEnabled() ) _logger.warn( message, t );
293     }
294
295
296     public class I18N {
297
298     protected Messages _messages = null;
299
300     protected I18N( String JavaDoc resourceName ) {
301         _messages = new Messages( resourceName );
302     }
303
304     /**
305      * An internationalized wrapper call to log4j's info method
306      *
307      * @param code The code to be internationalized.
308      *
309      * @see org.openejb.util.Messages
310      */

311     public void info( String JavaDoc code ) {
312         if ( isInfoEnabled() ) _logger.info( _messages.message( code ) );
313     }
314
315     /**
316      * An internationalized wrapper call to log4j's info method
317      *
318      * @param code The code to be internationalized.
319      * @param t the exception to log, including its stack trace
320      *
321      * @see org.openejb.util.Messages
322      */

323     public void info( String JavaDoc code, Throwable JavaDoc t ) {
324         if ( isInfoEnabled() ) _logger.info( _messages.message( code ), t );
325     }
326
327
328     /**
329      * An internationalized wrapper call to log4j's info method
330      *
331      * @param code The code to be internationalized
332      * @param arg0 First argument to the i18n message
333      *
334      * @see org.openejb.util.Messages
335      */

336     public void info( String JavaDoc code, Object JavaDoc arg0 ) {
337         if ( isInfoEnabled() ) {
338         Object JavaDoc[] args = { arg0 };
339         info( code, args );
340         }
341     }
342
343     /**
344      * An internationalized wrapper call to log4j's info method
345      *
346      * @param code The code to be internationalized
347      * @param t the exception to log, including its stack trace
348      * @param arg0 First argument to the i18n message
349      *
350      * @see org.openejb.util.Messages
351      */

352     public void info( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0 ) {
353         if ( isInfoEnabled() ) {
354         Object JavaDoc[] args = { arg0 };
355         info( code, t, args );
356         }
357     }
358
359     /**
360      * An internationalized wrapper call to log4j's info method
361      *
362      * @param code The code to be internationalized
363      * @param arg0 First argument to the i18n message
364      * @param arg1 Second argument to the i18n message
365      *
366      * @see org.openejb.util.Messages
367      */

368     public void info( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1 ) {
369         if ( isInfoEnabled() ) {
370         Object JavaDoc[] args = { arg0, arg1 };
371         info( code, args );
372         }
373     }
374
375     /**
376      * An internationalized wrapper call to log4j's info method
377      *
378      * @param code The code to be internationalized
379      * @param t the exception to log, including its stack trace
380      * @param arg0 First argument to the i18n message
381      * @param arg1 Second argument to the i18n message
382      *
383      * @see org.openejb.util.Messages
384      */

385     public void info( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1 ) {
386         if ( isInfoEnabled() ) {
387         Object JavaDoc[] args = { arg0, arg1 };
388         info( code, t, args );
389         }
390     }
391
392     /**
393      * An internationalized wrapper call to log4j's info method
394      *
395      * @param code The code to be internationalized
396      * @param arg0 First argument to the i18n message
397      * @param arg1 Second argument to the i18n message
398      * @param arg2 Third argument to the i18n message
399      *
400      * @see org.openejb.util.Messages
401      */

402     public void info( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
403         if ( isInfoEnabled() ) {
404         Object JavaDoc[] args = { arg0, arg1, arg2 };
405         info( code, args );
406         }
407     }
408
409     /**
410      * An internationalized wrapper call to log4j's info method
411      *
412      * @param code The code to be internationalized
413      * @param t the exception to log, including its stack trace
414      * @param arg0 First argument to the i18n message
415      * @param arg1 Second argument to the i18n message
416      * @param arg2 Third argument to the i18n message
417      *
418      * @see org.openejb.util.Messages
419      */

420     public void info( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
421         if ( isInfoEnabled() ) {
422         Object JavaDoc[] args = { arg0, arg1, arg2 };
423         info( code, t, args );
424         }
425     }
426
427     /**
428      * An internationalized wrapper call to log4j's info method
429      *
430      * @param code The code to be internationalized
431      * @param arg0 First argument to the i18n message
432      * @param arg1 Second argument to the i18n message
433      * @param arg2 Third argument to the i18n message
434      * @param arg3 Fourth argument to the i18n message
435      *
436      * @see org.openejb.util.Messages
437      */

438     public void info( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
439         if ( isInfoEnabled() ) {
440         Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
441         info( code, args );
442         }
443     }
444
445     /**
446      * An internationalized wrapper call to log4j's info method
447      *
448      * @param code The code to be internationalized
449      * @param t the exception to log, including its stack trace
450      * @param arg0 First argument to the i18n message
451      * @param arg1 Second argument to the i18n message
452      * @param arg2 Third argument to the i18n message
453      * @param arg3 Fourth argument to the i18n message
454      *
455      * @see org.openejb.util.Messages
456      */

457     public void info( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
458         if ( isInfoEnabled() ) {
459         Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
460         info( code, t, args );
461         }
462     }
463
464     /**
465      * An internationalized wrapper call to log4j's info method
466      *
467      * @param code The code to be internationalized
468      * @param arg0 First argument to the i18n message
469      * @param arg1 Second argument to the i18n message
470      * @param arg2 Third argument to the i18n message
471      * @param arg3 Fourth argument to the i18n message
472      * @param arg4 Fifth argument to the i18n message
473      *
474      * @see org.openejb.util.Messages
475      */

476     public void info( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
477         if ( isInfoEnabled() ) {
478         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
479         info( code, args );
480         }
481     }
482
483     /**
484      * An internationalized wrapper call to log4j's info method
485      *
486      * @param code The code to be internationalized
487      * @param t the exception to log, including its stack trace
488      * @param arg0 First argument to the i18n message
489      * @param arg1 Second argument to the i18n message
490      * @param arg2 Third argument to the i18n message
491      * @param arg3 Fourth argument to the i18n message
492      * @param arg4 Fifth argument to the i18n message
493      *
494      * @see org.openejb.util.Messages
495      */

496     public void info( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
497         if ( isInfoEnabled() ) {
498         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
499         info( code, t, args );
500         }
501     }
502
503     /**
504      * An internationalized wrapper call to log4j's info method
505      *
506      * @param code The code to be internationalized
507      * @param arg0 First argument to the i18n message
508      * @param arg1 Second argument to the i18n message
509      * @param arg2 Third argument to the i18n message
510      * @param arg3 Fourth argument to the i18n message
511      * @param arg4 Fifth argument to the i18n message
512      * @param arg5 Sixth argument to the i18n message
513      *
514      * @see org.openejb.util.Messages
515      */

516     public void info( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
517         if ( isInfoEnabled() ) {
518         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
519         info( code, args );
520         }
521     }
522
523     /**
524      * An internationalized wrapper call to log4j's info method
525      *
526      * @param code The code to be internationalized
527      * @param t the exception to log, including its stack trace
528      * @param arg0 First argument to the i18n message
529      * @param arg1 Second argument to the i18n message
530      * @param arg2 Third argument to the i18n message
531      * @param arg3 Fourth argument to the i18n message
532      * @param arg4 Fifth argument to the i18n message
533      * @param arg5 Sixth argument to the i18n message
534      *
535      * @see org.openejb.util.Messages
536      */

537     public void info( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
538         if ( isInfoEnabled() ) {
539         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
540         info( code, t, args );
541         }
542     }
543
544     /**
545      * An internationalized wrapper call to log4j's info method
546      *
547      * @param code The code to be internationalized
548      * @param args An array of arguments to the i18n message
549      *
550      * @see org.openejb.util.Messages
551      */

552     public void info( String JavaDoc code, Object JavaDoc[] args ) {
553         _logger.info( _messages.format( code, args ) );
554     }
555
556     /**
557      * An internationalized wrapper call to log4j's info method
558      *
559      * @param code The code to be internationalized
560      * @param t the exception to log, including its stack trace
561      * @param args An array of arguments to the i18n message
562      *
563      * @see org.openejb.util.Messages
564      */

565     public void info( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc[] args ) {
566         _logger.info( _messages.format( code, args ), t );
567     }
568
569     /**
570      * An internationalized wrapper call to log4j's warning method
571      *
572      * @param code The code to be internationalized.
573      *
574      * @see org.openejb.util.Messages
575      */

576     public void warning( String JavaDoc code ) {
577         if ( isWarningEnabled() ) _logger.warn( _messages.message( code ) );
578     }
579
580     /**
581      * An internationalized wrapper call to log4j's warning method
582      *
583      * @param code The code to be internationalized.
584      * @param t the exception to log, including its stack trace
585      *
586      * @see org.openejb.util.Messages
587      */

588     public void warning( String JavaDoc code, Throwable JavaDoc t ) {
589         if ( isWarningEnabled() ) _logger.warn( _messages.message( code ), t );
590     }
591
592     /**
593      * An internationalized wrapper call to log4j's warning method
594      *
595      * @param code The code to be internationalized
596      * @param arg0 First argument to the i18n message
597      *
598      * @see org.openejb.util.Messages
599      */

600     public void warning( String JavaDoc code, Object JavaDoc arg0 ) {
601         if ( isWarningEnabled() ) {
602         Object JavaDoc[] args = { arg0 };
603         warning( code, args );
604         }
605     }
606
607     /**
608      * An internationalized wrapper call to log4j's warning method
609      *
610      * @param code The code to be internationalized
611      * @param t the exception to log, including its stack trace
612      * @param arg0 First argument to the i18n message
613      *
614      * @see org.openejb.util.Messages
615      */

616     public void warning( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0 ) {
617         if ( isWarningEnabled() ) {
618         Object JavaDoc[] args = { arg0 };
619         warning( code, t, args );
620         }
621     }
622
623     /**
624      * An internationalized wrapper call to log4j's warning method
625      *
626      * @param code The code to be internationalized
627      * @param arg0 First argument to the i18n message
628      * @param arg1 Second argument to the i18n message
629      *
630      * @see org.openejb.util.Messages
631      */

632     public void warning( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1 ) {
633         if ( isWarningEnabled() ) {
634         Object JavaDoc[] args = { arg0, arg1 };
635         warning( code, args );
636         }
637     }
638
639     /**
640      * An internationalized wrapper call to log4j's warning method
641      *
642      * @param code The code to be internationalized
643      * @param t the exception to log, including its stack trace
644      * @param arg0 First argument to the i18n message
645      * @param arg1 Second argument to the i18n message
646      *
647      * @see org.openejb.util.Messages
648      */

649     public void warning( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1 ) {
650         if ( isWarningEnabled() ) {
651         Object JavaDoc[] args = { arg0, arg1 };
652         warning( code, t, args );
653         }
654     }
655
656     /**
657      * An internationalized wrapper call to log4j's warning method
658      *
659      * @param code The code to be internationalized
660      * @param arg0 First argument to the i18n message
661      * @param arg1 Second argument to the i18n message
662      * @param arg2 Third argument to the i18n message
663      *
664      * @see org.openejb.util.Messages
665      */

666     public void warning( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
667         if ( isWarningEnabled() ) {
668         Object JavaDoc[] args = { arg0, arg1, arg2 };
669         warning( code, args );
670         }
671     }
672
673     /**
674      * An internationalized wrapper call to log4j's warning method
675      *
676      * @param code The code to be internationalized
677      * @param t the exception to log, including its stack trace
678      * @param arg0 First argument to the i18n message
679      * @param arg1 Second argument to the i18n message
680      * @param arg2 Third argument to the i18n message
681      *
682      * @see org.openejb.util.Messages
683      */

684     public void warning( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
685         if ( isWarningEnabled() ) {
686         Object JavaDoc[] args = { arg0, arg1, arg2 };
687         warning( code, t, args );
688         }
689     }
690
691     /**
692      * An internationalized wrapper call to log4j's warning method
693      *
694      * @param code The code to be internationalized
695      * @param arg0 First argument to the i18n message
696      * @param arg1 Second argument to the i18n message
697      * @param arg2 Third argument to the i18n message
698      * @param arg3 Fourth argument to the i18n message
699      *
700      * @see org.openejb.util.Messages
701      */

702     public void warning( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
703         if ( isWarningEnabled() ) {
704         Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
705         warning( code, args );
706         }
707     }
708
709     /**
710      * An internationalized wrapper call to log4j's warning method
711      *
712      * @param code The code to be internationalized
713      * @param t the exception to log, including its stack trace
714      * @param arg0 First argument to the i18n message
715      * @param arg1 Second argument to the i18n message
716      * @param arg2 Third argument to the i18n message
717      * @param arg3 Fourth argument to the i18n message
718      *
719      * @see org.openejb.util.Messages
720      */

721     public void warning( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
722         if ( isWarningEnabled() ) {
723         Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
724         warning( code, t, args );
725         }
726     }
727
728     /**
729      * An internationalized wrapper call to log4j's warning method
730      *
731      * @param code The code to be internationalized
732      * @param arg0 First argument to the i18n message
733      * @param arg1 Second argument to the i18n message
734      * @param arg2 Third argument to the i18n message
735      * @param arg3 Fourth argument to the i18n message
736      * @param arg4 Fifth argument to the i18n message
737      *
738      * @see org.openejb.util.Messages
739      */

740     public void warning( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
741         if ( isWarningEnabled() ) {
742         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
743         warning( code, args );
744         }
745     }
746
747     /**
748      * An internationalized wrapper call to log4j's warning method
749      *
750      * @param code The code to be internationalized
751      * @param t the exception to log, including its stack trace
752      * @param arg0 First argument to the i18n message
753      * @param arg1 Second argument to the i18n message
754      * @param arg2 Third argument to the i18n message
755      * @param arg3 Fourth argument to the i18n message
756      * @param arg4 Fifth argument to the i18n message
757      *
758      * @see org.openejb.util.Messages
759      */

760     public void warning( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
761         if ( isWarningEnabled() ) {
762         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
763         warning( code, t, args );
764         }
765     }
766
767     /**
768      * An internationalized wrapper call to log4j's warning method
769      *
770      * @param code The code to be internationalized
771      * @param arg0 First argument to the i18n message
772      * @param arg1 Second argument to the i18n message
773      * @param arg2 Third argument to the i18n message
774      * @param arg3 Fourth argument to the i18n message
775      * @param arg4 Fifth argument to the i18n message
776      * @param arg5 Sixth argument to the i18n message
777      *
778      * @see org.openejb.util.Messages
779      */

780     public void warning( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
781         if ( isWarningEnabled() ) {
782         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
783         warning( code, args );
784         }
785     }
786
787     /**
788      * An internationalized wrapper call to log4j's warning method
789      *
790      * @param code The code to be internationalized
791      * @param t the exception to log, including its stack trace
792      * @param arg0 First argument to the i18n message
793      * @param arg1 Second argument to the i18n message
794      * @param arg2 Third argument to the i18n message
795      * @param arg3 Fourth argument to the i18n message
796      * @param arg4 Fifth argument to the i18n message
797      * @param arg5 Sixth argument to the i18n message
798      *
799      * @see org.openejb.util.Messages
800      */

801     public void warning( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
802         if ( isWarningEnabled() ) {
803         Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
804         warning( code, t, args );
805         }
806     }
807
808     /**
809      * An internationalized wrapper call to log4j's warning method
810      *
811      * @param code The code to be internationalized
812      * @param args An array of arguments to the i18n message
813      *
814      * @see org.openejb.util.Messages
815      */

816     public void warning( String JavaDoc code, Object JavaDoc[] args ) {
817         _logger.warn( _messages.format( code, args ) );
818     }
819
820     /**
821      * An internationalized wrapper call to log4j's warning method
822      *
823      * @param code The code to be internationalized
824      * @param t the exception to log, including its stack trace
825      * @param args An array of arguments to the i18n message
826      *
827      * @see org.openejb.util.Messages
828      */

829     public void warning( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc[] args ) {
830         _logger.warn( _messages.format( code, args ), t );
831     }
832
833
834     /**
835      * An internationalized wrapper call to log4j's error method
836      *
837      * @param code The code to be internationalized.
838      *
839      * @see org.openejb.util.Messages
840      */

841     public void error( String JavaDoc code ) {
842         if ( isErrorEnabled() ) _logger.error( _messages.message( code ) );
843     }
844
845     /**
846      * An internationalized wrapper call to log4j's error method
847      *
848      * @param code The code to be internationalized.
849      * @param t the exception to log, including its stack trace
850      *
851      * @see org.openejb.util.Messages
852      */

853     public void error( String JavaDoc code, Throwable JavaDoc t ) {
854         if ( isErrorEnabled() ) _logger.error( _messages.message( code ), t );
855     }
856
857     /**
858      * An internationalized wrapper call to log4j's error method
859      *
860      * @param code The code to be internationalized
861      * @param arg0 First argument to the i18n message
862      *
863      * @see org.openejb.util.Messages
864      */

865     public void error( String JavaDoc code, Object JavaDoc arg0 ) {
866         if ( isErrorEnabled() ) {
867         Object JavaDoc[] args = { arg0 };
868         error( code, args );
869         }
870     }
871
872     /**
873      * An internationalized wrapper call to log4j's error method
874      *
875      * @param code The code to be internationalized
876      * @param t the exception to log, including its stack trace
877      * @param arg0 First argument to the i18n message
878      *
879      * @see org.openejb.util.Messages
880      */

881     public void error( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0 ) {
882         if ( isErrorEnabled() ) {
883         Object JavaDoc[] args = { arg0 };
884         error( code, t, args );
885         }
886     }
887
888     /**
889      * An internationalized wrapper call to log4j's error method
890      *
891      * @param code The code to be internationalized
892      * @param arg0 First argument to the i18n message
893      * @param arg1 Second argument to the i18n message
894      *
895      * @see org.openejb.util.Messages
896      */

897     public void error( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1 ) {
898         if ( isErrorEnabled() ) {
899         Object JavaDoc[] args = { arg0, arg1 };
900         error( code, args );
901         }
902     }
903
904     /**
905      * An internationalized wrapper call to log4j's error method
906      *
907      * @param code The code to be internationalized
908      * @param t the exception to log, including its stack trace
909      * @param arg0 First argument to the i18n message
910      * @param arg1 Second argument to the i18n message
911      *
912      * @see org.openejb.util.Messages
913      */

914     public void error( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1 ) {
915         if ( isErrorEnabled() ) {
916         Object JavaDoc[] args = { arg0, arg1 };
917         error( code, t, args );
918         }
919     }
920
921     /**
922      * An internationalized wrapper call to log4j's error method
923      *
924      * @param code The code to be internationalized
925      * @param arg0 First argument to the i18n message
926      * @param arg1 Second argument to the i18n message
927      * @param arg2 Third argument to the i18n message
928      *
929      * @see org.openejb.util.Messages
930      */

931     public void error( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
932         if ( isErrorEnabled() ) {
933         Object JavaDoc[] args = { arg0, arg1, arg2 };
934         error( code, args );
935         }
936     }
937
938     /**
939      * An internationalized wrapper call to log4j's error method
940      *
941      * @param code The code to be internationalized
942      * @param t the exception to log, including its stack trace
943      * @param arg0 First argument to the i18n message
944      * @param arg1 Second argument to the i18n message
945      * @param arg2 Third argument to the i18n message
946      *
947      * @see org.openejb.util.Messages
948      */

949     public void error( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
950         if ( isErrorEnabled() ) {
951         Object JavaDoc[] args = { arg0, arg1, arg2 };
952         error( code, t, args );
953         }
954     }
955
956     /**
957      * An internationalized wrapper call to log4j's error method
958      *
959      * @param code The code to be internationalized
960      * @param arg0 First argument to the i18n message
961      * @param arg1 Second argument to the i18n message
962      * @param arg2 Third argument to the i18n message
963      * @param arg3 Fourth argument to the i18n message
964      *
965      * @see org.openejb.util.Messages
966      */

967     public void error( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
968         if ( isErrorEnabled() ) {
969         Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
970         error( code, args );
971         }
972     }
973
974     /**
975      * An internationalized wrapper call to log4j's error method
976      *
977      * @param code The code to be internationalized
978      * @param t the exception to log, including its stack trace
979      * @param arg0 First argument to the i18n message
980      * @param arg1 Second argument to the i18n message
981      * @param arg2 Third argument to the i18n message
982      * @param arg3 Fourth argument to the i18n message
983      *
984      * @see org.openejb.util.Messages
985      */

986     public void error( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
987         if ( isErrorEnabled() ) {
988         Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
989         error( code, t, args );
990         }
991     }
992
993     /**
994      * An internationalized wrapper call to log4j's error method
995      *
996      * @param code The code to be internationalized
997      * @param arg0 First argument to the i18n message
998      * @param arg1 Second argument to the i18n message
999      * @param arg2 Third argument to the i18n message
1000     * @param arg3 Fourth argument to the i18n message
1001     * @param arg4 Fifth argument to the i18n message
1002     *
1003     * @see org.openejb.util.Messages
1004     */

1005    public void error( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
1006        if ( isErrorEnabled() ) {
1007        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
1008        error( code, args );
1009        }
1010    }
1011
1012    /**
1013     * An internationalized wrapper call to log4j's error method
1014     *
1015     * @param code The code to be internationalized
1016     * @param t the exception to log, including its stack trace
1017     * @param arg0 First argument to the i18n message
1018     * @param arg1 Second argument to the i18n message
1019     * @param arg2 Third argument to the i18n message
1020     * @param arg3 Fourth argument to the i18n message
1021     * @param arg4 Fifth argument to the i18n message
1022     *
1023     * @see org.openejb.util.Messages
1024     */

1025    public void error( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
1026        if ( isErrorEnabled() ) {
1027        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
1028        error( code, t, args );
1029        }
1030    }
1031
1032    /**
1033     * An internationalized wrapper call to log4j's error method
1034     *
1035     * @param code The code to be internationalized
1036     * @param arg0 First argument to the i18n message
1037     * @param arg1 Second argument to the i18n message
1038     * @param arg2 Third argument to the i18n message
1039     * @param arg3 Fourth argument to the i18n message
1040     * @param arg4 Fifth argument to the i18n message
1041     * @param arg5 Sixth argument to the i18n message
1042     *
1043     * @see org.openejb.util.Messages
1044     */

1045    public void error( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
1046        if ( isErrorEnabled() ) {
1047        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
1048        error( code, args );
1049        }
1050    }
1051
1052    /**
1053     * An internationalized wrapper call to log4j's error method
1054     *
1055     * @param code The code to be internationalized
1056     * @param t the exception to log, including its stack trace
1057     * @param arg0 First argument to the i18n message
1058     * @param arg1 Second argument to the i18n message
1059     * @param arg2 Third argument to the i18n message
1060     * @param arg3 Fourth argument to the i18n message
1061     * @param arg4 Fifth argument to the i18n message
1062     * @param arg5 Sixth argument to the i18n message
1063     *
1064     * @see org.openejb.util.Messages
1065     */

1066    public void error( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
1067        if ( isErrorEnabled() ) {
1068        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
1069        error( code, t, args );
1070        }
1071    }
1072
1073    /**
1074     * An internationalized wrapper call to log4j's error method
1075     *
1076     * @param code The code to be internationalized
1077     * @param args An array of arguments to the i18n message
1078     *
1079     * @see org.openejb.util.Messages
1080     */

1081    public void error( String JavaDoc code, Object JavaDoc[] args ) {
1082        _logger.error( _messages.format( code, args ) );
1083    }
1084
1085    /**
1086     * An internationalized wrapper call to log4j's error method
1087     *
1088     * @param code The code to be internationalized
1089     * @param t the exception to log, including its stack trace
1090     * @param args An array of arguments to the i18n message
1091     *
1092     * @see org.openejb.util.Messages
1093     */

1094    public void error( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc[] args ) {
1095        _logger.error( _messages.format( code, args ), t );
1096    }
1097
1098    /**
1099     * An internationalized wrapper call to log4j's fatal method
1100     *
1101     * @param code The code to be internationalized.
1102     *
1103     * @see org.openejb.util.Messages
1104     */

1105    public void fatal( String JavaDoc code ) {
1106        _logger.fatal( _messages.message( code ) );
1107    }
1108
1109    /**
1110     * An internationalized wrapper call to log4j's fatal method
1111     *
1112     * @param code The code to be internationalized.
1113     * @param t the exception to log, including its stack trace
1114     *
1115     * @see org.openejb.util.Messages
1116     */

1117    public void fatal( String JavaDoc code, Throwable JavaDoc t ) {
1118        _logger.fatal( _messages.message( code ), t );
1119    }
1120
1121    /**
1122     * An internationalized wrapper call to log4j's fatal method
1123     *
1124     * @param code The code to be internationalized
1125     * @param arg0 First argument to the i18n message
1126     *
1127     * @see org.openejb.util.Messages
1128     */

1129    public void fatal( String JavaDoc code, Object JavaDoc arg0 ) {
1130        Object JavaDoc[] args = { arg0 };
1131        fatal( code, args );
1132    }
1133
1134    /**
1135     * An internationalized wrapper call to log4j's fatal method
1136     *
1137     * @param code The code to be internationalized
1138     * @param t the exception to log, including its stack trace
1139     * @param arg0 First argument to the i18n message
1140     *
1141     * @see org.openejb.util.Messages
1142     */

1143    public void fatal( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0 ) {
1144        Object JavaDoc[] args = { arg0 };
1145        fatal( code, t, args );
1146    }
1147
1148    /**
1149     * An internationalized wrapper call to log4j's fatal method
1150     *
1151     * @param code The code to be internationalized
1152     * @param arg0 First argument to the i18n message
1153     * @param arg1 Second argument to the i18n message
1154     *
1155     * @see org.openejb.util.Messages
1156     */

1157    public void fatal( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1 ) {
1158        Object JavaDoc[] args = { arg0, arg1 };
1159        fatal( code, args );
1160    }
1161
1162    /**
1163     * An internationalized wrapper call to log4j's fatal method
1164     *
1165     * @param code The code to be internationalized
1166     * @param t the exception to log, including its stack trace
1167     * @param arg0 First argument to the i18n message
1168     * @param arg1 Second argument to the i18n message
1169     *
1170     * @see org.openejb.util.Messages
1171     */

1172    public void fatal( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1 ) {
1173        Object JavaDoc[] args = { arg0, arg1 };
1174        fatal( code, t, args );
1175    }
1176
1177    /**
1178     * An internationalized wrapper call to log4j's fatal method
1179     *
1180     * @param code The code to be internationalized
1181     * @param arg0 First argument to the i18n message
1182     * @param arg1 Second argument to the i18n message
1183     * @param arg2 Third argument to the i18n message
1184     *
1185     * @see org.openejb.util.Messages
1186     */

1187    public void fatal( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
1188        Object JavaDoc[] args = { arg0, arg1, arg2 };
1189        fatal( code, args );
1190    }
1191
1192    /**
1193     * An internationalized wrapper call to log4j's fatal method
1194     *
1195     * @param code The code to be internationalized
1196     * @param t the exception to log, including its stack trace
1197     * @param arg0 First argument to the i18n message
1198     * @param arg1 Second argument to the i18n message
1199     * @param arg2 Third argument to the i18n message
1200     *
1201     * @see org.openejb.util.Messages
1202     */

1203    public void fatal( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
1204        Object JavaDoc[] args = { arg0, arg1, arg2 };
1205        fatal( code, t, args );
1206    }
1207
1208    /**
1209     * An internationalized wrapper call to log4j's fatal method
1210     *
1211     * @param code The code to be internationalized
1212     * @param arg0 First argument to the i18n message
1213     * @param arg1 Second argument to the i18n message
1214     * @param arg2 Third argument to the i18n message
1215     * @param arg3 Fourth argument to the i18n message
1216     *
1217     * @see org.openejb.util.Messages
1218     */

1219    public void fatal( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
1220        Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
1221        fatal( code, args );
1222    }
1223
1224    /**
1225     * An internationalized wrapper call to log4j's fatal method
1226     *
1227     * @param code The code to be internationalized
1228     * @param t the exception to log, including its stack trace
1229     * @param arg0 First argument to the i18n message
1230     * @param arg1 Second argument to the i18n message
1231     * @param arg2 Third argument to the i18n message
1232     * @param arg3 Fourth argument to the i18n message
1233     *
1234     * @see org.openejb.util.Messages
1235     */

1236    public void fatal( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
1237        Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
1238        fatal( code, t, args );
1239    }
1240
1241    /**
1242     * An internationalized wrapper call to log4j's fatal method
1243     *
1244     * @param code The code to be internationalized
1245     * @param arg0 First argument to the i18n message
1246     * @param arg1 Second argument to the i18n message
1247     * @param arg2 Third argument to the i18n message
1248     * @param arg3 Fourth argument to the i18n message
1249     * @param arg4 Fifth argument to the i18n message
1250     *
1251     * @see org.openejb.util.Messages
1252     */

1253    public void fatal( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
1254        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
1255        fatal( code, args );
1256    }
1257
1258    /**
1259     * An internationalized wrapper call to log4j's fatal method
1260     *
1261     * @param code The code to be internationalized
1262     * @param t the exception to log, including its stack trace
1263     * @param arg0 First argument to the i18n message
1264     * @param arg1 Second argument to the i18n message
1265     * @param arg2 Third argument to the i18n message
1266     * @param arg3 Fourth argument to the i18n message
1267     * @param arg4 Fifth argument to the i18n message
1268     *
1269     * @see org.openejb.util.Messages
1270     */

1271    public void fatal( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
1272        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
1273        fatal( code, t, args );
1274    }
1275
1276    /**
1277     * An internationalized wrapper call to log4j's fatal method
1278     *
1279     * @param code The code to be internationalized
1280     * @param arg0 First argument to the i18n message
1281     * @param arg1 Second argument to the i18n message
1282     * @param arg2 Third argument to the i18n message
1283     * @param arg3 Fourth argument to the i18n message
1284     * @param arg4 Fifth argument to the i18n message
1285     * @param arg5 Sixth argument to the i18n message
1286     *
1287     * @see org.openejb.util.Messages
1288     */

1289    public void fatal( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
1290        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
1291        fatal( code, args );
1292    }
1293
1294    /**
1295     * An internationalized wrapper call to log4j's fatal method
1296     *
1297     * @param code The code to be internationalized
1298     * @param t the exception to log, including its stack trace
1299     * @param arg0 First argument to the i18n message
1300     * @param arg1 Second argument to the i18n message
1301     * @param arg2 Third argument to the i18n message
1302     * @param arg3 Fourth argument to the i18n message
1303     * @param arg4 Fifth argument to the i18n message
1304     * @param arg5 Sixth argument to the i18n message
1305     *
1306     * @see org.openejb.util.Messages
1307     */

1308    public void fatal( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
1309        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
1310        fatal( code, t, args );
1311    }
1312
1313    /**
1314     * An internationalized wrapper call to log4j's fatal method
1315     *
1316     * @param code The code to be internationalized
1317     * @param args An array of arguments to the i18n message
1318     *
1319     * @see org.openejb.util.Messages
1320     */

1321    public void fatal( String JavaDoc code, Object JavaDoc[] args ) {
1322        _logger.fatal( _messages.format( code, args ) );
1323    }
1324
1325    /**
1326     * An internationalized wrapper call to log4j's fatal method
1327     *
1328     * @param code The code to be internationalized
1329     * @param t the exception to log, including its stack trace
1330     * @param args An array of arguments to the i18n message
1331     *
1332     * @see org.openejb.util.Messages
1333     */

1334    public void fatal( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc[] args ) {
1335        _logger.fatal( _messages.format( code, args ), t );
1336    }
1337
1338
1339    /**
1340     * An internationalized wrapper call to log4j's debug method
1341     *
1342     * @param code The code to be internationalized.
1343     *
1344     * @see org.openejb.util.Messages
1345     */

1346    public void debug( String JavaDoc code ) {
1347        if ( isDebugEnabled() ) _logger.debug( _messages.message( code ) );
1348    }
1349
1350    /**
1351     * An internationalized wrapper call to log4j's debug method
1352     *
1353     * @param code The code to be internationalized.
1354     * @param t the exception to log, including its stack trace
1355     *
1356     * @see org.openejb.util.Messages
1357     */

1358    public void debug( String JavaDoc code, Throwable JavaDoc t ) {
1359        if ( isDebugEnabled() ) _logger.debug( _messages.message( code ), t );
1360    }
1361
1362    /**
1363     * An internationalized wrapper call to log4j's debug method
1364     *
1365     * @param code The code to be internationalized
1366     * @param arg0 First argument to the i18n message
1367     *
1368     * @see org.openejb.util.Messages
1369     */

1370    public void debug( String JavaDoc code, Object JavaDoc arg0 ) {
1371        if ( isDebugEnabled() ) {
1372        Object JavaDoc[] args = { arg0 };
1373        debug( code, args );
1374        }
1375    }
1376
1377    /**
1378     * An internationalized wrapper call to log4j's debug method
1379     *
1380     * @param code The code to be internationalized
1381     * @param t the exception to log, including its stack trace
1382     * @param arg0 First argument to the i18n message
1383     *
1384     * @see org.openejb.util.Messages
1385     */

1386    public void debug( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0 ) {
1387        if ( isDebugEnabled() ) {
1388        Object JavaDoc[] args = { arg0 };
1389        debug( code, t, args );
1390        }
1391    }
1392
1393    /**
1394     * An internationalized wrapper call to log4j's debug method
1395     *
1396     * @param code The code to be internationalized
1397     * @param arg0 First argument to the i18n message
1398     * @param arg1 Second argument to the i18n message
1399     *
1400     * @see org.openejb.util.Messages
1401     */

1402    public void debug( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1 ) {
1403        if ( isDebugEnabled() ) {
1404        Object JavaDoc[] args = { arg0, arg1 };
1405        debug( code, args );
1406        }
1407    }
1408
1409    /**
1410     * An internationalized wrapper call to log4j's debug method
1411     *
1412     * @param code The code to be internationalized
1413     * @param t the exception to log, including its stack trace
1414     * @param arg0 First argument to the i18n message
1415     * @param arg1 Second argument to the i18n message
1416     *
1417     * @see org.openejb.util.Messages
1418     */

1419    public void debug( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1 ) {
1420        if ( isDebugEnabled() ) {
1421        Object JavaDoc[] args = { arg0, arg1 };
1422        debug( code, t, args );
1423        }
1424    }
1425
1426    /**
1427     * An internationalized wrapper call to log4j's debug method
1428     *
1429     * @param code The code to be internationalized
1430     * @param arg0 First argument to the i18n message
1431     * @param arg1 Second argument to the i18n message
1432     * @param arg2 Third argument to the i18n message
1433     *
1434     * @see org.openejb.util.Messages
1435     */

1436    public void debug( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
1437        if ( isDebugEnabled() ) {
1438        Object JavaDoc[] args = { arg0, arg1, arg2 };
1439        debug( code, args );
1440        }
1441    }
1442
1443    /**
1444     * An internationalized wrapper call to log4j's debug method
1445     *
1446     * @param code The code to be internationalized
1447     * @param t the exception to log, including its stack trace
1448     * @param arg0 First argument to the i18n message
1449     * @param arg1 Second argument to the i18n message
1450     * @param arg2 Third argument to the i18n message
1451     *
1452     * @see org.openejb.util.Messages
1453     */

1454    public void debug( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2 ) {
1455        if ( isDebugEnabled() ) {
1456        Object JavaDoc[] args = { arg0, arg1, arg2 };
1457        debug( code, t, args );
1458        }
1459    }
1460
1461    /**
1462     * An internationalized wrapper call to log4j's debug method
1463     *
1464     * @param code The code to be internationalized
1465     * @param arg0 First argument to the i18n message
1466     * @param arg1 Second argument to the i18n message
1467     * @param arg2 Third argument to the i18n message
1468     * @param arg3 Fourth argument to the i18n message
1469     *
1470     * @see org.openejb.util.Messages
1471     */

1472    public void debug( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
1473        if ( isDebugEnabled() ) {
1474        Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
1475        debug( code, args );
1476        }
1477    }
1478
1479    /**
1480     * An internationalized wrapper call to log4j's debug method
1481     *
1482     * @param code The code to be internationalized
1483     * @param t the exception to log, including its stack trace
1484     * @param arg0 First argument to the i18n message
1485     * @param arg1 Second argument to the i18n message
1486     * @param arg2 Third argument to the i18n message
1487     * @param arg3 Fourth argument to the i18n message
1488     *
1489     * @see org.openejb.util.Messages
1490     */

1491    public void debug( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3 ) {
1492        if ( isDebugEnabled() ) {
1493        Object JavaDoc[] args = { arg0, arg1, arg2, arg3 };
1494        debug( code, t, args );
1495        }
1496    }
1497
1498    /**
1499     * An internationalized wrapper call to log4j's debug method
1500     *
1501     * @param code The code to be internationalized
1502     * @param arg0 First argument to the i18n message
1503     * @param arg1 Second argument to the i18n message
1504     * @param arg2 Third argument to the i18n message
1505     * @param arg3 Fourth argument to the i18n message
1506     * @param arg4 Fifth argument to the i18n message
1507     *
1508     * @see org.openejb.util.Messages
1509     */

1510    public void debug( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
1511        if ( isDebugEnabled() ) {
1512        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
1513        debug( code, args );
1514        }
1515    }
1516
1517    /**
1518     * An internationalized wrapper call to log4j's debug method
1519     *
1520     * @param code The code to be internationalized
1521     * @param t the exception to log, including its stack trace
1522     * @param arg0 First argument to the i18n message
1523     * @param arg1 Second argument to the i18n message
1524     * @param arg2 Third argument to the i18n message
1525     * @param arg3 Fourth argument to the i18n message
1526     * @param arg4 Fifth argument to the i18n message
1527     *
1528     * @see org.openejb.util.Messages
1529     */

1530    public void debug( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4 ) {
1531        if ( isDebugEnabled() ) {
1532        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4 };
1533        debug( code, t, args );
1534        }
1535    }
1536
1537    /**
1538     * An internationalized wrapper call to log4j's debug method
1539     *
1540     * @param code The code to be internationalized
1541     * @param arg0 First argument to the i18n message
1542     * @param arg1 Second argument to the i18n message
1543     * @param arg2 Third argument to the i18n message
1544     * @param arg3 Fourth argument to the i18n message
1545     * @param arg4 Fifth argument to the i18n message
1546     * @param arg5 Sixth argument to the i18n message
1547     *
1548     * @see org.openejb.util.Messages
1549     */

1550    public void debug( String JavaDoc code, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
1551        if ( isDebugEnabled() ) {
1552        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
1553        debug( code, args );
1554        }
1555    }
1556
1557    /**
1558     * An internationalized wrapper call to log4j's debug method
1559     *
1560     * @param code The code to be internationalized
1561     * @param t the exception to log, including its stack trace
1562     * @param arg0 First argument to the i18n message
1563     * @param arg1 Second argument to the i18n message
1564     * @param arg2 Third argument to the i18n message
1565     * @param arg3 Fourth argument to the i18n message
1566     * @param arg4 Fifth argument to the i18n message
1567     * @param arg5 Sixth argument to the i18n message
1568     *
1569     * @see org.openejb.util.Messages
1570     */

1571    public void debug( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc arg0, Object JavaDoc arg1, Object JavaDoc arg2, Object JavaDoc arg3, Object JavaDoc arg4, Object JavaDoc arg5 ) {
1572        if ( isDebugEnabled() ) {
1573        Object JavaDoc[] args = { arg0, arg1, arg2, arg3, arg4, arg5 };
1574        debug( code, t, args );
1575        }
1576    }
1577
1578    /**
1579     * An internationalized wrapper call to log4j's debug method
1580     *
1581     * @param code The code to be internationalized
1582     * @param args An array of arguments to the i18n message
1583     *
1584     * @see org.openejb.util.Messages
1585     */

1586    public void debug( String JavaDoc code, Object JavaDoc[] args ) {
1587        _logger.debug( _messages.format( code, args ) );
1588    }
1589
1590    /**
1591     * An internationalized wrapper call to log4j's debug method
1592     *
1593     * @param code The code to be internationalized
1594     * @param t the exception to log, including its stack trace
1595     * @param args An array of arguments to the i18n message
1596     *
1597     * @see org.openejb.util.Messages
1598     */

1599    public void debug( String JavaDoc code, Throwable JavaDoc t, Object JavaDoc[] args ) {
1600        _logger.debug( _messages.format( code, args ), t );
1601    }
1602    }
1603
1604    static class Log4jConfigUtils {
1605
1606        Properties JavaDoc props;
1607
1608        public Log4jConfigUtils(Properties JavaDoc props)
1609        {
1610            this.props = props;
1611        }
1612
1613        public void configure(){
1614            String JavaDoc config = props.getProperty( "log4j.configuration" );
1615            if (config == null) {
1616                config = "conf/logging.conf";
1617            }
1618            try{
1619                // resolve the config file location
1620
config = getAbsolutePath(config, "conf/default.logging.conf", false);
1621
1622                // load the config
1623
Properties JavaDoc log4jProps = loadProperties(config);
1624
1625                PropertyConfigurator.configure(filterProperties(log4jProps));
1626            } catch (Exception JavaDoc e){
1627                System.err.println("Failed to configure log4j. "+e.getMessage());
1628            }
1629        }
1630
1631        public Properties JavaDoc loadProperties(String JavaDoc file) throws Exception JavaDoc{
1632            Properties JavaDoc props = new Properties JavaDoc();
1633            FileInputStream JavaDoc fin = null;
1634
1635            try{
1636                fin = new FileInputStream JavaDoc(file);
1637                props.load(fin);
1638            } finally {
1639                if (fin != null) fin.close();
1640            }
1641            return props;
1642        }
1643
1644        /**
1645         * Replace log4j file-related settings to reflect OpenEJB configuration
1646         * (openejb.home and openejb.base)
1647         *
1648         * @param log4jProps log4j initialization properties
1649         * @return properties with log4j File properties changed
1650         */

1651        public Properties JavaDoc filterProperties(Properties JavaDoc log4jProps) {
1652            Object JavaDoc[] names = log4jProps.keySet().toArray();
1653            for (int i=0; i < names.length; i++){
1654                String JavaDoc name = (String JavaDoc)names[i];
1655                if (name.endsWith(".File")) {
1656                    String JavaDoc path = log4jProps.getProperty(name);
1657                    try {
1658                        File JavaDoc file = SystemInstance.get().getBase().getFile(path, false);
1659                        if (!file.getParentFile().exists()) {
1660                            file = SystemInstance.get().getHome().getFile(path, false);
1661                        }
1662                        path = file.getPath();
1663                    } catch (IOException JavaDoc ignored) {
1664                        // as there's no validation - false in getFile - no
1665
// exception is to be thrown
1666
}
1667                    log4jProps.setProperty(name, path);
1668                }
1669            }
1670            return log4jProps;
1671        }
1672
1673        public String JavaDoc getAbsolutePath(String JavaDoc path, String JavaDoc secondaryPath, boolean create)
1674                throws OpenEJBException {
1675            File JavaDoc file = null;
1676
1677            if (path != null) {
1678                /*
1679                 * [1] Try finding the file relative to the current working
1680                 * directory
1681                 */

1682                file = new File JavaDoc(path);
1683                if (file != null && file.exists() && file.isFile()) {
1684                    return file.getAbsolutePath();
1685                }
1686
1687                /*
1688                 * [2] Try finding the file relative to the openejb.base directory
1689                 */

1690                try {
1691                    file = SystemInstance.get().getBase().getFile(path);
1692                    if (file != null && file.exists() && file.isFile()) {
1693                        return file.getAbsolutePath();
1694                    }
1695                } catch (FileNotFoundException JavaDoc ignored) {
1696                } catch (IOException JavaDoc ignored) {
1697                }
1698
1699                /*
1700                 * [3] Try finding the file relative to the openejb.home directory
1701                 */

1702                try {
1703                    file = SystemInstance.get().getHome().getFile(path);
1704                    if (file != null && file.exists() && file.isFile()) {
1705                        return file.getAbsolutePath();
1706                    }
1707                } catch (FileNotFoundException JavaDoc ignored) {
1708                } catch (IOException JavaDoc ignored) {
1709                }
1710
1711            }
1712
1713            try {
1714                /*
1715                 * [4] Try finding the secondaryPath file relative to the
1716                 * openejb.base directory
1717                 */

1718                try {
1719                    file = SystemInstance.get().getBase().getFile(secondaryPath);
1720                    if (file != null && file.exists() && file.isFile()) {
1721                        return file.getAbsolutePath();
1722                    }
1723                } catch (java.io.FileNotFoundException JavaDoc ignored) {
1724                }
1725
1726                /*
1727                 * [5] Try finding the secondaryPath file relative to the
1728                 * openejb.home directory
1729                 */

1730                try {
1731                    file = SystemInstance.get().getHome().getFile(secondaryPath);
1732                    if (file != null && file.exists() && file.isFile()) {
1733                        return file.getAbsolutePath();
1734                    }
1735                } catch (java.io.FileNotFoundException JavaDoc ignored) {
1736                }
1737
1738                // Nothing found. Create if asked.
1739
//
1740
// TODO:1: We cannot find the user's conf file and
1741
// are taking the liberty of creating one for them.
1742
// We should log this.
1743
if (create)
1744                {
1745                    File JavaDoc confDir = SystemInstance.get().getBase().getDirectory("conf", true);
1746
1747                    file = createConfig(new File JavaDoc(confDir, secondaryPath));
1748                }
1749            } catch (java.io.IOException JavaDoc e) {
1750                e.printStackTrace();
1751                throw new OpenEJBException("Could not locate config file: ", e);
1752            }
1753
1754            return (file == null) ? null : file.getAbsolutePath();
1755        }
1756
1757        private static File JavaDoc createConfig(File JavaDoc file) throws java.io.IOException JavaDoc{
1758            try{
1759                URL JavaDoc defaultConfig = new URL JavaDoc("resource:/" + file.getName());
1760                InputStream JavaDoc in = defaultConfig.openStream();
1761                FileOutputStream JavaDoc out = new FileOutputStream JavaDoc(file);
1762
1763                int b = in.read();
1764
1765                while (b != -1) {
1766                    out.write(b);
1767                    b = in.read();
1768                }
1769
1770                in.close();
1771                out.close();
1772
1773            } catch (Exception JavaDoc e){
1774                e.printStackTrace();
1775            }
1776
1777            return file;
1778        }
1779
1780    }
1781}
Popular Tags