1 23 24 package com.sun.enterprise.deployment.annotation.impl; 25 26 import java.util.Stack ; 27 import com.sun.enterprise.deployment.annotation.*; 28 import com.sun.enterprise.deployment.annotation.context.AnnotationContext; 29 30 35 class ProcessingContextImpl implements ProcessingContext { 36 37 protected AnnotationProcessor processor; 38 protected Stack <AnnotatedElementHandler> handlers = new Stack <AnnotatedElementHandler>(); 39 protected Scanner scanner; 40 41 42 ProcessingContextImpl(AnnotationProcessor processor) { 43 this.processor = processor; 44 } 45 46 public AnnotationProcessor getProcessor() { 47 return processor; 48 } 49 50 public void pushHandler(AnnotatedElementHandler handler) { 51 if (handler instanceof AnnotationContext) { 52 ((AnnotationContext) handler).setProcessingContext(this); 53 } 54 handlers.push(handler); 55 } 56 57 public AnnotatedElementHandler getHandler() { 58 if (handlers.isEmpty()) 59 return null; 60 61 return handlers.peek(); 62 } 63 64 public AnnotatedElementHandler popHandler() { 65 if (handlers.isEmpty()) 66 return null; 67 68 return handlers.pop(); 69 } 70 71 75 public <U extends AnnotatedElementHandler> U getHandler(Class <U> contextType) 76 throws ClassCastException { 77 78 if (handlers.isEmpty()) 79 return null; 80 if (AnnotationUtils.shouldLog("handler")) { 81 AnnotationUtils.getLogger().finer("Top handler is " + handlers.peek()); 82 } 83 return contextType.cast(handlers.peek()); 84 } 85 86 public Scanner getProcessingInput() { 87 return scanner; 88 } 89 public void setProcessingInput(Scanner scanner) { 90 this.scanner = scanner; 91 } 92 93 private ErrorHandler errorHandler = null; 94 95 98 public void setErrorHandler(ErrorHandler errorHandler) { 99 this.errorHandler = errorHandler; 100 } 101 102 105 public ErrorHandler getErrorHandler() { 106 return errorHandler; 107 } 108 } 109 | Popular Tags |