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

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

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

    posts - 431,  comments - 344,  trackbacks - 0

    使用handler(TypePattern)切入點(diǎn)。語法:
    pointcut <pointcut name>(<any values to be picked uo>) : handler(<class>) ;
    handler(TypePattern)切入點(diǎn)只支持vbefore()形式的通知。這意味著不能使用像around()這樣的通知來重寫catch塊的正常行為。

    public aspect HandlerRecipe {
     pointcut myExceptionHandlerPointcut() : handler(ServiceException);
     before() : myExceptionHandlerPointcut() {
      System.out.println("------------ Aspect Advice Logic --------------");
      System.out.println("Signature: " + thisJoinPoint.getStaticPart().getSignature());
      System.out.println("Source Line: " + thisJoinPoint.getStaticPart().getSourceLocation());
      System.out.println("-----------------------------------------------");
     }
    }


    public class ServiceException extends Exception {

     /**
      * Create a new ServiceException with the specified message.
      * @param msg the detail message
      */
     public ServiceException(String msg) {
      super(msg);
     }

     /**
      * Create a new ServiceException with the specified message
      * and root cause.
      * @param msg the detail message
      * @param ex the root cause
      */
     public ServiceException(String msg, Throwable ex) {
      super(msg, ex);
     }
    }

    public class ExceptionClass {

     public void triggerMyException() throws ServiceException
        {
      ServiceException myException = new ServiceException("A service exception has occured");
           System.out.println("About to throw a ServiceException");
           throw myException;
        }
     /**
      * @param args
      */
     public static void main(String[] args) {
      ExceptionClass myObject = new ExceptionClass();
       try
           {
              myObject.triggerMyException();
           } catch (ServiceException me)
           {
              System.out.println("A ServiceException has been caught");
           }
     }

    }

    運(yùn)行結(jié)果:
    About to throw a ServiceException
    ------------ Aspect Advice Logic --------------
    Signature: catch(ServiceException)
    Source Line: ExceptionClass.java:19
    -----------------------------------------------
    A ServiceException has been caught

    獲取拋出的異常
    public aspect HandlerRecipe {
     pointcut myExceptionHandlerPointcut(ServiceException exception) : handler(ServiceException) && args(exception);
     before(ServiceException exception) : myExceptionHandlerPointcut(exception) {
      System.out.println("------------ Aspect Advice Logic --------------");
      System.out.println("Signature: " + thisJoinPoint.getStaticPart().getSignature());
      System.out.println("Source Line: " + thisJoinPoint.getStaticPart().getSourceLocation());
      System.out.println("Exception caught:");
      exception.printStackTrace();
      System.out.println("-----------------------------------------------");
     }
    }

    posted on 2007-07-03 16:32 周銳 閱讀(308) 評論(0)  編輯  收藏 所屬分類: AspectJ
    主站蜘蛛池模板: 日韩在线观看免费| 另类免费视频一区二区在线观看| 日本免费一区二区三区最新 | 亚洲精品乱码久久久久久按摩| 鲁丝片一区二区三区免费| 中文字幕 亚洲 有码 在线 | 亚洲一区二区三区偷拍女厕| 在线观看永久免费| 黄色a级免费网站| 亚洲综合国产精品| 免费一级成人毛片| **一级毛片免费完整视| 真人无码作爱免费视频| 亚洲色大成网站www永久| gogo全球高清大胆亚洲| 久久久精品2019免费观看| 美女裸免费观看网站| 亚洲成人黄色网址| 成人午夜亚洲精品无码网站| 最近免费中文字幕视频高清在线看| 久久久WWW免费人成精品| 亚洲欧美日韩中文字幕一区二区三区| 国产亚洲人成网站观看| 国产又粗又猛又爽又黄的免费视频| 免费看搞黄视频网站| 免费一级全黄少妇性色生活片| 亚洲国产成人精品久久| 亚洲欧洲自拍拍偷午夜色无码| 国产一精品一aⅴ一免费| 91网站免费观看| 久久国产精品免费观看| 国产精品亚洲一区二区三区 | 国产成人无码免费网站| 亚洲狠狠婷婷综合久久蜜芽| 亚洲制服中文字幕第一区| 相泽亚洲一区中文字幕| 四虎影视永久免费视频观看| 欧美三级在线电影免费| 四虎1515hh永久久免费| 久久成人免费大片| 国内永久免费crm系统z在线|