1 package com.atlassian.plugin.loaders.classloading;
2
3 import com.atlassian.plugin.PluginException;
4
5 import java.util.Collection;
6
7 /**
8 * Monitors some hypothetical space for deployed plugins. Due to limitations in the plugin system, plugins must
9 * at some point be represented as files, so for situations where plugins are not files (i.e. database-stored
10 * plugins) the scanner is responsible for copying them to the filesystem before they are used)
11 *
12 * @since 2.1.0
13 */
14 public interface Scanner {
15 /**
16 * Scan for new deployment units. On the first scan, all deployment units that the scanner can find will
17 * be returned. Subsequent scans will only return deployment units that are new since the last scan (or
18 * call to reset() or clear())
19 *
20 * @return all new deployment units since the last scan
21 */
22 Collection<DeploymentUnit> scan();
23
24 /**
25 * Gets all deployment units currently being tracked by the scanner. This <i>will not</i> trigger
26 * a scan, meaning that plugins that have been added since the last scan will not be returned.
27 *
28 * @return a collection of all deployment units currently being tracked by the scanner.
29 */
30 Collection<DeploymentUnit> getDeploymentUnits();
31
32 /**
33 * Reset the scanner. This causes it to forget all state about which plugins have (or haven't) been loaded.
34 */
35 void reset();
36
37 /**
38 * Remove the specified deployment unit in such a way as it will not be picked up by subsequent scans, even
39 * if the system is restarted.
40 *
41 * @param unit the deployment unit to remove
42 * @throws PluginException if the unit has not been properly removed: i.e. a restart would mean the unit would
43 * be reloaded.
44 */
45 void remove(DeploymentUnit unit) throws PluginException;
46 }