View Javadoc

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      /**
17       * Scan for new deployment units. On the first scan, all deployment units that the scanner can find will
18       * be returned. Subsequent scans will only return deployment units that are new since the last scan (or
19       * call to reset() or clear())
20       *
21       * @return all new deployment units since the last scan
22       */
23      Collection<DeploymentUnit> scan();
24  
25      /**
26       * Gets all deployment units currently being tracked by the scanner. This <i>will not</i> trigger
27       * a scan, meaning that plugins that have been added since the last scan will not be returned.
28       *
29       * @return a collection of all deployment units currently being tracked by the scanner.
30       */
31      Collection<DeploymentUnit> getDeploymentUnits();
32  
33      /**
34       * Reset the scanner. This causes it to forget all state about which plugins have (or haven't) been loaded.
35       */
36      void reset();
37  
38      /**
39       * Remove the specified deployment unit in such a way as it will not be picked up by subsequent scans, even
40       * if the system is restarted.
41       *
42       * @param unit the deployment unit to remove
43       * @throws PluginException if the unit has not been properly removed: i.e. a restart would mean the unit would
44       *         be reloaded.
45       */
46      void remove(DeploymentUnit unit) throws PluginException;
47  }