Examples of ErrorHanlderMethodInfo


Examples of org.crank.metadata.ErrorHanlderMethodInfo

  }


  @Test
  public void testFindOrBuildErrorHandlerMethodInfoForSingle() {
    ErrorHanlderMethodInfo methodInfo =
      errorHandlerAnnotationProcessor.findOrBuildErrorHandlerMethodInfo(method);
    methodInfo.getExceptions().contains(TestException.class);
    assertEquals(true, methodInfo.isDefaultHandlerPresent());
   
    ErrorHanlderMethodInfo methodInfo2 =
      errorHandlerAnnotationProcessor.findOrBuildErrorHandlerMethodInfo(method);
    assertEquals("DEFAULT HANDLER AT CLASS LEVEL", methodInfo.getDefaultErrorHandler().getMessageSummary());   
    assertSame(methodInfo, methodInfo2);

  }
View Full Code Here

Examples of org.crank.metadata.ErrorHanlderMethodInfo

  }

  @Test
  public void testFindOrBuildErrorHandlerMethodInfoForMultiples() {
    ErrorHanlderMethodInfo methodInfo =
      errorHandlerAnnotationProcessor.findOrBuildErrorHandlerMethodInfo(method2);
   
    methodInfo.getExceptions().contains(ArithmeticException.class);
    assertEquals(true, methodInfo.isDefaultHandlerPresent());
    assertEquals("Some sort of fatal issue see details", methodInfo.getDefaultErrorHandler().getMessageSummary());
   
  }
View Full Code Here

Examples of org.crank.metadata.ErrorHanlderMethodInfo

   
  }

  @Test
  public void testFindOrBuildErrorHandlerMethodInfoForClassLevelAnnotation() {
    ErrorHanlderMethodInfo methodInfo =
      errorHandlerAnnotationProcessor.findOrBuildErrorHandlerMethodInfo(method3);
   
    methodInfo.getExceptions().contains(ArithmeticException.class);
    assertEquals(true, methodInfo.isDefaultHandlerPresent());
    assertEquals("DEFAULT HANDLER AT METHOD LEVEL", methodInfo.getDefaultErrorHandler().getMessageSummary());

  }
View Full Code Here

Examples of org.crank.metadata.ErrorHanlderMethodInfo

  /* (non-Javadoc)
   * @see org.crank.message.ErrorHandlerMetaDataProcessor#findOrBuildErrorHandlerMethodInfo(java.lang.reflect.Method)
   */
  public ErrorHanlderMethodInfo findOrBuildErrorHandlerMethodInfo(Method targetMethod) {
    /* Get the ErrorHanlderMethodInfo from the map. */
    ErrorHanlderMethodInfo errorHanlderMethodInfo = errorHandlerInfoMap.get(targetMethod);

    /* If we did not find it in the map, then we have to build it from the annotations. */
    if (errorHanlderMethodInfo == null) {
      List<ErrorHandlerData> errorHandlerList = buildErrorHandlerDataListFromAnnotations(targetMethod);
      errorHanlderMethodInfo = buildErrorHanlderMethodInfoFromList(errorHandlerList);
      errorHanlderMethodInfo.setMethod(targetMethod);
      errorHandlerInfoMap.put(targetMethod, errorHanlderMethodInfo);
    }
    return errorHanlderMethodInfo;
  }
View Full Code Here

Examples of org.crank.metadata.ErrorHanlderMethodInfo

   * Intercept method calls and decorate them with JSF error message handling.
   */
  public Object invoke(MethodInvocation methodInvocation) throws Throwable {
   
    /* Get the ErrorHandleMethodInfo for this method. */
    ErrorHanlderMethodInfo errorHanlderInfo = errorHandlerMetaDataProcessor
                        .findOrBuildErrorHandlerMethodInfo(methodInvocation.getMethod());
   
    Object returnValue = null;

    try {
      /* Try to excecute the method in question. */
      returnValue = methodInvocation.proceed();
     
    } catch (Exception exception) {
     
      /* See if this is an exception that we handle. */
      if (errorHanlderInfo.getExceptions().contains(exception.getClass())) {
        return messageProcessor.handleException(exception, errorHanlderInfo.getErrorHandlerMap().get(exception.getClass()));
      /* If it was not a method that we handle, is there a default handler for this method. */
      } else if (errorHanlderInfo.isDefaultHandlerPresent()) {
        return messageProcessor.handleException(exception, errorHanlderInfo.getDefaultErrorHandler());
      } //else process as usual... and let the default exception hanlding take place.
     
    }
    return returnValue;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.