<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>


    posts - 10,comments - 4,trackbacks - 0

    接口修改為
    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();}
    ?}

    }

    posted on 2006-03-28 12:57 dodoma 閱讀(244) 評論(0)  編輯  收藏 所屬分類: spring
    主站蜘蛛池模板: 亚洲黄色在线视频| 亚洲一区二区三区在线观看精品中文 | 久久免费看黄a级毛片| 亚洲成在人天堂在线| 久久成人无码国产免费播放| 久久亚洲精品中文字幕三区| 中文字幕成人免费高清在线| 亚洲亚洲人成综合网络| 光棍天堂免费手机观看在线观看 | 免费人妻无码不卡中文字幕18禁| 日韩欧美亚洲中文乱码| 亚洲 小说区 图片区 都市| 日本高清免费中文在线看| 亚洲va中文字幕无码| 皇色在线免费视频| 久久久久亚洲av无码专区蜜芽| 免费A级毛片无码专区| 亚洲成AV人片久久| 午夜精品在线免费观看| 偷自拍亚洲视频在线观看| 国产成人麻豆亚洲综合无码精品| 国产在线一区二区综合免费视频| 久久精品蜜芽亚洲国产AV| 99精品全国免费观看视频| 老牛精品亚洲成av人片| 91麻豆国产自产在线观看亚洲| 久久综合国产乱子伦精品免费| 亚洲一卡2卡3卡4卡乱码 在线| 四虎影视免费永久在线观看| 国产成人无码区免费网站| 亚洲免费观看网站| 精品亚洲一区二区三区在线观看| 午夜精品射精入后重之免费观看 | 亚洲国产成人99精品激情在线| 青青草国产免费久久久下载| 成在线人视频免费视频| 亚洲欧洲春色校园另类小说| 国产做床爱无遮挡免费视频| 免费看搞黄视频网站| 无码一区二区三区亚洲人妻| 老司机亚洲精品影院无码|