1 23 24 package com.sun.enterprise.deployment.annotation.impl; 25 26 import com.sun.enterprise.deployment.annotation.ErrorHandler; 27 import com.sun.enterprise.deployment.annotation.AnnotationInfo; 28 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException; 29 30 import java.util.logging.Logger ; 31 import java.util.logging.Level ; 32 33 38 public class DefaultErrorHandler implements ErrorHandler { 39 40 Logger logger; 41 42 45 public DefaultErrorHandler() { 46 logger = AnnotationUtils.getLogger(); 47 } 48 49 52 public DefaultErrorHandler(Logger logger){ 53 this.logger = logger; 54 } 55 56 61 public void fine(AnnotationProcessorException ape) throws 62 AnnotationProcessorException { 63 64 if (logger.isLoggable(Level.FINE)){ 65 AnnotationInfo info = ape.getLocator(); 66 if (info==null){ 67 logger.fine(ape.getMessage()); 68 } else{ 69 logger.fine(AnnotationUtils.getLocalString( 70 "enterprise.deployment.annotation.error", 71 "{2}\n symbol: {0}\n location: {1}\n\n", 72 new Object [] { info.getElementType(), info.getAnnotatedElement(), ape.getMessage()})); 73 } 74 } 75 76 } 77 78 83 public void warning(AnnotationProcessorException ape) throws 84 AnnotationProcessorException { 85 86 if (logger.isLoggable(Level.WARNING)){ 87 AnnotationInfo info = ape.getLocator(); 88 if (info==null){ 89 logger.warning(ape.getMessage()); 90 } else{ 91 logger.warning(AnnotationUtils.getLocalString( 92 "enterprise.deployment.annotation.error", 93 "{2}\n symbol: {0}\n location: {1}\n\n", 94 new Object [] { info.getElementType(), info.getAnnotatedElement(), ape.getMessage()})); 95 } 96 } 97 } 98 99 104 public void error(AnnotationProcessorException ape) throws 105 AnnotationProcessorException { 106 107 AnnotationInfo info = ape.getLocator(); 108 if (info==null){ 109 logger.severe(ape.getMessage()); 110 } else{ 111 logger.severe(AnnotationUtils.getLocalString( 112 "enterprise.deployment.annotation.error", 113 "{2}\n symbol: {0} location: {1}\n\n", 114 new Object [] { info.getElementType(), info.getAnnotatedElement(), ape.getMessage()})); 115 } 116 } 117 } 118 | Popular Tags |