001    // SECTION-START[License Header]
002    // <editor-fold defaultstate="collapsed" desc=" Generated License ">
003    /*
004     *   Copyright (c) 2009 The JOMC Project
005     *   Copyright (c) 2005 Christian Schulte <cs@jomc.org>
006     *   All rights reserved.
007     *
008     *   Redistribution and use in source and binary forms, with or without
009     *   modification, are permitted provided that the following conditions
010     *   are met:
011     *
012     *     o Redistributions of source code must retain the above copyright
013     *       notice, this list of conditions and the following disclaimer.
014     *
015     *     o Redistributions in binary form must reproduce the above copyright
016     *       notice, this list of conditions and the following disclaimer in
017     *       the documentation and/or other materials provided with the
018     *       distribution.
019     *
020     *   THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
021     *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
022     *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
023     *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
024     *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025     *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026     *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
027     *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
028     *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
029     *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
030     *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031     *
032     *   $Id: JdkObjectManagementListener.java 1131 2009-12-09 23:42:18Z schulte2005 $
033     *
034     */
035    // </editor-fold>
036    // SECTION-END
037    package org.jomc.logging.ri.jdk;
038    
039    import java.util.logging.Level;
040    
041    // SECTION-START[Documentation]
042    // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
043    /**
044     * {@code Listener} backed by JDK logging.
045     * <p><b>Specifications</b><ul>
046     * <li>{@code org.jomc.spi.Listener} {@code 1.0} {@code Multiton}</li>
047     * </ul></p>
048     * <p><b>Dependencies</b><ul>
049     * <li>"{@link #getLogger Logger}"<blockquote>
050     * Dependency on {@code org.jomc.logging.Logger} at specification level 1.0 bound to an instance.</blockquote></li>
051     * </ul></p>
052     *
053     * @author <a href="mailto:cs@jomc.org">Christian Schulte</a> 1.0
054     * @version $Id: JdkObjectManagementListener.java 1131 2009-12-09 23:42:18Z schulte2005 $
055     */
056    // </editor-fold>
057    // SECTION-END
058    // SECTION-START[Annotations]
059    // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
060    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
061                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
062    // </editor-fold>
063    // SECTION-END
064    public class JdkObjectManagementListener
065    implements
066        org.jomc.spi.Listener
067    {
068        // SECTION-START[JdkObjectManagementListener]
069    
070        public void onLog( final Level level, final String message, final Throwable throwable )
071        {
072            if ( level != null )
073            {
074                if ( level.equals( Level.CONFIG ) || level.equals( Level.FINE ) )
075                {
076                    this.getLogger().debug( message, throwable );
077                }
078                else if ( level.equals( Level.FINER ) || level.equals( Level.FINEST ) )
079                {
080                    this.getLogger().trace( message, throwable );
081                }
082                else if ( level.equals( Level.INFO ) )
083                {
084                    this.getLogger().info( message, throwable );
085                }
086                else if ( level.equals( Level.SEVERE ) )
087                {
088                    this.getLogger().error( message, throwable );
089                }
090                else if ( level.equals( Level.WARNING ) )
091                {
092                    this.getLogger().warn( message, throwable );
093                }
094                else
095                {
096                    this.getLogger().trace( message, throwable );
097                }
098            }
099        }
100    
101        // SECTION-END
102        // SECTION-START[Constructors]
103        // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
104    
105        /** Creates a new {@code JdkObjectManagementListener} instance. */
106        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
107                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
108        public JdkObjectManagementListener()
109        {
110            // SECTION-START[Default Constructor]
111            super();
112            // SECTION-END
113        }
114        // </editor-fold>
115        // SECTION-END
116        // SECTION-START[Dependencies]
117        // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies ">
118    
119        /**
120         * Gets the {@code Logger} dependency.
121         * <p>This method returns the "{@code JOMC Logging JDK Logging}" object of the {@code org.jomc.logging.Logger} specification at specification level 1.0.</p>
122         * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p>
123         * <p><b>Properties</b><dl>
124         * <dt>"{@code name}"</dt>
125         * <dd>Property of type {@code java.lang.String}.
126         * </dd>
127         * <dt>"{@code stackDepth}"</dt>
128         * <dd>Property of type {@code int}.
129         * </dd>
130         * </dl>
131         * @return The {@code Logger} dependency.
132         * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
133         */
134        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
135                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
136        private org.jomc.logging.Logger getLogger()
137        {
138            final org.jomc.logging.Logger _d = (org.jomc.logging.Logger) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Logger" );
139            assert _d != null : "'Logger' dependency not found.";
140            return _d;
141        }
142        // </editor-fold>
143        // SECTION-END
144        // SECTION-START[Properties]
145        // SECTION-END
146        // SECTION-START[Messages]
147        // SECTION-END
148    }