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...)
|
||||
*/
|
||||
protected String[] getAcceptClassesPatterns() {
|
||||
String[] patterns = new String[] {"*.X_*"};
|
||||
String[] patterns = new String[] {"*.X_*","*.M*"};
|
||||
return patterns;
|
||||
}
|
||||
|
||||
|
@ -83,27 +83,29 @@ public class AnnotationBasedModelFactory extends AbstractModelFactory implements
|
|||
ClassGraph graph = new ClassGraph()
|
||||
.enableAnnotationInfo()
|
||||
.overrideClassLoaders(classLoader)
|
||||
.disableJarScanning()
|
||||
.disableNestedJarScanning()
|
||||
.disableModuleScanning();
|
||||
|
||||
// narrow search to a list of packages
|
||||
String[] packages = null;
|
||||
if(isAtCore())
|
||||
graph.acceptPackagesNonRecursive(CORE_PACKAGES);
|
||||
packages = CORE_PACKAGES;
|
||||
else
|
||||
packages = getPackages();
|
||||
|
||||
//acceptClasses has no effect when acceptPackagesNonRecursive is use
|
||||
if (packages != null && packages.length > 0)
|
||||
{
|
||||
graph.acceptPackagesNonRecursive(packages);
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] packages = getPackages();
|
||||
if(packages==null || packages.length==0)
|
||||
s_log.warning(this.getClass().getSimpleName() + " should override the getPackages method");
|
||||
else
|
||||
graph.acceptPackagesNonRecursive(packages);
|
||||
// narrow search to class names matching a set of patterns
|
||||
String[] acceptClasses = getAcceptClassesPatterns();
|
||||
if(acceptClasses!=null && acceptClasses.length > 0)
|
||||
graph.acceptClasses(acceptClasses);
|
||||
}
|
||||
|
||||
// narrow search to class names matching a set of patterns
|
||||
String[] acceptClasses = getAcceptClassesPatterns();
|
||||
if(acceptClasses!=null && acceptClasses.length > 0)
|
||||
graph.acceptClasses(acceptClasses);
|
||||
|
||||
try (ScanResult scanResult = graph.scan())
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue