--- a/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/TestCarbideSDKCache.java Wed Aug 11 18:16:05 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core.test/src/com/nokia/carbide/cpp/sdk/core/test/TestCarbideSDKCache.java Wed Aug 11 18:16:36 2010 -0500
@@ -11,12 +11,12 @@
import org.eclipse.core.runtime.jobs.Job;
import org.osgi.framework.Version;
+import com.nokia.carbide.cpp.internal.api.sdk.SDKCacheUtils;
import com.nokia.carbide.cpp.internal.api.sdk.sbsv2.SBSv2QueryUtils;
import com.nokia.carbide.cpp.internal.sdk.core.model.AbstractSDKManager;
import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManager;
import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManagerCacheEntry;
import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
-import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
import com.nokia.carbide.cpp.sdk.core.SymbianSDKFactory;
public class TestCarbideSDKCache extends TestCase {
@@ -25,10 +25,10 @@
@SuppressWarnings("unchecked")
public TestSDKManager() {
- Map<String, SDKManagerCacheEntry> cache = SDKCorePlugin.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
+ Map<String, SDKManagerCacheEntry> cache = SDKCacheUtils.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
if (cache == null) {
cache = new HashMap<String, SDKManagerCacheEntry>();
- SDKCorePlugin.getCache().putCachedData(SDK_MANAGER_CACHE_KEY, (Serializable)cache, 0);
+ SDKCacheUtils.getCache().putCachedData(SDK_MANAGER_CACHE_KEY, (Serializable)cache, 0);
}
}
@@ -38,10 +38,10 @@
@SuppressWarnings("unchecked")
public Map<String, SDKManagerCacheEntry> getCache() {
- Map<String, SDKManagerCacheEntry> cache = SDKCorePlugin.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
+ Map<String, SDKManagerCacheEntry> cache = SDKCacheUtils.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
if (cache == null) {
cache = new HashMap<String, SDKManagerCacheEntry>();
- SDKCorePlugin.getCache().putCachedData(SDK_MANAGER_CACHE_KEY, (Serializable)cache, 0);
+ SDKCacheUtils.getCache().putCachedData(SDK_MANAGER_CACHE_KEY, (Serializable)cache, 0);
}
return cache;
}
@@ -100,7 +100,7 @@
manager.getScanJob().join();
assertTrue(manager.getSDKList().isEmpty() == manager.getCache().isEmpty());
manager.clearCache();
- assertNull(SDKCorePlugin.getCache().getCache(AbstractSDKManager.SDK_MANAGER_CACHE_KEY));
+ assertNull(SDKCacheUtils.getCache().getCache(AbstractSDKManager.SDK_MANAGER_CACHE_KEY));
final String sdkId = "test";
ISymbianSDK sdk = SymbianSDKFactory.createInstance(sdkId, "C:\\", new Version("9.5"));
manager.addSDK(sdk);
@@ -115,15 +115,15 @@
public void testSBSv2QueryCache() throws Exception {
SBSv2QueryUtils.removeAllCachedQueries();
- assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.ALIAS_CACHE_KEY));
- assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.PRODUCT_CACHE_KEY));
- assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.CONFIG_CACHE_KEY));
+ assertNull(SDKCacheUtils.getCache().getCache(SBSv2QueryUtils.ALIAS_CACHE_KEY));
+ assertNull(SDKCacheUtils.getCache().getCache(SBSv2QueryUtils.PRODUCT_CACHE_KEY));
+ assertNull(SDKCacheUtils.getCache().getCache(SBSv2QueryUtils.CONFIG_CACHE_KEY));
final TestSDKManager manager = new TestSDKManager();
manager.scanSDKs();
manager.getScanJob().join();
- assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.ALIAS_CACHE_KEY));
- assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.PRODUCT_CACHE_KEY));
- assertNull(SDKCorePlugin.getCache().getCache(SBSv2QueryUtils.CONFIG_CACHE_KEY));
+ assertNull(SDKCacheUtils.getCache().getCache(SBSv2QueryUtils.ALIAS_CACHE_KEY));
+ assertNull(SDKCacheUtils.getCache().getCache(SBSv2QueryUtils.PRODUCT_CACHE_KEY));
+ assertNull(SDKCacheUtils.getCache().getCache(SBSv2QueryUtils.CONFIG_CACHE_KEY));
}
}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SDKCacheUtils.java Wed Aug 11 18:16:05 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SDKCacheUtils.java Wed Aug 11 18:16:36 2010 -0500
@@ -17,12 +17,25 @@
import java.io.ObjectStreamClass;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
import com.nokia.cpp.internal.api.utils.core.CacheUtils;
public class SDKCacheUtils extends CacheUtils {
+ private static final String CACHE_FOLDER_NAME = "CarbideSDKCache"; //$NON-NLS-1$
+ private static SDKCacheUtils cache;
+
+ public static SDKCacheUtils getCache() {
+ if (cache == null)
+ {
+ IPath path = new Path(System.getProperty("user.home"));
+ cache = new SDKCacheUtils(path.append(CACHE_FOLDER_NAME));
+ }
+ return cache;
+ }
+
public SDKCacheUtils(IPath defaultLocation) {
super(defaultLocation);
}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2QueryUtils.java Wed Aug 11 18:16:05 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/sbsv2/SBSv2QueryUtils.java Wed Aug 11 18:16:36 2010 -0500
@@ -47,6 +47,7 @@
import org.xml.sax.helpers.DefaultHandler;
import com.nokia.carbide.cpp.internal.api.sdk.SBSv2Utils;
+import com.nokia.carbide.cpp.internal.api.sdk.SDKCacheUtils;
import com.nokia.carbide.cpp.internal.sdk.core.model.SDKManager;
import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
@@ -67,7 +68,7 @@
@SuppressWarnings("unchecked")
public static HashMap<String, String> getAliasesForSDK(ISymbianSDK sdk) throws SBSv2MinimumVersionException {
HashMap<String, String> aliases;
- Map<String, HashMap<String, String>> aliasesMap = SDKCorePlugin.getCache().getCachedData(ALIAS_CACHE_KEY, Map.class, 0);
+ Map<String, HashMap<String, String>> aliasesMap = SDKCacheUtils.getCache().getCachedData(ALIAS_CACHE_KEY, Map.class, 0);
SBSv2SDKKey key = new SBSv2SDKKey(sdk);
if (aliasesMap == null) {
@@ -82,14 +83,14 @@
aliases = getAliasesQuery(sdk);
aliasesMap.put(key.toString(), aliases);
- SDKCorePlugin.getCache().putCachedData(ALIAS_CACHE_KEY, (Serializable)aliasesMap, 0);
+ SDKCacheUtils.getCache().putCachedData(ALIAS_CACHE_KEY, (Serializable)aliasesMap, 0);
return aliases;
}
@SuppressWarnings("unchecked")
public static List<String> getProductVariantsForSDK(ISymbianSDK sdk) throws SBSv2MinimumVersionException {
List<String> products;
- Map<String, List<String>> productsMap = SDKCorePlugin.getCache().getCachedData(PRODUCT_CACHE_KEY, Map.class, 0);
+ Map<String, List<String>> productsMap = SDKCacheUtils.getCache().getCachedData(PRODUCT_CACHE_KEY, Map.class, 0);
SBSv2SDKKey key = new SBSv2SDKKey(sdk);
if (productsMap == null) {
@@ -104,7 +105,7 @@
products = getProductsQuery(sdk);
productsMap.put(key.toString(), products);
- SDKCorePlugin.getCache().putCachedData(PRODUCT_CACHE_KEY, (Serializable)productsMap, 0);
+ SDKCacheUtils.getCache().putCachedData(PRODUCT_CACHE_KEY, (Serializable)productsMap, 0);
return products;
}
@@ -132,7 +133,7 @@
@SuppressWarnings("unchecked")
public static SBSv2ConfigQueryData getConfigQueryDataForSDK(ISymbianSDK sdk, String alias) {
SBSv2ConfigQueryData configQueryData = null;
- Map<String, SBSv2ConfigQueryData> configsMap = SDKCorePlugin.getCache().getCachedData(CONFIG_CACHE_KEY, Map.class, 0);
+ Map<String, SBSv2ConfigQueryData> configsMap = SDKCacheUtils.getCache().getCachedData(CONFIG_CACHE_KEY, Map.class, 0);
String key = (new SBSv2SDKKey(sdk)).toString() + "[" + alias + "]";
if (configsMap != null) {
@@ -143,7 +144,7 @@
@SuppressWarnings("unchecked")
public static void storeConfigQueryDataForSDK(ISymbianSDK sdk, String alias, SBSv2ConfigQueryData configQueryData) {
- Map<String, SBSv2ConfigQueryData> configsMap = SDKCorePlugin.getCache().getCachedData(CONFIG_CACHE_KEY, Map.class, 0);
+ Map<String, SBSv2ConfigQueryData> configsMap = SDKCacheUtils.getCache().getCachedData(CONFIG_CACHE_KEY, Map.class, 0);
String key = (new SBSv2SDKKey(sdk)).toString() + "[" + alias + "]";
if (configsMap == null) {
@@ -156,7 +157,7 @@
}
configsMap.put(key, configQueryData);
- SDKCorePlugin.getCache().putCachedData(CONFIG_CACHE_KEY, (Serializable)configsMap, 0);
+ SDKCacheUtils.getCache().putCachedData(CONFIG_CACHE_KEY, (Serializable)configsMap, 0);
}
public static HashMap<String, String> queryConfigTargetInfo(ISymbianSDK sdk, List<String> aliasOrMeaningArray) throws SBSv2MinimumVersionException{
@@ -471,15 +472,15 @@
}
public static void removeCachedAliases() {
- SDKCorePlugin.getCache().removeCache(ALIAS_CACHE_KEY);
+ SDKCacheUtils.getCache().removeCache(ALIAS_CACHE_KEY);
}
public static void removeCachedProducts() {
- SDKCorePlugin.getCache().removeCache(PRODUCT_CACHE_KEY);
+ SDKCacheUtils.getCache().removeCache(PRODUCT_CACHE_KEY);
}
public static void removeCachedConfigurations() {
- SDKCorePlugin.getCache().removeCache(CONFIG_CACHE_KEY);
+ SDKCacheUtils.getCache().removeCache(CONFIG_CACHE_KEY);
}
}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java Wed Aug 11 18:16:05 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java Wed Aug 11 18:16:36 2010 -0500
@@ -45,6 +45,7 @@
import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerInternal;
import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerLoadedHook;
import com.nokia.carbide.cpp.internal.api.sdk.SBSv2Utils;
+import com.nokia.carbide.cpp.internal.api.sdk.SDKCacheUtils;
import com.nokia.carbide.cpp.internal.api.sdk.SDKManagerInternalAPI;
import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContextDataCache;
import com.nokia.carbide.cpp.internal.api.sdk.SymbianMacroStore;
@@ -644,12 +645,12 @@
}
protected void clearSDKCache() {
- SDKCorePlugin.getCache().removeCache(SDK_MANAGER_CACHE_KEY);
+ SDKCacheUtils.getCache().removeCache(SDK_MANAGER_CACHE_KEY);
}
@SuppressWarnings("unchecked")
protected List<String> getSDKCacheIdList() {
- Map<String, SDKManagerCacheEntry> cacheMap = SDKCorePlugin.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
+ Map<String, SDKManagerCacheEntry> cacheMap = SDKCacheUtils.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
List<String> idList = new ArrayList<String>();
if (cacheMap != null) {
@@ -662,7 +663,7 @@
@SuppressWarnings("unchecked")
protected SDKManagerCacheEntry getSDKCacheEntry(String id) {
SDKManagerCacheEntry entry = null;
- Map<String, SDKManagerCacheEntry> cacheMap = SDKCorePlugin.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
+ Map<String, SDKManagerCacheEntry> cacheMap = SDKCacheUtils.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
if (cacheMap != null) {
entry = cacheMap.get(id);
@@ -674,14 +675,14 @@
@SuppressWarnings("unchecked")
protected void setSDKCacheEntry(SDKManagerCacheEntry entry) {
String id = entry.getId();
- Map<String, SDKManagerCacheEntry> cacheMap = SDKCorePlugin.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
+ Map<String, SDKManagerCacheEntry> cacheMap = SDKCacheUtils.getCache().getCachedData(SDK_MANAGER_CACHE_KEY, Map.class, 0);
if (cacheMap == null) {
cacheMap = new HashMap<String, SDKManagerCacheEntry>();
}
cacheMap.put(id, entry);
- SDKCorePlugin.getCache().putCachedData(SDK_MANAGER_CACHE_KEY, (Serializable)cacheMap, 0);
+ SDKCacheUtils.getCache().putCachedData(SDK_MANAGER_CACHE_KEY, (Serializable)cacheMap, 0);
}
}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/SDKCorePlugin.java Wed Aug 11 18:16:05 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/sdk/core/SDKCorePlugin.java Wed Aug 11 18:16:36 2010 -0500
@@ -12,8 +12,6 @@
*/
package com.nokia.carbide.cpp.sdk.core;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
@@ -34,15 +32,11 @@
// The plug-in ID
public static final String PLUGIN_ID = "com.nokia.carbide.cpp.sdk.core"; //$NON-NLS-1$
- public static final String CACHE_FOLDER_NAME = "CarbideSDKCache"; //$NON-NLS-1$
-
// The shared instance
private static SDKCorePlugin plugin;
private static ISDKManager sdkManager;
- private static SDKCacheUtils cache;
-
/**
* The constructor
*/
@@ -64,8 +58,7 @@
*/
public void stop(BundleContext context) throws Exception {
try {
- if (cache != null)
- cache.flushAll();
+ SDKCacheUtils.getCache().flushAll();
} catch (Exception e) {
e.printStackTrace();
}
@@ -103,17 +96,4 @@
return sdkManager;
}
- /**
- * Get the persistent cache this plugin.
- * @return PersistentCache instance
- */
- public static SDKCacheUtils getCache() {
- if (cache == null)
- {
- IPath path = new Path(System.getProperty("user.home"));
- cache = new SDKCacheUtils(path.append(CACHE_FOLDER_NAME));
- }
- return cache;
- }
-
}