View Javadoc

1   package com.atlassian.plugin.webresource;
2   
3   import com.atlassian.plugin.descriptors.AbstractModuleDescriptor;
4   import com.atlassian.plugin.Plugin;
5   import com.atlassian.plugin.PluginParseException;
6   import org.dom4j.Element;
7   
8   import java.util.List;
9   import java.util.ArrayList;
10  
11  /**
12   * A way of linking to web 'resources', such as javascript or css.  This allows us to include resources once
13   * on any given page, as well as ensuring that plugins can declare resources, even if they are included
14   * at the bottom of a page.
15   */
16  public class WebResourceModuleDescriptor extends AbstractModuleDescriptor<Void>
17  {
18      private List<String> dependencies = new ArrayList<String>();
19  
20      @Override
21      public void init(final Plugin plugin, final Element element) throws PluginParseException
22      {
23          super.init(plugin, element);
24  
25          @SuppressWarnings("unchecked")
26          List<Element> dependencyElements = element.elements("dependency");
27          for (Element dependency : dependencyElements)
28          {
29              dependencies.add(dependency.getTextTrim());
30          }
31      }
32  
33      /**
34       * As this descriptor just handles resources, you should never call this
35       */
36      @Override
37      public Void getModule()
38      {
39          throw new UnsupportedOperationException("There is no module for Web Resources");
40      }
41  
42      /**
43       * Returns a list of dependencies on other web resources.
44       * @return a list of module complete keys
45       */
46      public List<String> getDependencies()
47      {
48          return dependencies;
49      }
50  }