View Javadoc
1   package com.atlassian.plugin;
2   
3   import java.io.File;
4   import java.io.InputStream;
5   import java.util.Set;
6   
7   /**
8    * Allows the retrieval of files and/or an input stream of a plugin artifact. Implementations
9    * must allow multiple calls to {@link #getInputStream()}.
10   *
11   * @see PluginController
12   * @since 2.0.0
13   */
14  public interface PluginArtifact {
15      /**
16       * @return true if the resource exists in this artifact, otherwise false
17       * @since 2.2.0
18       */
19      boolean doesResourceExist(String name);
20  
21      /**
22       * @return an input stream of the resource specified inside the artifact.  Null if the resource cannot be found.
23       * @throws PluginParseException if the there was an exception retrieving the resource from the artifact
24       */
25      InputStream getResourceAsStream(String name) throws PluginParseException;
26  
27      /**
28       * @return the original name of the plugin artifact file. Typically used
29       * for persisting it to disk with a meaningful name.
30       */
31      String getName();
32  
33      /**
34       * @return an InputStream for the entire plugin artifact. Calling this
35       * multiple times will return a fresh input stream each time.
36       */
37      InputStream getInputStream();
38  
39      /**
40       * @return the artifact as a file, or its underlying file if it is already one
41       * @since 2.2.0
42       */
43      File toFile();
44  
45      /**
46       * @return {@code true} if the plugin contains or references java executable code.
47       * @since 3.0
48       */
49      boolean containsJavaExecutableCode();
50  
51      /**
52       * @return {@code true} if the plugin contains Spring context files or instructions
53       * @since 4.1
54       */
55      boolean containsSpringContext();
56  
57      /**
58       * @return the ReferenceMode specifying whether or not this PluginArtifact may be reference installed.
59       * @since 4.0.0
60       */
61      ReferenceMode getReferenceMode();
62  
63      /**
64       * Additional interface for a plugin artifact which may support reference installation.
65       *
66       * @deprecated since 4.0.0, to be removed in 5.0.0: Equivalent functionality is now provided directly by
67       * {@link PluginArtifact#getReferenceMode()}.
68       */
69      @Deprecated
70      interface AllowsReference {
71          /**
72           * @see com.atlassian.plugin.ReferenceMode
73           */
74          enum ReferenceMode {
75              /**
76               * {@link AllowsReference#allowsReference} returns false.
77               */
78              FORBID_REFERENCE(com.atlassian.plugin.ReferenceMode.FORBID_REFERENCE),
79  
80              /**
81               * {@link AllowsReference#allowsReference} returns true.
82               */
83              PERMIT_REFERENCE(com.atlassian.plugin.ReferenceMode.PERMIT_REFERENCE);
84  
85              private final com.atlassian.plugin.ReferenceMode modern;
86  
87              private ReferenceMode(final com.atlassian.plugin.ReferenceMode modern) {
88                  this.modern = modern;
89              }
90  
91              boolean allowsReference() {
92                  return toModern().allowsReference();
93              }
94  
95              com.atlassian.plugin.ReferenceMode toModern() {
96                  return modern;
97              }
98          }
99  
100         /**
101          * @see {@link PluginArtifact#getReferenceMode} and {@link com.atlassian.plugin.ReferenceMode#allowsReference}
102          */
103         boolean allowsReference();
104 
105         /**
106          * Host to default implementation of {@link AllowsReference#allowsReference}.
107          */
108         class Default {
109             /**
110              * Forwards to {@link PluginArtifact#getReferenceMode} and {@link com.atlassian.plugin.ReferenceMode#allowsReference}.
111              *
112              * @param pluginArtifact the plugin artifact to check.
113              * @return {@code pluginArtifact.getReferenceMode().allowsReference()}
114              */
115             public static boolean allowsReference(final PluginArtifact pluginArtifact) {
116                 return pluginArtifact.getReferenceMode().allowsReference();
117             }
118         }
119     }
120 
121     interface HasExtraModuleDescriptors {
122         /**
123          * @return An Iterable containing the paths to any additional xml files found in scan folders
124          * @since 3.2.16
125          */
126         Set<String> extraModuleDescriptorFiles(String rootFolder);
127     }
128 }