锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲AV无码成人专区,亚洲爆乳少妇无码激情,亚洲av无码电影网http://m.tkk7.com/dodoma/category/9020.htmlzh-cnWed, 28 Feb 2007 04:12:25 GMTWed, 28 Feb 2007 04:12:25 GMT60spring涔媋op:LogThrowAdvicehttp://m.tkk7.com/dodoma/archive/2006/03/28/37768.htmldodomadodomaTue, 28 Mar 2006 04:57:00 GMThttp://m.tkk7.com/dodoma/archive/2006/03/28/37768.htmlhttp://m.tkk7.com/dodoma/comments/37768.htmlhttp://m.tkk7.com/dodoma/archive/2006/03/28/37768.html#Feedback0http://m.tkk7.com/dodoma/comments/commentRss/37768.htmlhttp://m.tkk7.com/dodoma/services/trackbacks/37768.html鎺ュ彛淇敼涓?br />package net.blogjava.dodoma.spring.aop;

public interface HelloI {
聽public String sayHello(String firstName,String lastName)throws Exception;
聽}

綾諱慨鏀逛負
package net.blogjava.dodoma.spring.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Hello implements HelloI {
聽protected static final Log log=LogFactory.getLog(Hello.class);
聽private String msg;
聽public Hello(){}
聽public Hello(String msg){
聽聽this.msg=msg;
聽}

聽public String getMsg() {
聽聽return msg;
聽}
聽public void setMsg(String msg) {
聽聽this.msg = msg;
聽}
聽public String sayHello(String firstName, String lastName) throws Exception{
聽聽// TODO Auto-generated method stub
聽聽log.info("in the class "+this.getClass().getName()+"'s method sayHello()");
聽 throw new Exception("here is a exception !");
聽聽return (msg+" "+firstName+" "+lastName);
聽}
}



package net.blogjava.dodoma.spring.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.ThrowsAdvice;

public class LogThrowAdvice implements ThrowsAdvice {
聽protected static final Log log = LogFactory.getLog(LogThrowAdvice.class);
聽public void afterThrowing(Exception e)throws Throwable{
聽聽log.info("in the class "+this.getClass().getName()+"'s method afterThrowing()");
聽聽log.info("the exception is "+e.getMessage());
聽}
}


package net.blogjava.dodoma.spring.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class HelloTest {
聽protected static final Log log = LogFactory.getLog(HelloTest.class);

聽/**
聽 * @param args
聽 * @throws Exception
聽 */
聽public static void main(String[] args) throws Exception {
聽聽// TODO Auto-generated method stub
聽聽Resource rs = new ClassPathResource("beans.xml");
聽聽BeanFactory bf = new XmlBeanFactory(rs);

聽聽HelloI h = (HelloI) bf.getBean("theBean");
聽聽log.info("starting...");
聽聽try {
聽聽聽log.info(h.sayHello("ma", "bin"));
聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽}
聽聽log.info("end...");
聽聽
聽聽
聽聽ProxyFactory factory=new ProxyFactory();
聽聽factory.addAdvice(new LogThrowAdvice ());
聽聽factory.setTarget(new Hello("hello"));
聽聽try{
聽聽HelloI hi=(HelloI)factory.getProxy();
聽聽hi.sayHello("ma","bin");}
聽聽catch(Exception e){e.printStackTrace();}
聽}

}



dodoma 2006-03-28 12:57 鍙戣〃璇勮
]]>
spring涔媋op:LogAroundAdvicehttp://m.tkk7.com/dodoma/archive/2006/03/28/37766.htmldodomadodomaTue, 28 Mar 2006 04:52:00 GMThttp://m.tkk7.com/dodoma/archive/2006/03/28/37766.htmlhttp://m.tkk7.com/dodoma/comments/37766.htmlhttp://m.tkk7.com/dodoma/archive/2006/03/28/37766.html#Feedback1http://m.tkk7.com/dodoma/comments/commentRss/37766.htmlhttp://m.tkk7.com/dodoma/services/trackbacks/37766.htmlLogAroundAdvice 閫氱煡
package net.blogjava.dodoma.spring.aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LogAroundAdvice implements MethodInterceptor {
聽protected static final Log log = LogFactory.getLog(LogAroundAdvice.class);

聽public Object invoke(MethodInvocation arg) throws Throwable {
聽聽//聽璋冪敤鐩爣瀵硅薄涔嬪墠
聽聽log.info("before the target object");
聽聽Object val=arg.proceed();
聽 //璋冪敤鐩爣瀵硅薄涔嬪悗
聽聽log.info("the arg is "+arg);
聽聽log.info("after the target object");
聽聽return val;
聽}

}

