View Javadoc

1   package com.atlassian.plugin.util;
2   
3   import com.atlassian.plugin.Plugin;
4   import com.atlassian.plugin.ModuleDescriptor;
5   import com.atlassian.plugin.descriptors.RequiresRestart;
6   
7   /**
8    * General plugin utility methods
9    *
10   * @since 2.1
11   */
12  public class PluginUtils
13  {
14      /**
15       * Determines if a plugin requires a restart after being installed at runtime.  Looks for the annotation
16       * {@link RequiresRestart} on the plugin's module descriptors.
17       *
18       * @param plugin The plugin that was just installed at runtime, but not yet enabled
19       * @return True if a restart is required
20       * @since 2.1
21       */
22      public static boolean doesPluginRequireRestart(Plugin plugin)
23      {
24          boolean requiresRestart = false;
25          for (ModuleDescriptor descriptor : plugin.getModuleDescriptors())
26          {
27              if (descriptor.getClass().getAnnotation(RequiresRestart.class) != null)
28              {
29                  requiresRestart = true;
30                  break;
31              }
32          }
33          return requiresRestart;
34      }
35  }