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 interface HasExtraModuleDescriptors {
64 /**
65 * @return An Iterable containing the paths to any additional xml files found in scan folders
66 * @since 3.2.16
67 */
68 Set<String> extraModuleDescriptorFiles(String rootFolder);
69 }
70 }