锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲AV无码成人专区,亚洲爆乳少妇无码激情,亚洲av无码电影网http://www.tkk7.com/dodoma/category/9020.htmlzh-cnWed, 28 Feb 2007 04:12:25 GMTWed, 28 Feb 2007 04:12:25 GMT60spring涔媋op:LogThrowAdvicehttp://www.tkk7.com/dodoma/archive/2006/03/28/37768.htmldodomadodomaTue, 28 Mar 2006 04:57:00 GMThttp://www.tkk7.com/dodoma/archive/2006/03/28/37768.htmlhttp://www.tkk7.com/dodoma/comments/37768.htmlhttp://www.tkk7.com/dodoma/archive/2006/03/28/37768.html#Feedback0http://www.tkk7.com/dodoma/comments/commentRss/37768.htmlhttp://www.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://www.tkk7.com/dodoma/archive/2006/03/28/37766.htmldodomadodomaTue, 28 Mar 2006 04:52:00 GMThttp://www.tkk7.com/dodoma/archive/2006/03/28/37766.htmlhttp://www.tkk7.com/dodoma/comments/37766.htmlhttp://www.tkk7.com/dodoma/archive/2006/03/28/37766.html#Feedback1http://www.tkk7.com/dodoma/comments/commentRss/37766.htmlhttp://www.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://www.tkk7.com/dodoma/archive/2006/03/28/37761.htmldodomadodomaTue, 28 Mar 2006 04:37:00 GMThttp://www.tkk7.com/dodoma/archive/2006/03/28/37761.htmlhttp://www.tkk7.com/dodoma/comments/37761.htmlhttp://www.tkk7.com/dodoma/archive/2006/03/28/37761.html#Feedback0http://www.tkk7.com/dodoma/comments/commentRss/37761.htmlhttp://www.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://www.tkk7.com/dodoma/archive/2006/03/28/37755.htmldodomadodomaTue, 28 Mar 2006 04:02:00 GMThttp://www.tkk7.com/dodoma/archive/2006/03/28/37755.htmlhttp://www.tkk7.com/dodoma/comments/37755.htmlhttp://www.tkk7.com/dodoma/archive/2006/03/28/37755.html#Feedback0http://www.tkk7.com/dodoma/comments/commentRss/37755.htmlhttp://www.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 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 青青免费在线视频| 国产永久免费高清在线| 亚洲精品456播放| 男人j进入女人j内部免费网站 | 91精品免费国产高清在线| 亚洲日本VA中文字幕久久道具| 亚洲精品国精品久久99热| 亚洲精品在线免费观看视频| 久久人午夜亚洲精品无码区| 亚洲Av无码精品色午夜| 成年人免费网站在线观看| 在线免费观看一级毛片| 一级一级一片免费高清| 亚洲一区二区三区在线| 亚洲啪啪AV无码片| 在线jlzzjlzz免费播放| 久久成人免费电影| 男人j进女人p免费视频| 亚洲伊人色一综合网| 中文字幕亚洲图片| 免费鲁丝片一级观看| 99热在线免费观看| a级毛片免费高清视频| 亚洲熟妇无码AV| 亚洲今日精彩视频| 2022中文字字幕久亚洲| 免费a级毛片高清视频不卡 | 国产又黄又爽又大的免费视频| 激情综合亚洲色婷婷五月APP| 国产成人精品日本亚洲专区61| 成年女人免费视频播放77777 | 国产精品成人免费综合| 精品一区二区三区免费毛片爱| 四虎精品免费永久免费视频| 久久乐国产综合亚洲精品| 亚洲精品无码不卡| 亚洲国产综合无码一区| 亚洲中文无韩国r级电影| 免费看国产曰批40分钟| 思思99re66在线精品免费观看| 每天更新的免费av片在线观看|