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 java.io.InputStream;
7   import javax.servlet.ServletContext;
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, boolean disableMinification)
17      {
18          super(plugin, resourceLocation, extraPath, disableMinification);
19          this.servletContext = servletContext;
20      }
21  
22      @Override
23      protected InputStream getResourceAsStream(final String resourceLocation)
24      {
25          return servletContext.getResourceAsStream(resourceLocation);
26      }
27  }