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