Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Maven Plug-in for Scanning Classes at Build-time

 
Marshal
Posts: 3156
466
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • 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: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 3156
466
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic