syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject syncope git commit: [SYNCOPE-926] Restrict startup classpath scan - This closes #36
Date Tue, 06 Sep 2016 06:02:26 GMT
Repository: syncope
Updated Branches:
  refs/heads/master 81f2e00c8 -> a751ff34b


[SYNCOPE-926] Restrict startup classpath scan - This closes #36

In order to improve performance, restrict
startup scanning to syncope packages.


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/a751ff34
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/a751ff34
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/a751ff34

Branch: refs/heads/master
Commit: a751ff34bcb7930d6fd2efc82b31531ef627fc33
Parents: 81f2e00
Author: Adrian Gonzalez <adr_gonzalez@yahoo.fr>
Authored: Mon Aug 29 11:36:44 2016 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Tue Sep 6 08:02:07 2016 +0200

----------------------------------------------------------------------
 .../init/ClassPathScanImplementationLookup.java      | 15 ++++++++++++---
 .../init/ClassPathScanImplementationLookup.java      | 15 ++++++++++++---
 2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/a751ff34/client/console/src/main/java/org/apache/syncope/client/console/init/ClassPathScanImplementationLookup.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/init/ClassPathScanImplementationLookup.java
b/client/console/src/main/java/org/apache/syncope/client/console/init/ClassPathScanImplementationLookup.java
index 194d3dd..1244075 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/init/ClassPathScanImplementationLookup.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/init/ClassPathScanImplementationLookup.java
@@ -25,7 +25,6 @@ import java.util.Comparator;
 import java.util.List;
 import org.apache.commons.collections4.ComparatorUtils;
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.client.console.pages.BaseExtPage;
 import org.apache.syncope.client.console.annotations.BinaryPreview;
 import org.apache.syncope.client.console.annotations.ExtPage;
@@ -44,6 +43,8 @@ public class ClassPathScanImplementationLookup {
 
     private static final Logger LOG = LoggerFactory.getLogger(ClassPathScanImplementationLookup.class);
 
+    private static final String DEFAULT_BASE_PACKAGE = "org.apache.syncope.client.console";
+
     private List<Class<? extends BasePage>> pages;
 
     private List<Class<? extends AbstractBinaryPreviewer>> previewers;
@@ -52,6 +53,15 @@ public class ClassPathScanImplementationLookup {
 
     private List<Class<? extends BaseExtWidget>> extWidgets;
 
+    /**
+     * This method can be overridden by subclasses to customize classpath scan.
+     *
+     * @return basePackage for classpath scanning
+     */
+    protected String getBasePackage() {
+        return DEFAULT_BASE_PACKAGE;
+    }
+
     @SuppressWarnings("unchecked")
     public void load() {
         pages = new ArrayList<>();
@@ -65,7 +75,7 @@ public class ClassPathScanImplementationLookup {
         scanner.addIncludeFilter(new AssignableTypeFilter(BaseExtPage.class));
         scanner.addIncludeFilter(new AssignableTypeFilter(BaseExtWidget.class));
 
-        for (BeanDefinition bd : scanner.findCandidateComponents(StringUtils.EMPTY)) {
+        for (BeanDefinition bd : scanner.findCandidateComponents(getBasePackage())) {
             try {
                 Class<?> clazz = ClassUtils.resolveClassName(
                         bd.getBeanClassName(), ClassUtils.getDefaultClassLoader());
@@ -161,5 +171,4 @@ public class ClassPathScanImplementationLookup {
     public List<Class<? extends BaseExtWidget>> getExtWidgetClasses() {
         return extWidgets;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/a751ff34/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
b/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
index a5b9a78..b91f2aa 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/init/ClassPathScanImplementationLookup.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.lib.policy.AccountRuleConf;
 import org.apache.syncope.common.lib.policy.PasswordRuleConf;
 import org.apache.syncope.common.lib.report.ReportletConf;
@@ -65,6 +64,8 @@ public class ClassPathScanImplementationLookup implements ImplementationLookup
{
 
     private static final Logger LOG = LoggerFactory.getLogger(ImplementationLookup.class);
 
+    private static final String DEFAULT_BASE_PACKAGE = "org.apache.syncope.core";
+
     private Map<Type, Set<String>> classNames;
 
     private Map<Class<? extends ReportletConf>, Class<? extends Reportlet>>
reportletClasses;
@@ -78,6 +79,15 @@ public class ClassPathScanImplementationLookup implements ImplementationLookup
{
         return 400;
     }
 
+    /**
+     * This method can be overridden by subclasses to customize classpath scan.
+     *
+     * @return basePackage for classpath scanning
+     */
+    protected String getBasePackage() {
+        return DEFAULT_BASE_PACKAGE;
+    }
+
     @Override
     @SuppressWarnings("unchecked")
     public void load() {
@@ -105,7 +115,7 @@ public class ClassPathScanImplementationLookup implements ImplementationLookup
{
         scanner.addIncludeFilter(new AssignableTypeFilter(Validator.class));
         scanner.addIncludeFilter(new AssignableTypeFilter(NotificationRecipientsProvider.class));
 
-        for (BeanDefinition bd : scanner.findCandidateComponents(StringUtils.EMPTY)) {
+        for (BeanDefinition bd : scanner.findCandidateComponents(getBasePackage())) {
             try {
                 Class<?> clazz = ClassUtils.resolveClassName(
                         bd.getBeanClassName(), ClassUtils.getDefaultClassLoader());
@@ -224,5 +234,4 @@ public class ClassPathScanImplementationLookup implements ImplementationLookup
{
 
         return passwordRuleClasses.get(passwordRuleConfClass);
     }
-
 }


Mime
View raw message