Java tutorial
/* * Copyright 2008-2009 MOPAS(Ministry of Public Administration and Security). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package egovframework.rte.fdl.cmmn.trace; import java.util.Locale; import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.springframework.context.MessageSource; import org.springframework.util.AntPathMatcher; import org.springframework.util.PathMatcher; import egovframework.rte.fdl.cmmn.trace.manager.TraceHandlerService; /** * LeaveaTrace * * <p><b>NOTE:</b> LeaveaTrace ?? ?? Exception ? ? ?? ? . * AbstractServiceImpl ??? leavaTrace() ? ? ?? ?? . * ? ? ? ? . </b> * * @author Judd Cho (horanghi@gmail.com) * @since 2009.06.01 * @version 1.0 * @see * * <pre> * << ?(Modification Information) >> * * ? ? * ------- -------- --------------------------- * 2009.05.30 Judd Cho ? * * </pre> */ public class LeaveaTrace { @Resource(name = "messageSource") private MessageSource messageSource; private static final long serialVersionUID = 1L; private TraceHandlerService[] traceHandlerServices; private PathMatcher pm = new AntPathMatcher(); /** * setTraceHandlerServices * @param traceHandlerServices ? Handler Manager */ public void setTraceHandlerServices(TraceHandlerService[] traceHandlerServices) { this.traceHandlerServices = traceHandlerServices; } /** * ?? TraceHandlerService . */ public int countOfTheTraceHandlerService() { return (traceHandlerServices != null) ? traceHandlerServices.length : 0; } /** * trace * @param msgKey * @param clazz leaveaTrace ? ? */ public void trace(String msgKey, Class<?> clazz) { this.trace(msgKey, new String[] {}, clazz); } /** * trace * @param msgKey * @param msgArgs ? * @param clazz leaveaTrace ? ? */ public void trace(String msgKey, String[] msgArgs, Class<?> clazz) { trace(msgKey, msgArgs, null, clazz); } /** * trace * @param msgKey * @param msgArgs ? * @param clazz leaveaTrace ? ? */ public void trace(String msgKey, String[] msgArgs, Locale locale, Class<?> clazz) { // traceObj. trace(clazz, messageSource, msgKey, msgArgs, locale, null); } /** * trace * @param clazz leaveaTrace ? ? * @param messageKey * @param messageParameters ? * @param locale / */ public void trace(Class<?> clazz, MessageSource messageSource, String messageKey, Object[] messageParameters, Locale locale) { this.trace(clazz, messageSource, messageKey, messageParameters, locale, null); } /** * trace * @param clazz leaveaTrace ? ? * @param messageKey * @param messageParameters ? * @param locale / * @param log ? */ public void trace(Class<?> clazz, MessageSource messageSource, String messageKey, Object[] messageParameters, Locale locale, Log log) { String message = messageSource.getMessage(messageKey, messageParameters, null, locale); if (log != null) { log.info(" LeaveaTrace.trace() this.message =>" + message); } if (traceHandlerServices == null) return; for (TraceHandlerService traceHandlerService : traceHandlerServices) { if (traceHandlerService.hasReqExpMatcher()) { traceHandlerService.setReqExpMatcher(pm); } traceHandlerService.setPackageName(clazz.getCanonicalName()); traceHandlerService.trace(clazz, message); } } }