- Spring3.X의 aop Namespace를 이용하여
-------------------------------OnjWorldImpl --------------------------------------
package onj.edu.project_Namespace;
import onj.edu.project.OnjWorld;
public class OnjWorldImpl {
public void onjHello(){
System.out.println("Onj에 오신것을 환영합니다. ----Hello1----");
}
public void onjHello1() throws Exception{
System.out.println("Onj에 오신것을 환영합니다.---- Hello2----");
//throw new Exception("Exception");
}
public void onjGoodBye(){
System.out.println("끝났어요~~~~~~");
}
}
----------------------------------- OnjWorldBean -----------------------------
package onj.edu.project_Namespace;
public class OnjWorldBean {
private OnjWorldImpl dependency;
public void run() throws Exception{
dependency.onjHello();
dependency.onjHello1();
dependency.onjGoodBye();
}
public void setDependency(OnjWorldImpl dependency){
this.dependency = dependency;
}
}
-------------------- OnjWorldAdvice ----------------------------------------------------
package onj.edu.project_Namespace;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
public class OnjWorldAdvice {
public void beforeAdvice(JoinPoint joinPoint){
System.out.println("----비포 실행----"
+ joinPoint.getSignature().getDeclaringTypeName()+ ","
+ joinPoint.getSignature().getName());
}
public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable{
System.out.println("----어라운드 비포 실행----"
+ joinPoint.getSignature().getDeclaringTypeName()+ ","
+ joinPoint.getSignature().getName());
Object rVal = joinPoint.proceed();
System.out.println("----어라운드 에프터 실행----"
+ joinPoint.getSignature().getDeclaringTypeName()+ ","
+ joinPoint.getSignature().getName());
return rVal;
}
}
------------------------------ OnjWorldExam -------------------------------------
package onj.edu.project_Namespace;
import org.springframework.context.support.GenericXmlApplicationContext;
public class OnjWorldExam {
public static void main(String args[]) throws Exception{
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load("worldName.xml");
ctx.refresh();
OnjWorldBean bean = (OnjWorldBean)ctx.getBean("onjWorldBean");
System.out.println("--------bean------------");
bean.run();
ctx.close();
}
}
----------------------------- worldName ---------------------------------------------
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<aop:config>
<aop:pointcut id="onjpointcut" __EXPRESSION__="execution(* onj.edu.project_Namespace..onjHello(..))"/>
<aop:aspect ref="advice">
<aop:before pointcut-ref ="onjpointcut" method="beforeAdvice"/>
<aop:around pointcut-ref="onjpointcut" method="aroundAdvice"/>
</aop:aspect>
</aop:config>
<bean id="advice" class="onj.edu.project_Namespace.OnjWorldAdvice"/>
<bean id="onjWorldImpl" class="onj.edu.project_Namespace.OnjWorldImpl"/>
<bean id="onjWorldBean" class="onj.edu.project_Namespace.OnjWorldBean">
<property name="dependency" ref="onjWorldImpl"/>
</bean>
</beans>
[출처] 오라클자바커뮤니티 -
http://www.oraclejavanew.kr/bbs/board.php?bo_table=Cyber&wr_id=642
오라클자바커뮤니티에서 운영, 개발자 전문교육,
개인80%환급 오엔제이프로그래밍실무교육센터(www.onjprogramming.co.kr)
평일주간(9:30~18:20) 개강
(4/29)[기업100%환급]PL/SQL,ORACLE HINT,TUNING
(4/29)[기업100%환급]자바기초에서 JDBC, Servlet/JSP까지
(4/29)C#4.0,ADO.NET,Network 프로그래밍
(5/12)[기업100%환급]Spring ,MyBatis,Hibernate실무과정
(5/12)[기업100%환급]SQL기초에서 Schema Object까지
(5/12)안드로이드개발자과정
(5/21)[교육전취업확정]Spring,MyBatis,XPlatform실무프로젝트과정
평일야간(19:00~21:50) 개강
(4/25)안드로이드개발자과정
(5/07)Spring3.X, MyBatis, Hibernate실무과정
(5/09)웹퍼블리싱 마스터
(5/09)JAVA&WEB프레임워크실무과정
(5/09)SQL초보에서실전전문가까지
(5/16)자바웹(JSP,Spring,MyBatis,XPlatform)프로젝트과정
(5/16)C#,ASP.NET마스터
(5/20)개발자를위한PLSQL,SQL튜닝,힌트
주말(10:00~18:00) 개강
(5/03)JAVA&WEB프레임워크실무과정
(5/03)안드로이드개발자과정
(5/03)C#,ASP.NET마스터
(5/10)닷넷실무자를위한WPF개발자과정
(5/10)SQL초보에서실전전문가까지
(5/10)Spring3.X, MyBatis, Hibernate실무과정
(5/11)웹퍼블리싱 마스터
(5/17)자바기초에서JSP,Ajax,jQuery,Spring3.2,MyBatis까지
(5/17)개발자를위한PLSQL,SQL튜닝,힌트
주말저녁(18:30~22:20) 개강
(5/17)자바&웹,jQUERY,스프링프레임워크
(5/17)SQL기초에서 Schema Object까지
평일주간(9:30~18:20) 개강
(4/29)[기업100%환급]PL/SQL,ORACLE HINT,TUNING
(4/29)[기업100%환급]자바기초에서 JDBC, Servlet/JSP까지
(4/29)C#4.0,ADO.NET,Network 프로그래밍
(5/12)[기업100%환급]Spring ,MyBatis,Hibernate실무과정
(5/12)[기업100%환급]SQL기초에서 Schema Object까지
(5/12)안드로이드개발자과정
(5/21)[교육전취업확정]Spring,MyBatis,XPlatform실무프로젝트과정
평일야간(19:00~21:50) 개강
(4/25)안드로이드개발자과정
(5/07)Spring3.X, MyBatis, Hibernate실무과정
(5/09)웹퍼블리싱 마스터
(5/09)JAVA&WEB프레임워크실무과정
(5/09)SQL초보에서실전전문가까지
(5/16)자바웹(JSP,Spring,MyBatis,XPlatform)프로젝트과정
(5/16)C#,ASP.NET마스터
(5/20)개발자를위한PLSQL,SQL튜닝,힌트
주말(10:00~18:00) 개강
(5/03)JAVA&WEB프레임워크실무과정
(5/03)안드로이드개발자과정
(5/03)C#,ASP.NET마스터
(5/10)닷넷실무자를위한WPF개발자과정
(5/10)SQL초보에서실전전문가까지
(5/10)Spring3.X, MyBatis, Hibernate실무과정
(5/11)웹퍼블리싱 마스터
(5/17)자바기초에서JSP,Ajax,jQuery,Spring3.2,MyBatis까지
(5/17)개발자를위한PLSQL,SQL튜닝,힌트
주말저녁(18:30~22:20) 개강
(5/17)자바&웹,jQUERY,스프링프레임워크
(5/17)SQL기초에서 Schema Object까지
댓글 없음:
댓글 쓰기