View Javadoc

1   package com.atlassian.plugin.osgi.factory.descriptor;
2   
3   import com.atlassian.plugin.Permissions;
4   import com.atlassian.plugin.Plugin;
5   import com.atlassian.plugin.PluginParseException;
6   import com.atlassian.plugin.RequirePermission;
7   import com.atlassian.plugin.descriptors.AbstractModuleDescriptor;
8   import com.atlassian.plugin.descriptors.CannotDisable;
9   import com.atlassian.plugin.module.ModuleFactory;
10  import com.atlassian.plugin.osgi.module.BeanPrefixModuleFactory;
11  import com.atlassian.util.concurrent.NotNull;
12  import org.dom4j.Element;
13  
14  /**
15   * Module descriptor for components.  Shouldn't be directly used outside providing read-only information.
16   *
17   * @since 2.2.0
18   */
19  @CannotDisable
20  @RequirePermission(Permissions.EXECUTE_JAVA)
21  public class ComponentModuleDescriptor extends AbstractModuleDescriptor<Object>
22  {
23      public ComponentModuleDescriptor()
24      {
25          super(ModuleFactory.LEGACY_MODULE_FACTORY);
26      }
27  
28      @Override
29      public void init(@NotNull Plugin plugin, @NotNull Element element) throws PluginParseException
30      {
31          super.init(plugin, element);
32          checkPermissions();
33      }
34  
35      @Override
36      protected void loadClass(Plugin plugin, String clazz) throws PluginParseException
37      {
38          try
39          {
40              // this should have been done once by the plugin container so should never throw exception.
41              this.moduleClass = plugin.loadClass(clazz, null);
42          }
43          catch (ClassNotFoundException e)
44          {
45              throw new PluginParseException("cannot load component class", e);
46          }
47      }
48  
49      @Override
50      public Object getModule()
51      {
52          return new BeanPrefixModuleFactory().createModule(getKey(), this);
53      }
54  
55      /**
56       * @return Module Class Name
57       * @since 2.3.0
58       * @deprecated - BEWARE that this is a temporary method that will not exist for long. Deprecated since 2.3.0
59       */
60      public String getModuleClassName()
61      {
62          return moduleClassName;
63      }
64  }