View Javadoc

1   package com.atlassian.plugin.util;
2   
3   import com.atlassian.plugin.ModuleDescriptor;
4   import com.atlassian.plugin.Plugin;
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(final Plugin plugin)
23      {
24          for (final ModuleDescriptor<?> descriptor : plugin.getModuleDescriptors())
25          {
26              if (descriptor.getClass().getAnnotation(RequiresRestart.class) != null)
27              {
28                  return true;
29              }
30          }
31          return false;
32      }
33  }