1
2
3
4
5 package gboat2.base.core.web.md;
6
7 import gboat2.base.core.Activator;
8 import gboat2.base.core.cache.ICacheService;
9
10 import java.net.URL;
11
12 import net.sf.json.JSONObject;
13
14 import org.osgi.framework.Bundle;
15 import org.osgi.framework.BundleContext;
16
17
18
19
20
21
22
23
24
25
26 public class CacheHandler extends MetadataHandler {
27
28
29
30
31
32 @Override
33 public JSONObject parseMetadata(JSONObject object, URL url, Bundle bundle, MetadataHandlerChain chain) {
34 BundleContext context = Activator.LOCAL_BUNDLE.getBundleContext();
35 ICacheService cache =(ICacheService)context.getService(context.getServiceReference(ICacheService.class.getName()));
36 if(cache!=null){
37 if (cache.get(chain.getBundle().getSymbolicName(), chain.getFilePath()) == null) {
38 cache.put(chain.getBundle().getSymbolicName(), chain.getFilePath(), url);
39 }
40 }
41 return chain.doHandler(object, url, bundle);
42 }
43
44 }