diff options
author | donald.g.dunne | 2018-10-18 17:38:11 +0000 |
---|---|---|
committer | Donald Dunne | 2018-10-18 19:44:23 +0000 |
commit | f98e5d0eb2e387f424ca551d41a070f79ec46d05 (patch) | |
tree | 8106b2b785cdb882e382b696b9d16d6eba6e66a9 /plugins/org.eclipse.osee.framework.skynet.core | |
parent | cfaab695848f13333d538b4506df8b68cecc947a (diff) | |
download | org.eclipse.osee-f98e5d0eb2e387f424ca551d41a070f79ec46d05.tar.gz org.eclipse.osee-f98e5d0eb2e387f424ca551d41a070f79ec46d05.tar.xz org.eclipse.osee-f98e5d0eb2e387f424ca551d41a070f79ec46d05.zip |
bug[ats_TW11474]: Fix GlobalXViewerSettings.getCustomArtifact performance
Change-Id: I831aec8199e47366b456dfd199d11b76326314eb
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core')
2 files changed, 33 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF index a54ba6795d7..83a87c1148f 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF @@ -47,7 +47,8 @@ Export-Package: org.eclipse.osee.framework.skynet.core, org.eclipse.osee.framework.skynet.core.validation, org.eclipse.osee.framework.skynet.core.word Bundle-Vendor: Eclipse Open System Engineering Environment -Import-Package: com.google.common.collect;version="15.0.0", +Import-Package: com.google.common.base;version="15.0.0", + com.google.common.collect;version="15.0.0", com.google.common.io;version="15.0.0", javax.ws.rs.client;version="2.0.0", javax.ws.rs.core;version="2.0.0", diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/GlobalXViewerSettings.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/GlobalXViewerSettings.java index df556749e84..768eb71c39c 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/GlobalXViewerSettings.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/GlobalXViewerSettings.java @@ -12,10 +12,17 @@ package org.eclipse.osee.framework.skynet.core; import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import java.util.concurrent.TimeUnit; +import org.eclipse.osee.framework.core.enums.CoreArtifactTokens; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.enums.CoreBranches; +import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; +import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; /** * This singleton artifact stores the default customizations for XViewers @@ -24,13 +31,33 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; */ public final class GlobalXViewerSettings { + private static final Supplier<Artifact> configurationsCache = + Suppliers.memoizeWithExpiration(getConfigArtifactSupplier(), 10, TimeUnit.MINUTES); + + private static Supplier<Artifact> getConfigArtifactSupplier() { + return new Supplier<Artifact>() { + @Override + public Artifact get() { + return loadConfigArtifact(); + } + }; + } + + private static Artifact loadConfigArtifact() { + Artifact configArt = ArtifactQuery.getArtifactFromTokenOrNull(CoreArtifactTokens.XViewerGlobalCustomization, + CoreBranches.COMMON, DeletionFlag.EXCLUDE_DELETED); + if (configArt == null) { + configArt = OseeSystemArtifacts.getCachedArtifact(CoreArtifactTypes.XViewerGlobalCustomization, + CoreArtifactTypes.XViewerGlobalCustomization.getName(), COMMON); + } + return configArt; + } + public static Artifact getCustomArtifact() throws OseeCoreException { - return OseeSystemArtifacts.getCachedArtifact(CoreArtifactTypes.XViewerGlobalCustomization, - CoreArtifactTypes.XViewerGlobalCustomization.getName(), COMMON); + return configurationsCache.get(); } public static Artifact createCustomArtifact() throws OseeCoreException { - return ArtifactTypeManager.addArtifact(CoreArtifactTypes.XViewerGlobalCustomization, COMMON, - CoreArtifactTypes.XViewerGlobalCustomization.getName()); + return ArtifactTypeManager.addArtifact(CoreArtifactTokens.XViewerGlobalCustomization, COMMON); } }
\ No newline at end of file |