author | timkelly |
Tue, 27 Jul 2010 11:49:52 -0500 | |
branch | C3_BUILDER_WORK |
changeset 1693 | de004e8bf5cb |
parent 1692 | 3980cf3d4074 |
child 1857 | 5b2d8f8c613b |
permissions | -rw-r--r-- |
1568
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
1 |
/******************************************************************************* |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia and others. |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
3 |
* All rights reserved. This program and the accompanying materials |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
5 |
* which accompanies this distribution, and is available at |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
7 |
* |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
8 |
* Contributors: |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
9 |
* Nokia - Initial API and implementation |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
10 |
*******************************************************************************/ |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
11 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
12 |
package com.nokia.cpp.internal.api.utils.core; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
13 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
14 |
import java.io.File; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
15 |
import java.io.FileInputStream; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
16 |
import java.io.FileOutputStream; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
17 |
import java.io.IOException; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
18 |
import java.io.ObjectInputStream; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
19 |
import java.io.ObjectOutputStream; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
20 |
import java.io.ObjectStreamClass; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
21 |
import java.io.Serializable; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
22 |
import java.util.Collection; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
23 |
import java.util.Collections; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
24 |
import java.util.HashMap; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
25 |
import java.util.Map; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
26 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
27 |
import org.eclipse.core.runtime.IPath; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
28 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
29 |
import com.nokia.cpp.utils.core.noexport.UtilsCorePlugin; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
30 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
31 |
public class CacheUtils { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
32 |
|
1621
393b985a50f3
Raptor scanner discovery on top of new Raptor Query API.
stechong
parents:
1568
diff
changeset
|
33 |
protected class CacheEntry { |
1568
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
34 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
35 |
private String identifier; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
36 |
private long freshness; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
37 |
private Serializable data; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
38 |
private IPath location; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
39 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
40 |
public CacheEntry(String identifier, Serializable data, long freshness) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
41 |
this.identifier = identifier; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
42 |
this.freshness = freshness; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
43 |
this.data = data; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
44 |
this.location = getDefaultLocation().append(Integer.toString(identifier.hashCode())).addFileExtension("txt");; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
45 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
46 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
47 |
public CacheEntry(ObjectInputStream ois) throws Exception { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
48 |
this.identifier = (String) ois.readObject(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
49 |
this.freshness = (Long) ois.readObject(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
50 |
this.data = (Serializable) ois.readObject(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
51 |
this.location = getDefaultLocation().append(Integer.toString(identifier.hashCode())).addFileExtension("txt");; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
52 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
53 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
54 |
public IPath getLocation() { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
55 |
return location; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
56 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
57 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
58 |
@SuppressWarnings("unchecked") |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
59 |
private <T> T getData(Class<T> expectedClass) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
60 |
if (expectedClass.isInstance(data)) |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
61 |
return (T) data; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
62 |
else |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
63 |
return null; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
64 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
65 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
66 |
private long getFreshness() { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
67 |
return freshness; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
68 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
69 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
70 |
private void flush() throws Exception { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
71 |
File cacheFile = getLocation().toFile(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
72 |
if (!cacheFile.exists()) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
73 |
cacheFile.getParentFile().mkdirs(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
74 |
cacheFile.createNewFile(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
75 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
76 |
FileOutputStream fos = new FileOutputStream(cacheFile); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
77 |
ObjectOutputStream oos = new ObjectOutputStream(fos); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
78 |
oos.writeObject(identifier); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
79 |
oos.writeObject(freshness); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
80 |
oos.writeObject(data); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
81 |
fos.close(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
82 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
83 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
84 |
public void delete() { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
85 |
File cacheFile = getLocation().toFile(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
86 |
if (cacheFile.exists()) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
87 |
cacheFile.delete(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
88 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
89 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
90 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
91 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
92 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
93 |
private Map<String, CacheEntry> caches = Collections.synchronizedMap(new HashMap<String, CacheEntry>()); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
94 |
private IPath defaultLocation; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
95 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
96 |
public CacheUtils(IPath defaultLocation) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
97 |
this.defaultLocation = defaultLocation; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
98 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
99 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
100 |
public CacheEntry getCache(String identifier) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
101 |
CacheEntry result = caches.get(identifier); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
102 |
return result; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
103 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
104 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
105 |
public void removeCache(String identifier) { |
1692
3980cf3d4074
Update removeCache() to delete corresponding cache file saved to disk; also updated getCacheData() to remember cache loaded from disk.
stechong
parents:
1621
diff
changeset
|
106 |
CacheEntry cache = caches.get(identifier); |
3980cf3d4074
Update removeCache() to delete corresponding cache file saved to disk; also updated getCacheData() to remember cache loaded from disk.
stechong
parents:
1621
diff
changeset
|
107 |
if (cache != null) { |
1693
de004e8bf5cb
fix small glitch with clearing sbs cache on rescan
timkelly
parents:
1692
diff
changeset
|
108 |
caches.remove(identifier); |
1692
3980cf3d4074
Update removeCache() to delete corresponding cache file saved to disk; also updated getCacheData() to remember cache loaded from disk.
stechong
parents:
1621
diff
changeset
|
109 |
cache.delete(); |
3980cf3d4074
Update removeCache() to delete corresponding cache file saved to disk; also updated getCacheData() to remember cache loaded from disk.
stechong
parents:
1621
diff
changeset
|
110 |
} |
1568
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
111 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
112 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
113 |
public <T> T getCachedData(String cacheIdentifier, Class<T> expectedClass, long freshness) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
114 |
// freshness = 0; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
115 |
CacheEntry cache = caches.get(cacheIdentifier); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
116 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
117 |
if (cache == null) |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
118 |
cache = loadCachedData(getDefaultLocation(), cacheIdentifier); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
119 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
120 |
if (cache != null) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
121 |
long cachedFreshness = cache.getFreshness(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
122 |
T result = cache.getData(expectedClass); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
123 |
if (cachedFreshness == freshness && result != null) |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
124 |
{ |
1692
3980cf3d4074
Update removeCache() to delete corresponding cache file saved to disk; also updated getCacheData() to remember cache loaded from disk.
stechong
parents:
1621
diff
changeset
|
125 |
caches.put(cacheIdentifier, cache); |
1568
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
126 |
return result; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
127 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
128 |
else |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
129 |
{ |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
130 |
caches.remove(cache); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
131 |
cache.delete(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
132 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
133 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
134 |
return null; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
135 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
136 |
|
1621
393b985a50f3
Raptor scanner discovery on top of new Raptor Query API.
stechong
parents:
1568
diff
changeset
|
137 |
protected CacheEntry loadCachedData(IPath location, String cacheIdentifier) { |
1568
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
138 |
IPath flushPath = location.append(Integer.toString(cacheIdentifier.hashCode())).addFileExtension("txt"); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
139 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
140 |
if (flushPath.toFile().exists()) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
141 |
try { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
142 |
final ClassLoader classLoader = UtilsCorePlugin.getDefault().getClass().getClassLoader(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
143 |
FileInputStream fis = new FileInputStream(flushPath.toFile()); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
144 |
ObjectInputStream ois = new ObjectInputStream(fis) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
145 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
146 |
@Override |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
147 |
protected Class<?> resolveClass(ObjectStreamClass desc) |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
148 |
throws IOException, ClassNotFoundException { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
149 |
String name = desc.getName(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
150 |
try { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
151 |
return classLoader.loadClass(name); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
152 |
} catch (ClassNotFoundException e) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
153 |
return super.resolveClass(desc); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
154 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
155 |
}}; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
156 |
return new CacheEntry(ois); |
1621
393b985a50f3
Raptor scanner discovery on top of new Raptor Query API.
stechong
parents:
1568
diff
changeset
|
157 |
} catch (Exception e) { |
393b985a50f3
Raptor scanner discovery on top of new Raptor Query API.
stechong
parents:
1568
diff
changeset
|
158 |
e.printStackTrace(); |
393b985a50f3
Raptor scanner discovery on top of new Raptor Query API.
stechong
parents:
1568
diff
changeset
|
159 |
} |
1568
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
160 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
161 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
162 |
return null; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
163 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
164 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
165 |
public void putCachedData(String cacheIdentifier, Serializable data, long freshness) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
166 |
CacheEntry cache = new CacheEntry(cacheIdentifier, data, freshness); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
167 |
caches.put(cacheIdentifier, cache); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
168 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
169 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
170 |
public void flushAll() throws Exception { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
171 |
Collection<CacheEntry> allCaches = caches.values(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
172 |
for (CacheEntry entry : allCaches) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
173 |
entry.flush(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
174 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
175 |
caches.clear(); |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
176 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
177 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
178 |
public IPath getDefaultLocation() { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
179 |
return defaultLocation; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
180 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
181 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
182 |
public void setDefaultLocation(IPath defaultLocation) { |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
183 |
this.defaultLocation = defaultLocation; |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
184 |
} |
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
185 |
|
508bfdb3a934
Added caching of Raptor query data for aliases, products and configs.
stechong
parents:
diff
changeset
|
186 |
} |