View Javadoc

1   package com.atlassian.plugin.refimpl.webresource;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import javax.servlet.ServletContext;
7   
8   import com.atlassian.plugin.PluginAccessor;
9   import com.atlassian.plugin.refimpl.ContainerManager;
10  import com.atlassian.plugin.refimpl.ParameterUtils;
11  import com.atlassian.plugin.webresource.WebResourceIntegration;
12  
13  public class SimpleWebResourceIntegration implements WebResourceIntegration
14  {
15      private final String systemBuildNumber;
16      private final ThreadLocal<Map> requestCache;
17      
18      public SimpleWebResourceIntegration(ServletContext servletContext)
19      {
20          // we fake the build number by using the startup time which will force anything cached by clients to be 
21          // reloaded after a restart
22          this.systemBuildNumber = String.valueOf(System.currentTimeMillis());
23  
24          requestCache = new ThreadLocal<Map>();
25      }
26  
27      public String getBaseUrl()
28      {
29          return ParameterUtils.getBaseUrl();
30      }
31  
32      public PluginAccessor getPluginAccessor()
33      {
34          return ContainerManager.getInstance().getPluginManager();
35      }
36  
37      public Map getRequestCache()
38      {
39          // if it's null, we just create a new one.. tho this means results from one request will affect the next request
40          // on this same thread because we don't ever clean it up from a filter or anything - definitely not for use in
41          // production!
42          if (requestCache.get() == null)
43              requestCache.set(new HashMap());
44          
45          return requestCache.get();
46      }
47  
48      public String getSystemBuildNumber()
49      {
50          return systemBuildNumber;
51      }
52  
53      public String getSystemCounter()
54      {
55          return "1";
56      }
57  
58  }