嫻嬭瘯鏂規硶

package net.blogjava.dodoma.spring.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class HelloTest {
聽protected static final Log log = LogFactory.getLog(HelloTest.class);

聽/**
聽 * @param args
聽 * @throws Exception
聽 */
聽public static void main(String[] args) throws Exception {
聽聽// TODO Auto-generated method stub
聽聽Resource rs = new ClassPathResource("beans.xml");
聽聽BeanFactory bf = new XmlBeanFactory(rs);

聽聽HelloI h = (HelloI) bf.getBean("theBean");
聽聽log.info("starting...");
聽聽try {
聽聽聽log.info(h.sayHello("ma", "bin"));
聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽}
聽聽log.info("end...");
聽聽
聽聽
聽聽ProxyFactory factory=new ProxyFactory();
聽聽factory.addAdvice(new LogAroundAdvice ());
聽聽factory.setTarget(new Hello("hello"));
聽聽try{
聽聽HelloI hi=(HelloI)factory.getProxy();
聽聽hi.sayHello("ma","bin");}
聽聽catch(Exception e){e.printStackTrace();}
聽}

}



dodoma 2006-03-28 12:52 鍙戣〃璇勮
]]>
spring涔媋op:LogAfterAdvicehttp://m.tkk7.com/dodoma/archive/2006/03/28/37761.htmldodomadodomaTue, 28 Mar 2006 04:37:00 GMThttp://m.tkk7.com/dodoma/archive/2006/03/28/37761.htmlhttp://m.tkk7.com/dodoma/comments/37761.htmlhttp://m.tkk7.com/dodoma/archive/2006/03/28/37761.html#Feedback0http://m.tkk7.com/dodoma/comments/commentRss/37761.htmlhttp://m.tkk7.com/dodoma/services/trackbacks/37761.html鎺ュ彛鍜屽疄鐜扮被瑙丩ogBeforeAdvice鐨勪緥瀛?br />package net.blogjava.dodoma.spring.aop;

import java.lang.reflect.Method;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.AfterReturningAdvice;

public class LogAfterAdvice implements AfterReturningAdvice {
聽protected static final Log log = LogFactory.getLog(LogAfterAdvice.class);
聽public void afterReturning(Object returnVal, Method m, Object[] args,
聽聽聽Object target) throws Throwable {
聽聽// TODO Auto-generated method stub
聽聽log.info("in the class "+this.getClass().getName()+"'s method afterReturning()");

聽聽log.info("the target class is:" + target.getClass().getName());
聽聽log.info("the target method is:" + m.getName());

聽聽for (int i = 0; i < args.length; i++) {
聽聽聽log.info("the method's args is:" + args[i]);
聽聽}
聽聽
聽聽log.info("the returnValue is "+returnVal);
聽聽//嫻嬭瘯,濡傛灉榪斿洖瑁呭鍙戠敓浜嗗紓甯?灝嗗浣曞鐞嗙▼搴忔祦紼?br />聽聽//throw new Exception("榪斿洖瑁呭鍙戠敓寮傚父");
聽}

}

嫻嬭瘯浠g爜

package net.blogjava.dodoma.spring.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class HelloTest {
聽protected static final Log log = LogFactory.getLog(HelloTest.class);

聽/**
聽 * @param args
聽 * @throws Exception
聽 */
聽public static void main(String[] args) throws Exception {
聽聽// TODO Auto-generated method stub
聽聽Resource rs = new ClassPathResource("beans.xml");
聽聽BeanFactory bf = new XmlBeanFactory(rs);

聽聽HelloI h = (HelloI) bf.getBean("theBean");
聽聽log.info("starting...");
聽聽try {
聽聽聽log.info(h.sayHello("ma", "bin"));
聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽}
聽聽log.info("end...");
聽聽
聽聽
聽聽ProxyFactory factory=new ProxyFactory();
聽聽factory.addAdvice(new LogAfterAdvice());
聽聽factory.setTarget(new Hello("hello"));
聽聽try{
聽聽HelloI hi=(HelloI)factory.getProxy();
聽聽hi.sayHello("ma","bin");}
聽聽catch(Exception e){e.printStackTrace();}
聽}

}


鍦╞eans.xml涓姞鍏ュ涓嬩唬鐮?br /><bean id="theLogAfterAdvice" class="net.blogjava.dodoma.spring.aop.LogAfterAdvice"/>

