1 /*
2 * jDTAUS Core Utilities
3 * Copyright (C) 2005 Christian Schulte
4 * <cs@schulte.it>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21 package org.jdtaus.core.lang.util;
22
23 import org.jdtaus.core.container.ContainerFactory;
24 import org.jdtaus.core.lang.ExceptionEvent;
25 import org.jdtaus.core.lang.ExceptionListener;
26 import org.jdtaus.core.logging.spi.Logger;
27
28 /**
29 * {@code ExceptionListener} logging exceptions.
30 *
31 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
32 * @version $JDTAUS: ExceptionLogger.java 8641 2012-09-27 06:45:17Z schulte $
33 *
34 * @see #onException(ExceptionEvent)
35 */
36 public final class ExceptionLogger implements ExceptionListener
37 {
38 //--Constructors------------------------------------------------------------
39
40 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausConstructors
41 // This section is managed by jdtaus-container-mojo.
42
43 // </editor-fold>//GEN-END:jdtausConstructors
44
45 //------------------------------------------------------------Constructors--
46 //--Dependencies------------------------------------------------------------
47
48 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausDependencies
49 // This section is managed by jdtaus-container-mojo.
50
51 /**
52 * Gets the configured <code>Logger</code> implementation.
53 *
54 * @return The configured <code>Logger</code> implementation.
55 */
56 private Logger getLogger()
57 {
58 return (Logger) ContainerFactory.getContainer().
59 getDependency( this, "Logger" );
60
61 }
62
63 // </editor-fold>//GEN-END:jdtausDependencies
64
65 //------------------------------------------------------------Dependencies--
66 //--Properties--------------------------------------------------------------
67
68 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausProperties
69 // This section is managed by jdtaus-container-mojo.
70
71 // </editor-fold>//GEN-END:jdtausProperties
72
73 //--------------------------------------------------------------Properties--
74 //--ExceptionListener-------------------------------------------------------
75
76 /**
77 * {@inheritDoc}
78 * <p>This method logs details of the event's exception to a logger.</p>
79 *
80 * @param event the event holding the exception.
81 */
82 public void onException( final ExceptionEvent event )
83 {
84 if ( event != null )
85 {
86 this.getLogger().error( event.getException() );
87 }
88 }
89
90 //-------------------------------------------------------ExceptionListener--
91 }