You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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 <[email protected]>
Copy file name to clipboardexpand all lines: foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/config/PersistenceUnitProperties.java
+9
Original file line number
Diff line number
Diff line change
@@ -3906,6 +3906,15 @@ public class PersistenceUnitProperties {
Copy file name to clipboardexpand all lines: jpa/eclipselink.jpa.test/src/it/java/org/eclipse/persistence/testing/tests/jpa/advanced/PersistenceUnitProcessorTest.java
Copy file name to clipboardexpand all lines: jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java
+56-6
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
/*
2
2
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
3
-
* Copyright (c) 1998, 2018 IBM Corporation. All rights reserved.
3
+
* Copyright (c) 1998, 2020 IBM Corporation. All rights reserved.
4
4
*
5
5
* This program and the accompanying materials are made available under the
6
6
* terms of the Eclipse Public License v. 2.0 which is available at
0 commit comments