diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java index 0956fbc185..75c9c6dd05 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java @@ -22,16 +22,18 @@ import java.util.List; * Created by XiaXiang on 2017/3/27. */ public class ActionSearchManager implements AlphaFineSearchProvider { - private static ActionSearchManager actionSearchManager = null; + private static ActionSearchManager instance; private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; - public synchronized static ActionSearchManager getInstance() { - if (actionSearchManager == null) { - actionSearchManager = new ActionSearchManager(); + public static ActionSearchManager getInstance() { + synchronized (ActionSearchManager.class) { + if (instance == null) { + instance = new ActionSearchManager(); + } } - return actionSearchManager; + return instance; } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java index 2fa777f038..790481866f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java @@ -20,16 +20,17 @@ import com.fr.stable.StringUtils; * Created by XiaXiang on 2017/3/27. */ public class DocumentSearchManager implements AlphaFineSearchProvider { - private static DocumentSearchManager documentSearchManager = null; + private static DocumentSearchManager instance; private SearchResult lessModelList; private SearchResult moreModelList; - public synchronized static DocumentSearchManager getInstance() { - if (documentSearchManager == null) { - documentSearchManager = new DocumentSearchManager(); - + public static DocumentSearchManager getInstance() { + synchronized (DocumentSearchManager.class) { + if (instance == null) { + instance = new DocumentSearchManager(); + } } - return documentSearchManager; + return instance; } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index 82d98f9622..3cf991736c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -35,7 +35,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { private static final String DS_NAME = "dsname=\""; private static final String FRM_PREFIX = "k:frm "; private static final String CPT_PREFIX = "k:cpt "; - private static FileSearchManager fileSearchManager = null; + private static FileSearchManager fileSearchManager; private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; @@ -47,15 +47,17 @@ public class FileSearchManager implements AlphaFineSearchProvider { private boolean isContainCpt = true; private boolean isContainFrm = true; - public synchronized static FileSearchManager getInstance() { - init(); + public static FileSearchManager getInstance() { + synchronized (FileSearchManager.class) { + if (fileSearchManager == null) { + fileSearchManager = new FileSearchManager(); + } + } return fileSearchManager; } public synchronized static void init() { - if (fileSearchManager == null) { - fileSearchManager = new FileSearchManager(); - } + } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index ab3ce080df..7d57066d2e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -26,16 +26,18 @@ import java.net.URLEncoder; * Created by XiaXiang on 2017/3/27. */ public class PluginSearchManager implements AlphaFineSearchProvider { - private static PluginSearchManager pluginSearchManager = null; + private static PluginSearchManager instance = null; private SearchResult lessModelList; private SearchResult moreModelList; - public synchronized static PluginSearchManager getInstance() { - if (pluginSearchManager == null) { - pluginSearchManager = new PluginSearchManager(); + public static PluginSearchManager getInstance() { + synchronized (PluginSearchManager.class) { + if (instance == null) { + instance = new PluginSearchManager(); + } } - return pluginSearchManager; + return instance; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index d9f131f768..c98e097540 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -45,7 +45,7 @@ import java.util.List; */ public class RecentSearchManager implements AlphaFineSearchProvider { private static final int MAX_SIZE = 3; - private static RecentSearchManager recentSearchManager = null; + private static RecentSearchManager instance; IndexReader indexReader = null; IndexSearcher indexSearcher = null; //索引存储路径 @@ -59,12 +59,14 @@ public class RecentSearchManager implements AlphaFineSearchProvider { private SearchResult recentModelList; private SearchResult modelList; - public synchronized static RecentSearchManager getInstance() { - if (recentSearchManager == null) { - recentSearchManager = new RecentSearchManager(); - recentSearchManager.initWriter(); + public static RecentSearchManager getInstance() { + synchronized (RecentSearchManager.class) { + if (instance == null) { + instance = new RecentSearchManager(); + instance.initWriter(); + } } - return recentSearchManager; + return instance; } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index 2dc1ee9c0f..8ec194f5b7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -26,15 +26,17 @@ import java.util.List; * Created by XiaXiang on 2017/3/31. */ public class RecommendSearchManager implements AlphaFineSearchProvider { - private static RecommendSearchManager recommendSearchManager = null; + private static RecommendSearchManager instance; private SearchResult modelList; private SearchResult recommendModelList; - public synchronized static RecommendSearchManager getInstance() { - if (recommendSearchManager == null) { - recommendSearchManager = new RecommendSearchManager(); + public static RecommendSearchManager getInstance() { + synchronized (RecentSearchManager.class) { + if (instance == null) { + instance = new RecommendSearchManager(); + } } - return recommendSearchManager; + return instance; } @Override