<property name="interceptorNames">
聽聽聽聽聽 <list>
聽聽聽聽聽聽聽 <value>theLogAfterAdvice</value><!--姝ゆ椂鐩存帴浣跨敤advice,琛ㄦ槑榪欎釜綾繪墍鏈夌殑瀹炰緥,鏂規硶,閮戒韓鍙梐dvice鐨勬嫤鎴?->
聽聽聽聽聽聽 </list>聽
</property>

鍒囧叆鐐瑰彲鐪佺暐,濡傞渶瑕佺殑璇?br />濡?br />
<!--鍒囧叆鐐?->
聽 <!--Note: An advisor assembles pointcut and advice-->
聽 <bean id="theBeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
聽聽聽 <property name="advice">
聽聽聽聽聽 <ref local="theLogAfterAdvice"/>
聽聽聽 </property>
聽聽聽 <!--鍖歸厤妯″紡-->
聽聽聽 <property name="pattern">
聽聽聽聽聽 <value>.*</value>
聽聽聽 </property>
聽 </bean>



dodoma 2006-03-28 12:37 鍙戣〃璇勮
]]>
spring涔媋op:LogBeforeAdvicehttp://m.tkk7.com/dodoma/archive/2006/03/28/37755.htmldodomadodomaTue, 28 Mar 2006 04:02:00 GMThttp://m.tkk7.com/dodoma/archive/2006/03/28/37755.htmlhttp://m.tkk7.com/dodoma/comments/37755.htmlhttp://m.tkk7.com/dodoma/archive/2006/03/28/37755.html#Feedback0http://m.tkk7.com/dodoma/comments/commentRss/37755.htmlhttp://m.tkk7.com/dodoma/services/trackbacks/37755.html鎺ュ彛
package net.blogjava.dodoma.spring.aop;

public interface HelloI {
聽public String sayHello(String firstName,String lastName);
聽}

瀹炵幇綾?br />package net.blogjava.dodoma.spring.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Hello implements HelloI {
聽protected static final Log log=LogFactory.getLog(Hello.class);
聽private String msg;
聽public Hello(){}
聽public Hello(String msg){
聽聽this.msg=msg;
聽}
聽public String getMsg() {
聽聽return msg;
聽}
聽public void setMsg(String msg) {
聽聽this.msg = msg;
聽}
聽public String sayHello(String firstName, String lastName) {
聽聽// TODO Auto-generated method stub
聽聽log.info("in the class "+this.getClass().getName()+"'s method sayHello()");
聽聽return (msg+" "+firstName+" "+lastName);
聽}
}

BeforeAdvice閫氱煡

package net.blogjava.dodoma.spring.aop;

import java.lang.reflect.Method;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.MethodBeforeAdvice;

/**
聽* 鏂規硶璋冪敤涔嬪墠.
聽* 鍏堣皟鐢ㄦ鏂規硶
聽* @author dodoma
聽**/
public class LogBeforeAdvice implements MethodBeforeAdvice {
聽protected static final Log log = LogFactory.getLog(LogBeforeAdvice.class);

聽public void before(Method m, Object[] args, Object target) throws Throwable {
聽聽log.info("in the class "+this.getClass().getName()+"'s method before()");

聽聽log.info("the target class is:" + target.getClass().getName());
聽聽log.info("the target method is:" + m.getName());

聽聽for (int i = 0; i < args.length; i++) {
聽聽聽log.info("the method's args is:" + args[i]);
聽聽}
聽聽//嫻嬭瘯,濡傛灉鍦╞efore閫氱煡涓彂鐢熶簡寮傚父,紼嬪簭嫻佺▼灝嗗浣?br />聽聽//throw new Exception("寮傚父");
聽}
}

嫻嬭瘯綾?br />package net.blogjava.dodoma.spring.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class HelloTest {
聽protected static final Log log = LogFactory.getLog(HelloTest.class);
聽public static void main(String[] args) throws Exception {
聽聽// TODO Auto-generated method stub
聽//搴旂敤spring鐨刬oc瀹瑰櫒
聽聽Resource rs = new ClassPathResource("beans.xml");
聽聽BeanFactory bf = new XmlBeanFactory(rs);

聽聽HelloI h = (HelloI) bf.getBean("theBean");
聽聽log.info("starting...");
聽聽try {
聽聽聽log.info(h.sayHello("ma", "bin"));
聽聽聽聽聽} catch (Exception e) {
聽聽聽e.printStackTrace();
聽聽}
聽聽log.info("end...");
聽聽
聽聽//濡傛灉娌℃湁浣跨敤spring鐨刬oc,鍙互鐩存帴鐢ㄥ涓嬩唬鐮佹祴璇?br />聽聽ProxyFactory factory=new ProxyFactory();
聽聽factory.addAdvice(new LogBeforeAdvice());//娣誨姞閫氱煡
聽聽factory.setTarget(new Hello("hello"));//娣誨姞琚唬鐞嗙殑綾誨疄渚?br />聽聽try{
聽聽HelloI hi=(HelloI)factory.getProxy();
聽聽hi.sayHello("ma","bin");}
聽聽catch(Exception e){e.printStackTrace();}
聽}

}

