Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package-to-scan feature #786

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on May 1, 2020

  1. Add package-to-scan feature

    # Context
    
    Some applications can have thousands of classes.
    When JPA is configured to scan classes (`exclude-unlisted-classes` is `false` in `persistence.xml`), the time used to scan all classes can be quite long.
    With reasonable application size, class scanning can take only ten's of milliseconds but for heavy application it can take a few seconds.
    
    In order to help reducing startup time, we can restrict class scanning to a pre-configured list of known packages to avoid loading unnecessary classes metadata.
    
    # What was done
    
    - Introduced a new property `PersistenceUnitProperties.PACKAGES_TO_SCAN`: `eclipselink.packages-to-scan`
    - Modified `PersistenceUnitProcessor.getClassNamesFromURL` to only return eligible classes
    
    This new property takes as a value a list of packages as a string: `com.foo.bar, some.other.packages`
    
    # Performance result
    
    I've tested this feature with 2 applications, one with ~1000 classes and another with more than 30k classes.
    `MetadataProcessor.initPersistenceUnitClasses` was faster by ~25% for the small application and ~45% for the big one.
    
    Signed-off-by: Alexandre Jacob <alexandref.jacob@gmail.com>
    ajacob committed May 1, 2020
    Configuration menu
    Copy the full SHA
    6a6dabf View commit details
    Browse the repository at this point in the history