1   package com.atlassian.plugin.osgi;
2   
3   import com.atlassian.plugin.descriptors.AbstractModuleDescriptor;
4   import com.atlassian.plugin.AutowireCapablePlugin;
5   
6   /**
7    * Module type for an object
8    */
9   public class ObjectModuleDescriptor extends AbstractModuleDescriptor<Object>
10  {
11      public Object getModule()
12      {
13          Object module = null;
14          // Give the plugin a go first
15          if (plugin instanceof AutowireCapablePlugin)
16          {
17              module = ((AutowireCapablePlugin) plugin).autowire(getModuleClass());
18          }
19          else
20          {
21              try
22              {
23                  module = getModuleClass().newInstance();
24              }
25              catch (InstantiationException e)
26              {
27                  throw new RuntimeException(e);
28              }
29              catch (IllegalAccessException e)
30              {
31                  throw new RuntimeException(e);
32              }
33          }
34          return module;
35      }
36  }