logcomponent.java
来自「提供ESB 应用mule源代码 提供ESB 应用mule源代码」· Java 代码 · 共 44 行
JAVA
44 行
/* * $Id: LogComponent.java 10529 2008-01-25 05:58:36Z dfeist $ * -------------------------------------------------------------------------------------- * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com * * The software in this package is published under the terms of the CPAL v1.0 * license, a copy of which has been included with this distribution in the * LICENSE.txt file. */package org.mule.component.simple;import org.mule.api.MuleEventContext;import org.mule.api.component.simple.LogService;import org.mule.api.lifecycle.Callable;import org.mule.util.StringMessageUtils;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;/** * <code>LogComponent</code> simply logs the content (or content length if it is a * large message) */public class LogComponent implements Callable, LogService{ private static Log logger = LogFactory.getLog(LogComponent.class); public Object onCall(MuleEventContext context) throws Exception { String contents = context.getMessageAsString(); String msg = "Message received in service: " + context.getService().getName(); msg = StringMessageUtils.getBoilerPlate(msg + ". Content is: '" + StringMessageUtils.truncate(contents, 100, true) + "'"); log(msg); return null; } public void log(String message) { logger.info(message); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?