Currently, it is possible to define specialized resources,EjbJarXml is an example. These resources might not use the parsing result created by OpenRewrite but a custom representation like a JAXB-generated object model. Current implementationProjectContextInitializer scans the given project dir- The scanned resources are parsed by
MavenProjectParser and wrapped inRewriteSourceFileHoldes - The
RewriteSourceFileHoldes are added to theProjectResourceSet ProjectContextInitializer then callsapplyProjectResourceWrappers(ProjectResourceSet)- Another loop over all resources in
ProjectResourceSet trying to find a matchingProjectResourceWrapper to replaceRewriteSourceFileHolder with a more "speciaized resource", e.g.EjbJarXml (which inherits fromRewriteSourceFileHolder)
Problems with this implementation- All resources get parsed by OpenRewrite (currently in
MavenProjectParser) and in case aProjectResourceWrapper is found it "parses" the resource again, e.g. by parsing the XML file with JAXB. => All specialized resources are parsed twice - Because of this implementation two models of a resource exist in parallel. In the given example OpenRewrite created an
Xml.Document after parsing the JAXB model representation is kept in a separate variable. => This allows for concurrent modifications and wastes memory - Some specialized resources might require access to other resources, e.g. Java classes to provide a complete API. Think of a representation of
SpringBootRestController
|