IDEMPIERE-4842 Easier model registration (#895)
* IDEMPIERE-4842 Easier model registration - Needs to enable jar scanning to support felix/console installation of plugin jar. - add rejectJars call to reduce startup delay after enable of jar scanning. keep the list short to reduce future maintenance hazard. - remove the not supported use of acceptPackagesNonRecursive and acceptClasses together. - change getAcceptClassesPatterns() default to X_* and M*. Withouut acceptPackages, we need to scan both X and M classes. * IDEMPIERE-4842 Easier model registration - remove use of rejectJars since the performance difference is small and need maintenance. - remove warning for not overriding getPackages(). Plugin that doesn't has many model class (< 100) doesn't have to override getPackages() as performance is good enough with the use of acceptClasses(...).
This commit is contained in:
parent
445ca8e0fa
commit
164e6d15b6
|
|
@ -71,7 +71,7 @@ public class AnnotationBasedModelFactory extends AbstractModelFactory implements
|
||||||
* @see ClassGraph#acceptClasses(String...)
|
* @see ClassGraph#acceptClasses(String...)
|
||||||
*/
|
*/
|
||||||
protected String[] getAcceptClassesPatterns() {
|
protected String[] getAcceptClassesPatterns() {
|
||||||
String[] patterns = new String[] {"*.X_*"};
|
String[] patterns = new String[] {"*.X_*","*.M*"};
|
||||||
return patterns;
|
return patterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,26 +83,28 @@ public class AnnotationBasedModelFactory extends AbstractModelFactory implements
|
||||||
ClassGraph graph = new ClassGraph()
|
ClassGraph graph = new ClassGraph()
|
||||||
.enableAnnotationInfo()
|
.enableAnnotationInfo()
|
||||||
.overrideClassLoaders(classLoader)
|
.overrideClassLoaders(classLoader)
|
||||||
.disableJarScanning()
|
|
||||||
.disableNestedJarScanning()
|
.disableNestedJarScanning()
|
||||||
.disableModuleScanning();
|
.disableModuleScanning();
|
||||||
|
|
||||||
// narrow search to a list of packages
|
// narrow search to a list of packages
|
||||||
|
String[] packages = null;
|
||||||
if(isAtCore())
|
if(isAtCore())
|
||||||
graph.acceptPackagesNonRecursive(CORE_PACKAGES);
|
packages = CORE_PACKAGES;
|
||||||
else
|
else
|
||||||
|
packages = getPackages();
|
||||||
|
|
||||||
|
//acceptClasses has no effect when acceptPackagesNonRecursive is use
|
||||||
|
if (packages != null && packages.length > 0)
|
||||||
{
|
{
|
||||||
String[] packages = getPackages();
|
|
||||||
if(packages==null || packages.length==0)
|
|
||||||
s_log.warning(this.getClass().getSimpleName() + " should override the getPackages method");
|
|
||||||
else
|
|
||||||
graph.acceptPackagesNonRecursive(packages);
|
graph.acceptPackagesNonRecursive(packages);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// narrow search to class names matching a set of patterns
|
// narrow search to class names matching a set of patterns
|
||||||
String[] acceptClasses = getAcceptClassesPatterns();
|
String[] acceptClasses = getAcceptClassesPatterns();
|
||||||
if(acceptClasses!=null && acceptClasses.length > 0)
|
if(acceptClasses!=null && acceptClasses.length > 0)
|
||||||
graph.acceptClasses(acceptClasses);
|
graph.acceptClasses(acceptClasses);
|
||||||
|
}
|
||||||
|
|
||||||
try (ScanResult scanResult = graph.scan())
|
try (ScanResult scanResult = graph.scan())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue