1 package com.atlassian.plugin.module;
2
3 import com.atlassian.plugin.ModuleDescriptor;
4 import com.atlassian.plugin.PluginParseException;
5
6 /**
7 * The {@link ModuleFactory} creates the module class of a {@link com.atlassian.plugin.ModuleDescriptor}.
8 * The ModuleFactory is injected into the {@code AbstractModuleDescriptor} and encapsulates the different strategies
9 * how the module class can be created.
10 *
11 * @since 2.5.0
12 */
13 public interface ModuleFactory {
14 /**
15 * Creates the module instance. The module class name can contain a prefix. The delimiter of the prefix and the
16 * class name is ':'. E.g.: 'bean:httpServletBean'. Which prefixes are supported depends on the registered
17 * {@code ModuleCreator}. The prefix is case in-sensitive.
18 *
19 * @param name module class name, can contain a prefix followed by ":" and the class name. Cannot be
20 * {@code null}. If no prefix provided a default behaviour is assumed how to create the
21 * module class.
22 * @param moduleDescriptor the {@link com.atlassian.plugin.ModuleDescriptor}. Cannot be {@code null}
23 * @return an instantiated object of the module class.
24 * @throws PluginParseException If it failed to create the object.
25 */
26 <T> T createModule(String name, ModuleDescriptor<T> moduleDescriptor) throws PluginParseException;
27
28 ModuleFactory LEGACY_MODULE_FACTORY = new LegacyModuleFactory();
29 }