Search in sources :

Example 1 with ProcessingResult

use of org.glassfish.apf.ProcessingResult in project Payara by payara.

the class AnnotationProcessorImpl method process.

/**
 * Starts the annotation processing tool passing the processing context which
 * encapsulate all information necessary for the configuration of the tool.
 * @param ctx is the initialised processing context
 * @return the result of the annotations processing
 * @throws AnnotationProcessorException
 */
@Override
public ProcessingResult process(ProcessingContext ctx) throws AnnotationProcessorException {
    ApplicationState state = ctx.getArchive().getExtraData(ApplicationState.class);
    Optional<AnnotationProcessorState> processorState = Optional.empty();
    if (state != null) {
        processorState = state.getProcessingState(ctx);
    }
    Scanner<Object> scanner = ctx.getProcessingInput();
    ProcessingResultImpl result;
    errorCount = 0;
    if (state == null) {
        result = new ProcessingResultImpl();
        for (Class c : scanner.getElements()) {
            result.add(process(ctx, c));
        }
    } else if (state.isInactive()) {
        result = new ProcessingResultImpl();
        for (Class c : scanner.getElements()) {
            result.add(process(ctx, c));
        }
        processorState.ifPresent(s -> s.setProcessingResult(result));
    } else {
        result = processorState.get().getProcessingResult(ProcessingResultImpl.class);
        for (Class modifiedClass : scanner.getElements(state.getClassesChanged().keySet())) {
            result.add(process(ctx, modifiedClass));
        }
    }
    return result;
}
Also used : AnnotationProcessorState(fish.payara.nucleus.hotdeploy.AnnotationProcessorState) HandlerProcessingResult(org.glassfish.apf.HandlerProcessingResult) HashMap(java.util.HashMap) Constructor(java.lang.reflect.Constructor) Stack(java.util.Stack) AnnotationProcessorException(org.glassfish.apf.AnnotationProcessorException) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) ProcessingContext(org.glassfish.apf.ProcessingContext) AnnotationInfo(org.glassfish.apf.AnnotationInfo) Map(java.util.Map) ResultType(org.glassfish.apf.ResultType) AnnotationProcessor(org.glassfish.apf.AnnotationProcessor) Method(java.lang.reflect.Method) ProcessingResult(org.glassfish.apf.ProcessingResult) EmptyStackException(java.util.EmptyStackException) Set(java.util.Set) ElementType(java.lang.annotation.ElementType) Field(java.lang.reflect.Field) Logger(java.util.logging.Logger) ApplicationState(fish.payara.nucleus.hotdeploy.ApplicationState) AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler) List(java.util.List) AnnotationHandler(org.glassfish.apf.AnnotationHandler) Annotation(java.lang.annotation.Annotation) ComponentInfo(org.glassfish.apf.ComponentInfo) Optional(java.util.Optional) Scanner(org.glassfish.apf.Scanner) AnnotatedElement(java.lang.reflect.AnnotatedElement) ApplicationState(fish.payara.nucleus.hotdeploy.ApplicationState) AnnotationProcessorState(fish.payara.nucleus.hotdeploy.AnnotationProcessorState)

Aggregations

AnnotationProcessorState (fish.payara.nucleus.hotdeploy.AnnotationProcessorState)1 ApplicationState (fish.payara.nucleus.hotdeploy.ApplicationState)1 Annotation (java.lang.annotation.Annotation)1 ElementType (java.lang.annotation.ElementType)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Constructor (java.lang.reflect.Constructor)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 EmptyStackException (java.util.EmptyStackException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Stack (java.util.Stack)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 AnnotatedElementHandler (org.glassfish.apf.AnnotatedElementHandler)1