/** * Creates a new ErrorHandler with the default logger */ public DefaultErrorHandler() { logger = AnnotationUtils.getLogger(); }
/** * Log a message on the default logger */ public void log(Level level, AnnotationInfo locator, String localizedMessage){ if (logger!=null && logger.isLoggable(level)){ if (locator!=null){ logger.log(level, AnnotationUtils.getLocalString( "enterprise.deployment.annotation.error", "{2}\n symbol: {0}\n location: {1}", new Object[] { locator.getAnnotation().annotationType().getName(), locator.getAnnotatedElement(), localizedMessage})); } else{ logger.log(level, localizedMessage); } } }
/** * @return the previously set ClientContext casted to the requestd * type if possible or throw an exception otherwise. */ public <U extends AnnotatedElementHandler> U getHandler(Class<U> contextType) throws ClassCastException { if (handlers.isEmpty()) return null; if (AnnotationUtils.shouldLog("handler")) { AnnotationUtils.getLogger().finer("Top handler is " + handlers.peek()); } return contextType.cast(handlers.peek()); }
if (AnnotationUtils.shouldLog("annotation")) { logger.finer("Annotation : " + annotation.annotationType().getName() + " delegate = " + delegate); AnnotationUtils.getLocalString( "enterprise.deployment.annotation.toomanyerror", "Too many errors, annotation processing abandoned."));
private void dumpProcessingResult(HandlerProcessingResult result) { if (result==null || !AnnotationUtils.shouldLog("annotation")) { return; } Map<Class<? extends Annotation>, ResultType> annotationResults = result.processedAnnotations(); for (Map.Entry<Class<? extends Annotation>, ResultType> element : annotationResults.entrySet()) { logger.finer("Annotation " + element.getKey() + " : " + element.getValue()); } } public void pushAnnotationHandler(AnnotationHandler handler) {
if (AnnotationUtils.shouldLog("annotation")) { logger.finer("Annotation : " + annotation.annotationType().getName() + " delegate = " + delegate); AnnotationUtils.getLocalString( "enterprise.deployment.annotation.toomanyerror", "Too many errors, annotation processing abandoned."));
private void dumpProcessingResult(HandlerProcessingResult result) { if (result==null || !AnnotationUtils.shouldLog("annotation")) { return; } Map<Class<? extends Annotation>, ResultType> annotationResults = result.processedAnnotations(); for (Map.Entry<Class<? extends Annotation>, ResultType> element : annotationResults.entrySet()) { logger.finer("Annotation " + element.getKey() + " : " + element.getValue()); } } public void pushAnnotationHandler(AnnotationHandler handler) {
/** * Creates a new ErrorHandler with the default logger */ public DefaultErrorHandler() { logger = AnnotationUtils.getLogger(); }
/** * @return the previously set ClientContext casted to the requestd * type if possible or throw an exception otherwise. */ public <U extends AnnotatedElementHandler> U getHandler(Class<U> contextType) throws ClassCastException { if (handlers.isEmpty()) return null; if (AnnotationUtils.shouldLog("handler")) { AnnotationUtils.getLogger().finer("Top handler is " + handlers.peek()); } return contextType.cast(handlers.peek()); }
/** * Log a message on the default logger */ public void log(Level level, AnnotationInfo locator, String localizedMessage){ if (logger!=null && logger.isLoggable(level)){ if (locator!=null){ logger.log(level, AnnotationUtils.getLocalString( "enterprise.deployment.annotation.error", "{2}\n symbol: {0}\n location: {1}", new Object[] { locator.getAnnotation().annotationType().getName(), locator.getAnnotatedElement(), localizedMessage})); } else{ logger.log(level, localizedMessage); } } }
private HandlerProcessingResult processAnnotations(ProcessingContext ctx, AnnotatedElement element) throws AnnotationProcessorException { HandlerProcessingResultImpl result= new HandlerProcessingResultImpl(); try{ for (Annotation annotation : element.getAnnotations()) { // initialize the result... AnnotationInfo subElement = new AnnotationInfo(ctx, element, annotation, getTopElementType()); if (!result.processedAnnotations().containsKey(annotation.annotationType())) { process(ctx, subElement, result); } else { if (AnnotationUtils.shouldLog("annotation")) { logger.finer("Annotation " + annotation.annotationType() + " already processed"); } } } } catch (ArrayStoreException e) { logger.info("Exception " + e.toString() + " encountered while processing annotaton for element " + element + ". Message is: " + e.getMessage() + ". Ignoring annotations and proceeding."); } return result; }
/** Creates a new instance of AnnotationProcessorImpl */ public AnnotationProcessorImpl() { logger = AnnotationUtils.getLogger(); }
private void logEnd(AnnotatedElementHandler handler, ElementType type, AnnotatedElement c) throws AnnotationProcessorException { if (AnnotationUtils.shouldLog("types")) { AnnotationUtils.getLogger().finer(type + " END : " + c); } // pop it from our annotated element stack annotatedElements.pop(); if(delegate!=null) { delegate.getStack().pop(); } if (handler!=null) { handler.endElement(type, c); } }
/** * Receive notification of a warning * @param ape The warning information * @throws any exception to stop the annotation processing */ public void warning(AnnotationProcessorException ape) throws AnnotationProcessorException { if (logger.isLoggable(Level.WARNING)){ AnnotationInfo info = ape.getLocator(); if (info==null){ logger.warning(ape.getMessage()); } else{ logger.warning(AnnotationUtils.getLocalString( "enterprise.deployment.annotation.error", "{2}\n symbol: {0}\n location: {1}\n\n", new Object[] { info.getElementType(), info.getAnnotatedElement(), ape.getMessage()})); } } }
private HandlerProcessingResult processAnnotations(ProcessingContext ctx, AnnotatedElement element) throws AnnotationProcessorException { HandlerProcessingResultImpl result= new HandlerProcessingResultImpl(); try{ for (Annotation annotation : element.getAnnotations()) { // initialize the result... AnnotationInfo subElement = new AnnotationInfo(ctx, element, annotation, getTopElementType()); if (!result.processedAnnotations().containsKey(annotation.annotationType())) { process(ctx, subElement, result); } else { if (AnnotationUtils.shouldLog("annotation")) { logger.finer("Annotation " + annotation.annotationType() + " already processed"); } } } } catch (ArrayStoreException e) { logger.info("Exception " + e.toString() + " encountered while processing annotaton for element " + element + ". Message is: " + e.getMessage() + ". Ignoring annotations and proceeding."); } return result; }
/** Creates a new instance of AnnotationProcessorImpl */ public AnnotationProcessorImpl() { logger = AnnotationUtils.getLogger(); }
private void logEnd(AnnotatedElementHandler handler, ElementType type, AnnotatedElement c) throws AnnotationProcessorException { if (AnnotationUtils.shouldLog("types")) { AnnotationUtils.getLogger().finer(type + " END : " + c); } // pop it from our annotated element stack annotatedElements.pop(); if(delegate!=null) { delegate.getStack().pop(); } if (handler!=null) { handler.endElement(type, c); } }
/** * Receive notication of a fine error message * @param ape The warning information * @throws any exception to stop the annotation processing */ public void fine(AnnotationProcessorException ape) throws AnnotationProcessorException { if (logger.isLoggable(Level.FINE)){ AnnotationInfo info = ape.getLocator(); if (info==null){ logger.fine(ape.getMessage()); } else{ logger.fine(AnnotationUtils.getLocalString( "enterprise.deployment.annotation.error", "{2}\n symbol: {0}\n location: {1}\n\n", new Object[] { info.getElementType(), info.getAnnotatedElement(), ape.getMessage()})); } } }
public void process(File directory, Object bundleDesc, ClassLoader classLoader) throws IOException { AnnotationUtils.getLogger().finer("dir is " + directory); AnnotationUtils.getLogger().finer("classLoader is " + classLoader); this.directory = directory; this.classLoader = classLoader; init(directory); }
private void logStart(AnnotatedElementHandler handler, ElementType type, AnnotatedElement c) throws AnnotationProcessorException { if (AnnotationUtils.shouldLog("types")) { AnnotationUtils.getLogger().finer(type + " START : " + c); } // push it to our annotated element stack annotatedElements.push(new StackElement(type, c)); if(delegate!=null) { delegate.getStack().push(new StackElement(type, c)); } if (handler!=null) { handler.startElement(type, c); } }