• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Maven Plug-in for Scanning Classes at Build-time

 
Marshal
Posts: 3654
516
Android 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: 24309
167
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: 3654
516
Android 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic