public void postConstruct() { if (systemProcessor == null) { // initialize our system annotation processor... systemProcessor = new AnnotationProcessorImpl(); for (AnnotationHandler anHandler : handlers) { systemProcessor.pushAnnotationHandler(anHandler); annotationClassNames.add("L" + anHandler.getAnnotationType().getName(). replace('.', '/') + ";"); } } } }
public AnnotationProcessor getAnnotationProcessor(boolean isMetaDataComplete) { AnnotationProcessorImpl processor = Factory.getDefaultAnnotationProcessor(); if (!isMetaDataComplete) { processor.setDelegate(systemProcessor); } else { processor.setDelegate(systemProcessorMetaDataComplete); } return processor; }
private HandlerProcessingResult processAnnotations(ProcessingContext ctx, ElementType type, AnnotatedElement element) throws AnnotationProcessorException { AnnotatedElementHandler handler = ctx.getHandler(); logStart(handler, type, element); HandlerProcessingResult result = processAnnotations(ctx, element); logEnd(handler, type, element); dumpProcessingResult(result); return result; }
private HandlerProcessingResult processParameters(ProcessingContext ctx, Annotation[][] parametersAnnotations) throws AnnotationProcessorException { HandlerProcessingResultImpl result = new HandlerProcessingResultImpl(); // process the method parameters... for (Annotation[] parameterAnnotations : parametersAnnotations) { logStart(ctx.getHandler(), ElementType.PARAMETER, null); if (parameterAnnotations!=null) { for (Annotation annotation : parameterAnnotations) { AnnotationInfo info = new AnnotationInfo(ctx, null, annotation, ElementType.PARAMETER); process(ctx, info, result); dumpProcessingResult(result); } } logEnd(ctx.getHandler(), ElementType.PARAMETER, null); } return result; }
processAnnotations(ctx, ElementType.PACKAGE, classPackage)); logStart(handler, ElementType.TYPE,c); result.add(c, processAnnotations(ctx, c)); result.add(field,processAnnotations(ctx, ElementType.FIELD, field)); logStart(ctx.getHandler(), ElementType.CONSTRUCTOR, constructor); result.add(constructor, processAnnotations(ctx, constructor)); processParameters(ctx, constructor.getParameterAnnotations()); logEnd(ctx.getHandler(), ElementType.CONSTRUCTOR, constructor); logStart(ctx.getHandler(), ElementType.METHOD, method); result.add(method, processAnnotations(ctx, method)); processParameters(ctx, method.getParameterAnnotations()); logEnd(ctx.getHandler(), ElementType.METHOD, method); result.add(c, processAnnotations(ctx, currentClass)); currentClass = currentClass.getSuperclass(); logEnd(ctx.getHandler(), ElementType.TYPE, c);
/** * Return a empty AnnotationProcessor with no annotation handlers registered * @return initialized AnnotationProcessor instance */ public static AnnotationProcessorImpl getDefaultAnnotationProcessor() { return new AnnotationProcessorImpl(); }
public void pushAnnotationHandler(AnnotationHandler handler) { String type = handler.getAnnotationType().getName(); pushAnnotationHandler(type, handler); }
if (resultType==null || resultType==ResultType.UNPROCESSED){ AnnotationInfo info = new AnnotationInfo(ctx, ae, depAnnotation, getTopElementType()); process(ctx, info, result); } catch(AnnotationProcessorException ape) { log(Level.SEVERE, ape.getLocator(), ape.getMessage()); delegate.process(ctx, element, result); } else { ctx.getErrorHandler().fine(
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; }
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); } }
private HandlerProcessingResult processParameters(ProcessingContext ctx, Annotation[][] parametersAnnotations) throws AnnotationProcessorException { HandlerProcessingResultImpl result = new HandlerProcessingResultImpl(); // process the method parameters... for (Annotation[] parameterAnnotations : parametersAnnotations) { logStart(ctx.getHandler(), ElementType.PARAMETER, null); if (parameterAnnotations!=null) { for (Annotation annotation : parameterAnnotations) { AnnotationInfo info = new AnnotationInfo(ctx, null, annotation, ElementType.PARAMETER); process(ctx, info, result); dumpProcessingResult(result); } } logEnd(ctx.getHandler(), ElementType.PARAMETER, null); } return result; }
processAnnotations(ctx, ElementType.PACKAGE, classPackage)); logStart(handler, ElementType.TYPE,c); result.add(c, processAnnotations(ctx, c)); result.add(field,processAnnotations(ctx, ElementType.FIELD, field)); logStart(ctx.getHandler(), ElementType.CONSTRUCTOR, constructor); result.add(constructor, processAnnotations(ctx, constructor)); processParameters(ctx, constructor.getParameterAnnotations()); logEnd(ctx.getHandler(), ElementType.CONSTRUCTOR, constructor); logStart(ctx.getHandler(), ElementType.METHOD, method); result.add(method, processAnnotations(ctx, method)); processParameters(ctx, method.getParameterAnnotations()); logEnd(ctx.getHandler(), ElementType.METHOD, method); result.add(c, processAnnotations(ctx, currentClass)); currentClass = currentClass.getSuperclass(); logEnd(ctx.getHandler(), ElementType.TYPE, c);
/** * Return a empty AnnotationProcessor with no annotation handlers registered * @return initialized AnnotationProcessor instance */ public static AnnotationProcessorImpl getDefaultAnnotationProcessor() { return new AnnotationProcessorImpl(); }
public void pushAnnotationHandler(AnnotationHandler handler) { String type = handler.getAnnotationType().getName(); pushAnnotationHandler(type, handler); }
if (resultType==null || resultType==ResultType.UNPROCESSED){ AnnotationInfo info = new AnnotationInfo(ctx, ae, depAnnotation, getTopElementType()); process(ctx, info, result); } catch(AnnotationProcessorException ape) { log(Level.SEVERE, ape.getLocator(), ape.getMessage()); delegate.process(ctx, element, result); } else { ctx.getErrorHandler().fine(
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; }
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); } }
systemProcessor = new AnnotationProcessorImpl(); systemProcessorMetaDataComplete = new AnnotationProcessorImpl(); for (ActiveDescriptor<?> i : locator.getDescriptors(BuilderHelper.createContractFilter( AnnotationHandler.class.getName()))) { if (annotationTypeName == null) continue; systemProcessor.pushAnnotationHandler(annotationTypeName, new LazyAnnotationHandler(descriptor)); annotationClassNames.add("L" + annotationTypeName. systemProcessorMetaDataComplete.pushAnnotationHandler(annotationTypeName, new LazyAnnotationHandler(descriptor)); annotationClassNamesMetaDataComplete.add("L" + annotationTypeName.
private HandlerProcessingResult processAnnotations(ProcessingContext ctx, ElementType type, AnnotatedElement element) throws AnnotationProcessorException { AnnotatedElementHandler handler = ctx.getHandler(); logStart(handler, type, element); HandlerProcessingResult result = processAnnotations(ctx, element); logEnd(handler, type, element); dumpProcessingResult(result); return result; }
public AnnotationProcessor getAnnotationProcessor() { AnnotationProcessorImpl processor = Factory.getDefaultAnnotationProcessor(); processor.setDelegate(systemProcessor); return processor; }