Skip to content

Publish parsing events registered through the ExecutionContext as Spring application events #892

@fabapp2

Description

@fabapp2

This has been done.

OpenRewrite allows registering a ParsingEventListener with the ExecutionContext.
The listener will then be informed about parsed resources.
A RewriteParsingEventListenerAdapter implements the ParsingEventListener and publishes ParsedResourceEvent as Spring application events copying the information provided to the listener.

See RewriteProjectParserIntegrationTest

Events

  • ParsedResourceEvent - published for every parsed resource (when published by OpenRewrite)
  • StartedParsingProjectEvent - published when the parsing starts
  • FinishedParsingProjectEvent - published when the parsing finished successfully

Spring @EventListsner can be used to listen to these events

@EventListener(ParsedResourceEvent.class)
public void onEvent(ParsedResourceEvent event) {
    // handle new parsed resource
}

@EventListener(StartedParsingProjectEvent.class)
public void onStartedParsingProjectEvent(StartedParsingProjectEvent event) {
    // handle start of parsing
}

@EventListener(FinishedParsingProjectEvent.class)
public void onFinishedParsingProjectEvent(FinishedParsingProjectEvent event) {
    // handle finish parsing
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions