org.xwiki.component.annotation
Class ComponentAnnotationLoader

java.lang.Object
  extended by org.xwiki.component.annotation.ComponentAnnotationLoader

public class ComponentAnnotationLoader
extends java.lang.Object

Dynamically loads all components defined using Annotations and declared in META-INF/components.txt files.

Since:
1.8.1
Version:
$Id$

Field Summary
static java.lang.String COMPONENT_LIST
          Location in the classloader of the file defining the list of component implementation class to parser for annotations.
static java.lang.String COMPONENT_OVERRIDE_LIST
          Location in the classloader of the file specifying which component implementation to use when several with the same role/hint are found.
 
Constructor Summary
ComponentAnnotationLoader()
           
 
Method Summary
 java.util.Set<java.lang.Class<?>> findComponentRoleClasses(java.lang.Class<?> componentClass)
          Finds the interfaces that implement component roles by looking recursively in all interfaces of the passed component implementation class.
 java.util.List<ComponentDescriptor> getComponentsDescriptors(java.lang.Class<?> componentClass)
           
 java.util.List<java.lang.String> getDeclaredComponents(java.io.InputStream componentListStream)
          Get all components listed in the passed resource stream.
 void initialize(ComponentManager manager, java.lang.ClassLoader classLoader)
          Loads all components defined using annotations.
 void initialize(ComponentManager manager, java.lang.ClassLoader classLoader, java.util.List<java.lang.String> componentClassNames, java.util.List<java.lang.String> componentOverrideClassNames)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_LIST

public static final java.lang.String COMPONENT_LIST
Location in the classloader of the file defining the list of component implementation class to parser for annotations.

See Also:
Constant Field Values

COMPONENT_OVERRIDE_LIST

public static final java.lang.String COMPONENT_OVERRIDE_LIST
Location in the classloader of the file specifying which component implementation to use when several with the same role/hint are found.

See Also:
Constant Field Values
Constructor Detail

ComponentAnnotationLoader

public ComponentAnnotationLoader()
Method Detail

initialize

public void initialize(ComponentManager manager,
                       java.lang.ClassLoader classLoader)
Loads all components defined using annotations.

Parameters:
manager - the component manager to use to dynamically register components
classLoader - the classloader to use to look for the Component list declaration file ( META-INF/components.txt)

initialize

public void initialize(ComponentManager manager,
                       java.lang.ClassLoader classLoader,
                       java.util.List<java.lang.String> componentClassNames,
                       java.util.List<java.lang.String> componentOverrideClassNames)
Parameters:
manager - the component manager to use to dynamically register components
classLoader - the classloader to use to look for the Component list declaration file ( META-INF/components.txt)
componentClassNames - the list of components to load
componentOverrideClassNames - the list of components to override
Since:
2.5M2

getComponentsDescriptors

public java.util.List<ComponentDescriptor> getComponentsDescriptors(java.lang.Class<?> componentClass)

findComponentRoleClasses

public java.util.Set<java.lang.Class<?>> findComponentRoleClasses(java.lang.Class<?> componentClass)
Finds the interfaces that implement component roles by looking recursively in all interfaces of the passed component implementation class. If the roles annotation value is specified then use the specified list instead of doing auto-discovery.

Parameters:
componentClass - the component implementation class for which to find the component roles it implements
Returns:
the list of component role classes implemented

getDeclaredComponents

public java.util.List<java.lang.String> getDeclaredComponents(java.io.InputStream componentListStream)
                                                       throws java.io.IOException
Get all components listed in the passed resource stream.

Parameters:
componentListStream - the stream to parse
Returns:
the list of component implementation class names
Throws:
java.io.IOException - in case of an error loading the component list resource
Since:
2.5M2


Copyright © 2004-2011 XWiki. All Rights Reserved.