com.atlassian.plugin.module
Class PrefixDelegatingModuleFactory

java.lang.Object
  extended by com.atlassian.plugin.module.PrefixDelegatingModuleFactory
All Implemented Interfaces:
ModuleFactory

public class PrefixDelegatingModuleFactory
extends java.lang.Object
implements ModuleFactory

The default implementation of a ModuleFactory. The module class name can contain a prefix and this prefix determines which ModuleFactory is used to create the java class for this module descriptor.

If no prefix is supplied it will use ClassPrefixModuleFactory to create the module class object.

ModuleFactories are located via the following algorithm. First, the prefixes registered during construction are searched, then any implementations in the plugin's container, if applicable.

Implementation note: The plugin's container is searched, instead of a general search for all OSGi services registered against PrefixModuleFactory, because the factories have to be available before any modules are created, and Spring DM, for example, ensures all required service references are available before creating the context, which is then interpreted as an enabled plugin.


Field Summary
 
Fields inherited from interface com.atlassian.plugin.module.ModuleFactory
LEGACY_MODULE_FACTORY
 
Constructor Summary
PrefixDelegatingModuleFactory(java.util.Set<PrefixModuleFactory> delegates)
           
 
Method Summary
 void addPrefixModuleFactory(PrefixModuleFactory prefixModuleFactory)
           
<T> T
createModule(java.lang.String className, ModuleDescriptor<T> moduleDescriptor)
          Creates the module instance.
protected  ModuleFactory getModuleFactoryForPrefix(com.atlassian.plugin.module.PrefixDelegatingModuleFactory.ModuleReference moduleReference, ModuleDescriptor<?> moduleDescriptor)
          Returns the module factory for a prefix, first using registered prefixes, then any from the plugin's container.
<T> java.lang.Class<T>
guessModuleClass(java.lang.String name, ModuleDescriptor<T> moduleDescriptor)
          Deprecated. Since 2.5.0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrefixDelegatingModuleFactory

public PrefixDelegatingModuleFactory(java.util.Set<PrefixModuleFactory> delegates)
Method Detail

addPrefixModuleFactory

public void addPrefixModuleFactory(PrefixModuleFactory prefixModuleFactory)

getModuleFactoryForPrefix

protected ModuleFactory getModuleFactoryForPrefix(com.atlassian.plugin.module.PrefixDelegatingModuleFactory.ModuleReference moduleReference,
                                                  ModuleDescriptor<?> moduleDescriptor)
Returns the module factory for a prefix, first using registered prefixes, then any from the plugin's container.

Parameters:
moduleReference - The module reference
moduleDescriptor - The descriptor containing the module
Returns:
The instance, can return null

createModule

public <T> T createModule(java.lang.String className,
                          ModuleDescriptor<T> moduleDescriptor)
               throws PluginParseException
Description copied from interface: ModuleFactory
Creates the module instance. The module class name can contain a prefix. The delimiter of the prefix and the class name is ':'. E.g.: 'bean:httpServletBean'. Which prefixes are supported depends on the registered com.atlassian.plugin.module.ModuleCreator. The prefix is case in-sensitive.

Specified by:
createModule in interface ModuleFactory
Parameters:
className - module class name, can contain a prefix followed by ":" and the class name. Cannot be null If no prefix provided a default behaviour is assumed how to create the module class.
moduleDescriptor - the ModuleDescriptor. Cannot be null
Returns:
an instantiated object of the module class.
Throws:
PluginParseException - If it failed to create the object.

guessModuleClass

@Deprecated
public <T> java.lang.Class<T> guessModuleClass(java.lang.String name,
                                                          ModuleDescriptor<T> moduleDescriptor)
                                    throws ModuleClassNotFoundException
Deprecated. Since 2.5.0

This is not to be used. It is only for backwards compatibility with old code that uses PluginAccessor.getEnabledModulesByClass(Class). This method can and will be removed without warning.

Type Parameters:
T - The module class type
Parameters:
name - The class name
moduleDescriptor - The module descriptor
Returns:
The module class
Throws:
ModuleClassNotFoundException


Copyright © 2010 Atlassian. All Rights Reserved.