spring鐨勯厤緗枃浠禸eans.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "

<beans>

<!--浜彈鏃ュ織鐨勭被-->
<bean id="theTargetBean" class="net.blogjava.dodoma.spring.aop.Hello">
聽<property name="msg">
聽聽聽 聽<value>hello</value>
聽聽聽 </property>
聽聽聽聽聽
</bean>

<!--advices-->
<bean id="theLogBeforeAdvice" class="net.blogjava.dodoma.spring.aop.LogBeforeAdvice"/>

<!--CONFIG-->
聽 <bean id="theBean" class="org.springframework.aop.framework.ProxyFactoryBean">
聽聽聽 <!--鎺ュ彛-->
聽聽聽 <property name="proxyInterfaces">
聽聽聽聽聽 <value>net.blogjava.dodoma.spring.aop.HelloI</value>
聽聽聽 </property>
聽聽聽 <!--琚唬鐞嗙殑綾?->
聽聽聽 <property name="target">
聽聽聽聽聽 <ref local="theTargetBean"/>
聽聽聽 </property>
聽聽聽 <!--鍔犲湪浠g悊綾諱笂鐨刟dvice-->
聽聽聽 <property name="interceptorNames">
聽聽聽聽聽 <list>
聽聽聽聽聽聽聽 <value>theLogBeforeAdvice</value><!--姝ゆ椂鐩存帴浣跨敤advice,琛ㄦ槑榪欎釜綾繪墍鏈夌殑瀹炰緥,鏂規硶,閮戒韓鍙梐dvice鐨勬嫤鎴?->
聽聽聽聽聽聽</list>
聽聽聽 </property>
聽 </bean>
聽聽
聽 <!--鍒囧叆鐐?鍙互綺劇‘鍖歸厤綾?鏂規硶,涔熷彲浠ヤ笉闇瑕佽繖涓?->
聽 <!--Note: An advisor assembles pointcut and advice-->
聽 <bean id="theBeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
聽聽聽 <property name="advice">
聽聽聽聽聽 <ref local="theLogBeforeAdvice"/>
聽聽聽 </property>
聽聽聽 <!--鍖歸厤妯″紡-->
聽聽聽 <property name="pattern">
聽聽聽聽聽 <value>.*</value>
聽聽聽 </property>
聽 </bean>
聽聽 聽
</beans>



dodoma 2006-03-28 12:02 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲国产成人AV在线播放| 91亚洲国产成人精品下载| 亚洲综合av一区二区三区| 最近中文字幕无免费| 亚洲国产精华液网站w| 久久免费观看视频| 亚洲性在线看高清h片| 免费一级特黄特色大片| 日本免费v片一二三区| 亚洲成a人无码亚洲成www牛牛| 97性无码区免费| 亚洲一级毛片免费观看| 永久在线免费观看| 亚洲系列国产精品制服丝袜第| 午夜精品一区二区三区免费视频| 亚洲男人第一av网站| 美丽的姑娘免费观看在线播放| 亚洲国产美女在线观看| 黄页网站免费在线观看| 亚洲AV成人影视在线观看| 好吊妞788免费视频播放| 午夜在线a亚洲v天堂网2019| 成年女人午夜毛片免费视频| 亚洲AV成人无码网天堂| 亚洲高清无码专区视频| 一个人看的免费视频www在线高清动漫| 久久激情亚洲精品无码?V| 免费91麻豆精品国产自产在线观看 | 最近2019年免费中文字幕高清| 亚洲成人福利网站| 两性刺激生活片免费视频| 亚洲欧美日韩久久精品| 亚洲日韩国产一区二区三区| 黄网站免费在线观看| 自拍日韩亚洲一区在线| 亚洲av片一区二区三区| 久久久久久免费一区二区三区 | 免费在线视频你懂的| 色九月亚洲综合网| 亚洲国产a∨无码中文777| 日本在线高清免费爱做网站|