=== anyframe
--context-annotaion.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <!--AOP(Aspect Oriented Programming)--> <aop:aspectj-autoproxy /> <!--Bean Definition--> <context:component-scan base-package="com.everland" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" /> <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" /> </context:component-scan> </beans>
--context-transaction.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <util:properties id="contextProperties" location="classpath:context.properties"/> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="#{contextProperties.driver}"/> <property name="url" value="#{contextProperties.url}"/> <property name="username" value="#{contextProperties.username}"/> <property name="password" value="#{contextProperties.password}"/> </bean> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <tx:annotation-driven transaction-manager="txManager" /> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="*" rollback-for="Exception" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="mipServiceRequiredTx" expression="execution(* *..MiPService.*(..))"/> <aop:pointcut id="dynamicHibernateRequiredTx" expression="execution(* *..*DynamicHibernateService.*(..))"/> <aop:pointcut id="jobRequiredTx" expression="execution(* *..job..*Job.execute(..))"/> <aop:pointcut id="flexRequiredTx" expression="execution(* *..FlexService.*(..))"/> <aop:advisor advice-ref="txAdvice" order="2" pointcut-ref="flexRequiredTx" /> <aop:advisor advice-ref="txAdvice" order="2" pointcut-ref="mipServiceRequiredTx" /> <aop:advisor advice-ref="txAdvice" order="2" pointcut-ref="dynamicHibernateRequiredTx" /> <aop:advisor advice-ref="txAdvice" order="2" pointcut-ref="jobRequiredTx" /> </aop:config> </beans>
--doremi
--root-context.xml
<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:arid="http://chrisrichardson.net/schema/arid" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://chrisrichardson.net/schema/arid http://chrisrichardson.net/schema/arid.xsd"> <!-- aop 관련 --> <!-- Advice 클래스를 빈으로 등록 --> <bean id="performanceTraceAdvice" class="com.everland.ws.doremi.common.log.ProfilingAdvice" /> <!-- Aspect 설정: Advice를 어떤 Pointcut에 적용할 지 설정 --> <aop:config> <aop:aspect id="traceAspect1" ref="performanceTraceAdvice"> <aop:pointcut id="publicMethod" expression="execution(public * com.everland.ws.*.doremi.*.*.*(..))" /> <aop:around pointcut-ref="publicMethod" method="trace" /> </aop:aspect> </aop:config> <!-- db 관련 끝 --> <util:properties id="db" location="classpath:db.properties"/> <beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <beans:property name="driverClassName" value="#{db['db.driverClassName']}" /> <beans:property name="url" value="#{db['db.url']}" /> <beans:property name="username" value="#{db['db.username']}" /> <beans:property name="password" value="#{db['db.password']}" /> </beans:bean> <!-- jdbc setting --> <beans:bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <beans:property name="dataSource" ref="dataSource"/> </beans:bean> <beans:bean id="simplejdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate"> <beans:constructor-arg ref="dataSource"/> </beans:bean> <!-- ibatis setting --> <beans:bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <beans:property name="dataSource" ref="dataSource"/> <beans:property name="configLocation" value="WEB-INF/sqlMap/sqlMapConfig.xml"/> </beans:bean> <beans:bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <beans:property name="sqlMapClient" ref="sqlMapClient"/> </beans:bean> <!-- db 관련 끝 --> <arid:define-beans package="com.everland.ws.sd.doremi.service" /> <arid:define-beans package="com.everland.ws.mm.doremi.service" /> <context:annotation-config /> <context:component-scan base-package="com.everland" /> </beans:beans>
package com.everland.ws.doremi.common.log; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Locale; import java.util.Map; import org.aspectj.lang.ProceedingJoinPoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StopWatch; import com.everland.ws.doremi.common.domain.ReturnModel; import com.everland.ws.doremi.common.service.impl.XiLogDao; public class ProfilingAdvice { @Autowired private XiLogDao xiLogDao; public Object trace(ProceedingJoinPoint joinPoint) throws Throwable { Map log = new HashMap(); StopWatch stopWatch = new StopWatch(); long startTime = System.currentTimeMillis(); long endTime; SimpleDateFormat formatter = new SimpleDateFormat ( "yyyyMMddHHmmss", Locale.KOREA ); DecimalFormat df = new DecimalFormat("0.##"); Object retVal = joinPoint.proceed(); endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis (); Date stDate = new Date ( startTime ); Date edDate = new Date ( endTime ); String strStartDate = formatter.format ( stDate ); String strEndDate = formatter.format ( edDate ); String strResDate = df.format((Double.parseDouble(""+endTime) - Double.parseDouble(""+startTime))/1000); ReturnModel model = (ReturnModel)retVal; String interfaceId=joinPoint.getTarget().getClass().getName(); String interfaceMethod=joinPoint.getSignature().getName(); log.put("if_id", interfaceId); //인터페이스 아이디 log.put("if_method", interfaceMethod); //인터페이스 메소드 log.put("st_date", strStartDate.substring(0, 8)); //요청 시작일 log.put("st_time", strStartDate.substring(8)); //요청 시간 log.put("ed_date", strEndDate.substring(0, 8)); //응답 시작일 log.put("ed_time", strEndDate.substring(8)); //응답 시간 log.put("res_time", strResDate); //수행시간 log.put("status", model.getZSTATUS() != null ? model.getZSTATUS() : "N"); //처리결과 상태 log.put("message", model.getZMESSAGE()!= null ? model.getZMESSAGE() : "No Header Message"); //결과메세지 // for ( Iterator it = log.entrySet () .iterator () ; it.hasNext () ; ) { // Map.Entry entry = ( Map.Entry ) it.next () ; // Object key = entry.getKey () ; // Object value = entry.getValue () ; // System.out.println((String)key+" : "+(String)value); // } xiLogDao.saveXiLog(log); return retVal; // StringBuffer logMessageStringBuffer = new StringBuffer(); // logMessageStringBuffer.append(" 결과메세지 : "+model.getZMESSAGE()+"\r\n"); // logMessageStringBuffer.append(" 인터페이스 아이디 : "+joinPoint.getTarget().getClass().getName()+"\r\n"); // logMessageStringBuffer.append(" 메소드명 : "+joinPoint.getSignature().getName()+"\r\n"); // logMessageStringBuffer.append(" 파라미터 : "+ joinPoint.getArgs()+"\r\n"); // logMessageStringBuffer.append(" 요청 시작일 : "+ strStartDate.substring(0, 8)+"\r\n"); // logMessageStringBuffer.append(" 요청 시간 : "+ strStartDate.substring(8)+"\r\n"); // logMessageStringBuffer.append(" 응답 시작일 : "+ strEndDate.substring(0, 8)+"\r\n"); // logMessageStringBuffer.append(" 응답 시간 : "+ strEndDate.substring(8)+"\r\n"); // logMessageStringBuffer.append(" 수행시간 : "+ strResDate+"\r\n"); // logMessageStringBuffer.append(" 처리결과 상태 : "+ model.getZSTATUS()+"\r\n"); // System.out.println(logMessageStringBuffer.toString()); } }