Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  jDTAUS Core Utilities
   *  Copyright (c) 2005 Christian Schulte
   *
   *  Christian Schulte, Haldener Strasse 72, 58095 Hagen, Germany
   *  <cs@jdtaus.org> (+49 2331 3543887)
   *
   *  This library is free software; you can redistribute it and/or
   *  modify it under the terms of the GNU Lesser General Public
  *  License as published by the Free Software Foundation; either
  *  version 2.1 of the License, or any later version.
  *
  *  This library is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  *  Lesser General Public License for more details.
  *
  *  You should have received a copy of the GNU Lesser General Public
  *  License along with this library; if not, write to the Free Software
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 package org.jdtaus.core.lang.util;
 
 import  org.jdtaus.core.container.ContainerFactory;
 import  org.jdtaus.core.container.ContextFactory;
 import  org.jdtaus.core.container.ContextInitializer;
 import  org.jdtaus.core.container.Implementation;
 import  org.jdtaus.core.container.ModelFactory;
 import  org.jdtaus.core.container.Properties;
 import  org.jdtaus.core.container.Property;
 import  org.jdtaus.core.lang.ExceptionEvent;
 import  org.jdtaus.core.lang.ExceptionListener;
 import  org.jdtaus.core.logging.spi.Logger;

ExceptionListener logging exceptions.

Author(s):
Christian Schulte
Version:
$Id: ExceptionLogger.java 5034 2008-07-04 11:04:09Z schulte2005 $
See also:
onException(ExceptionEvent)
 
 public final class ExceptionLogger implements ExceptionListener
 {
     //--Implementation----------------------------------------------------------
 
 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausImplementation
     // This section is managed by jdtaus-container-mojo.
 
    
Meta-data describing the implementation.
 
     private static final Implementation META =
         ModelFactory.getModel().getModules().
         getImplementation(ExceptionLogger.class.getName());
 // </editor-fold>//GEN-END:jdtausImplementation
 
     //----------------------------------------------------------Implementation--
     //--Constructors------------------------------------------------------------
 
 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausConstructors
     // This section is managed by jdtaus-container-mojo.
 
    
Initializes the properties of the instance.

Parameters:
meta the property values to initialize the instance with.
Throws:
NullPointerException if meta is null.
 
     private void initializeProperties(final Properties meta)
     {
         Property p;
 
         if(meta == null)
         {
             throw new NullPointerException("meta");
         }
 
     }
 // </editor-fold>//GEN-END:jdtausConstructors
 
     //------------------------------------------------------------Constructors--
     //--Dependencies------------------------------------------------------------
 
 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausDependencies
     // This section is managed by jdtaus-container-mojo.
 
    
Configured Logger implementation.
 
     private transient Logger dLogger;

    
Gets the configured Logger implementation.

Returns:
the configured Logger implementation.
 
     private Logger getLogger()
     {
         Logger ret = null;
         if(this. != null)
        {
            ret = this.;
        }
        else
        {
            ret = (Logger) ContainerFactory.getContainer().
                getDependency(ExceptionLogger.class,
                "Logger");
            if(ModelFactory.getModel().getModules().
                getImplementation(ExceptionLogger.class.getName()).
                getDependencies().getDependency("Logger").
                isBound())
            {
                this. = ret;
            }
        }
        if(ret instanceof ContextInitializer && !((ContextInitializer) ret).
            isInitialized(ContextFactory.getContext()))
        {
            ((ContextInitializer) ret).initialize(ContextFactory.getContext());
        }
        return ret;
    }
// </editor-fold>//GEN-END:jdtausDependencies
    //------------------------------------------------------------Dependencies--
    //--Properties--------------------------------------------------------------
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausProperties
    // This section is managed by jdtaus-container-mojo.
// </editor-fold>//GEN-END:jdtausProperties
    //--------------------------------------------------------------Properties--
    //--ExceptionListener-------------------------------------------------------

    

This method logs details of the event's exception to a logger.

Parameters:
event the event holding the exception.
    public void onExceptionfinal ExceptionEvent event )
    {
        if ( event != null )
        {
            this.getLogger().error( event.getException() );
        }
    }
    //-------------------------------------------------------ExceptionListener--
    //--ExceptionLogger---------------------------------------------------------

    
Creates a new ExceptionLogger instance.
    public ExceptionLogger()
    {
        super();
        this.initializeProperties.getProperties() );
    }
    //---------------------------------------------------------ExceptionLogger--
New to GrepCode? Check out our FAQ X