View Javadoc

1   package com.atlassian.plugin.servlet;
2   
3   import com.atlassian.plugin.Plugin;
4   import com.atlassian.plugin.elements.ResourceLocation;
5   
6   import javax.servlet.ServletContext;
7   import java.io.InputStream;
8   
9   /**
10   * A {@link DownloadableResource} that will serve the resource via the web application's {@link ServletContext}.
11   */
12  public class DownloadableWebResource extends AbstractDownloadableResource
13  {
14      private final ServletContext servletContext;
15  
16      public DownloadableWebResource(Plugin plugin, ResourceLocation resourceLocation, String extraPath, ServletContext servletContext)
17      {
18          super(plugin, resourceLocation, extraPath);
19          this.servletContext = servletContext;
20      }
21  
22      protected InputStream getResourceAsStream()
23      {
24          return servletContext.getResourceAsStream(getLocation());
25      }
26  }