⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loggableobject.java

📁 jbpm的demo,带有流程设计
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** * $Source: /home/ws/rz65/CVS-Repository/WorkflowProjects/JBPM-Demo/src/java/jbpmdemo/logging/LoggableObject.java,v $ * $Revision: 1.1 $ * $Date: 2005/03/05 12:16:28 $ * $Author: rz65 $ * * Copyright (c) 2005 Universitaet Karlsruhe (TH) / Rechenzentrum (RZ-UNI-UKA) * * RZ-UNI-KA makes no representations or warranties about the suitability * of this software, either express or implied, including but not limited * to the implied warranties of merchantability, fitness for a particular * purpose, or non-infringement. RZ-UNI-KA shall not be liable for any * damages as a result of using, modifying or distributing this software * or its derivatives. */package jbpmdemo.logging;import org.apache.commons.logging.LogFactory;import org.apache.commons.logging.Log;import java.io.Serializable;import jbpmdemo.logging.Loggable;/** * This class provides a simple implementation of the {@link Loggable} * interface. Within class inheritance hierarchies, it might replace * {@link Object}for an easy way to supply logging methods to your application. *  * <p> *  * <code>LoggableObject</code> allocates a logger which is normally identified * by the fully qualified class name of the run-time class of <code>this</code>. * However, you may supply any dot-separated String chain for defining the * logged though this might be laborious and error-prone. Using the class name * as logger identification is far more comfortable. *  * <p> *  * Some aspects of {@link Serializable}: In a distributed J2EE application, * objects may frequently migrate from one JVM to another using Java's built-in * serialization facility. However, serialization might be thwarted by those * part of the object reference graph that are introduced by the logging * interface. Therefore, the potentially non-serializable Log reference field of * this class are marked as <code>transient</code>; this attributes prevents * that field from serialization. The field will be <code>null</code> when a * migrating object is unmarshalled at the destination side of the serialized * object flow. Consequently, the evaluation of the logger for this instance is * repeated at the destination side. *  * <p> *  * Class Hierarchies and Delegation: If you want to provide logging capabilities * to a class whose super-class is not <code>Object</code>, things will get a * little bit more complex since Java does not allow multiple inheritance. For * such classes, logging could be achieved by delegation to an aggregated * <code>LoggableObject</code> that uses a logger derived from the class name * of the delegating class. A <a * href="doc-files/LoggableDelegation-template.txt"> template </a> for these * delegations is provided within the API documentation of this class. Simple * paste it into the source of your class. *  * <p> *  * @version $Revision: 1.1 $ * @author mailto:harald.meyer@rz.uni-karlsruhe.de */public class LoggableObject extends Object implements Loggable, Serializable {	/**	 * The underlying Log.	 */	private transient Log log;	/**	 * The log name.	 */	private String logName;	/**	 * <p>	 * Returns the log name.	 * 	 * @return The log name.	 */	public String getLogName() {		return logName;	}	/**	 * The last part of the log name.	 */	private String shortLogName;	/**	 * <p>	 * Returns the short log name.	 * 	 * @return The short name.	 */	public String getShortLogName() {		return shortLogName;	}	/**	 * <p>	 * Is debug logging currently enabled?	 * </p>	 * 	 * <p>	 * Call this method to prevent having to perform expensive operations (for	 * example, <code>String</code> concatination) when the log level is more	 * than debug.	 * </p>	 */	public boolean isDebugEnabled() {		checkLogger();		return log.isDebugEnabled();	}	/**	 * <p>	 * Is error logging currently enabled?	 * </p>	 * 	 * <p>	 * Call this method to prevent having to perform expensive operations (for	 * example, <code>String</code> concatination) when the log level is more	 * than error.	 * </p>	 */	public boolean isErrorEnabled() {		checkLogger();		return log.isErrorEnabled();	}	/**	 * <p>	 * Is fatal logging currently enabled?	 * </p>	 * 	 * <p>	 * Call this method to prevent having to perform expensive operations (for	 * example, <code>String</code> concatination) when the log level is more	 * than fatal.	 * </p>	 */	public boolean isFatalEnabled() {		checkLogger();		return log.isFatalEnabled();	}	/**	 * <p>	 * Is info logging currently enabled?	 * </p>	 * 	 * <p>	 * Call this method to prevent having to perform expensive operations (for	 * example, <code>String</code> concatination) when the log level is more	 * than info.	 * </p>	 */	public boolean isInfoEnabled() {		checkLogger();		return log.isInfoEnabled();	}	/**	 * <p>	 * Is trace logging currently enabled?	 * </p>	 * 	 * <p>	 * Call this method to prevent having to perform expensive operations (for	 * example, <code>String</code> concatination) when the log level is more	 * than trace.	 * </p>	 */	public boolean isTraceEnabled() {		checkLogger();		return log.isTraceEnabled();	}	/**	 * <p>	 * Is warning logging currently enabled?	 * </p>	 * 	 * <p>	 * Call this method to prevent having to perform expensive operations (for	 * example, <code>String</code> concatination) when the log level is more	 * than warning.	 * </p>	 */	public boolean isWarnEnabled() {		checkLogger();		return log.isWarnEnabled();	}	/**	 * Auxiliary method that creates the message text from a method name and	 * inner message.	 * 	 * @param methodName	 *            The name of the method that issued the message.	 * @param message	 *            The inner message.	 * @return The combined methodName + message text.	 */	private Object mh(String methodName, Object message) {		checkLogger();		return methodName + " ** " + message.toString();	}	/**	 * Auxiliary method that creates the message text from an inner message.	 * 	 * @param message	 *            The inner message.	 * @return The combined text.	 */	private Object mh(Object message) {		checkLogger();		return message;	}	/**	 * <p>	 * Log a message with trace log level.	 * </p>	 * 	 * @param methodName	 *            The name of the method that issued this message.	 * @param message	 *            The log message.	 */	public void trace(String methodName, Object message) {		checkLogger();		log.trace(mh(methodName, message));	}	/**	 * <p>	 * Log an error with trace log level.	 * </p>	 * 	 * @param methodName	 *            The name of the method that issued this message.	 * @param message	 *            The log message.	 * @param throwable	 *            The cause for this message.	 */	public void trace(String methodName, Object message, Throwable throwable) {		checkLogger();		log.trace(mh(methodName, message), throwable);	}	/**	 * <p>	 * Log a message with trace log level.	 * </p>	 * 	 * @param message	 *            The log message.	 */	public void trace(Object message) {		checkLogger();		log.trace(mh(message));	}	/**	 * <p>	 * Log an error with trace log level.	 * </p>	 * 	 * @param message	 *            The log message.	 * @param throwable	 *            The cause for this message.	 */	public void trace(Object message, Throwable throwable) {		checkLogger();		log.trace(mh(message), throwable);	}	/**	 * <p>	 * Log a message with debug log level.	 * </p>	 * 	 * @param methodName	 *            The name of the method that issued this message.	 * @param message	 *            The log message.	 */	public void debug(String methodName, Object message) {		checkLogger();		log.debug(mh(methodName, message));	}	/**	 * <p>	 * Log an error with debug log level.	 * </p>	 * 	 * @param methodName	 *            The name of the method that issued this message.	 * @param message	 *            The log message.	 * @param throwable	 *            The cause for this message.	 */	public void debug(String methodName, Object message, Throwable throwable) {		checkLogger();		log.debug(mh(methodName, message), throwable);	}	/**	 * <p>	 * Log a message with debug log level.	 * </p>	 * 	 * @param message	 *            The log message.	 */	public void debug(Object message) {		checkLogger();		log.debug(mh(message));	}	/**	 * <p>	 * Log an error with debug log level.	 * </p>	 * 	 * @param message	 *            The log message.	 * @param throwable	 *            The cause for this message.	 */	public void debug(Object message, Throwable throwable) {		checkLogger();		log.debug(mh(message), throwable);	}	/**	 * <p>	 * Log a message with info log level.	 * </p>	 * 	 * @param methodName	 *            The name of the method that issued this message.	 * @param message	 *            The log message.	 */	public void info(String methodName, Object message) {		checkLogger();		log.info(mh(methodName, message));	}	/**	 * <p>	 * Log an error with info log level.	 * </p>	 * 	 * @param methodName	 *            The name of the method that issued this message.	 * @param message	 *            The log message.	 * @param throwable	 *            The cause for this message.	 */	public void info(String methodName, Object message, Throwable throwable) {		checkLogger();		log.info(mh(methodName, message), throwable);	}	/**	 * <p>	 * Log a message with info log level.	 * </p>	 * 	 * @param message	 *            The log message.	 */	public void info(Object message) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -