• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Maven Plug-in for Scanning Classes at Build-time

 
Marshal
Posts: 4510
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ResourceInfo(subsystem = "usermgmt", name = "api-user", title = "ApiUser", metadataLink = "api-user")

I have an JEE application where I have a number of application-specific annotations to describe certain non-business attributes of entity classes.  When the application is launched, all the entity classes are scanned, and a map is populated with entities class based on one of the annotation attributes (metadataLink in this case) which is used to look-up the corresponding class when the webservice need to provide metadata for an entity.  Scanning all the packages which can contain entity classes and filling the map is taking around 45 seconds on the target hardware.  I would like to reduce this time to only a few seconds or less.

Since this mapping is based on static data, I am hoping to be able to create the mapping data at build time, store it is a file in the WAR (maybe WEB-INF/META-INF/metadata-mappings.properties), and just load this information at run-time, avoiding the sizable delay when launching the application.

I've done type of thing before using a Compile-time Annotation Processor, but I am hoping there is a ready-built Maven plugin which I could use to accomplish this.  Has anyone worked on a project with Maven build-time scanning?
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you'd probably want to create a mojo (which is to say a custom Maven plugin). Mojos are in JavaBean form, but for details I'll refer you to the official Maven docs.

You might also consider doing what Spring Data does, which is to define a package path for your scanner. That's what Spring Data does to identify persistence objects without having to run every class in the application.
 
Ron McLeod
Marshal
Posts: 4510
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:I think you'd probably want to create a mojo (which is to say a custom Maven plugin).


Great suggestion.  A custom Mojo seems like a good solution for this, and some other issues that I would like to solve.  Thanks.
 
The City calls upon her steadfast protectors. Now for a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic