public class

ComponentContainer

extends Object
java.lang.Object
   ↳ org.apache.archiva.redback.components.springutils.ComponentContainer

Class Overview

utility class to mimic some behaviour of the plexus container with role#hint

Summary

Constants
String BEAN_NAME_ROLEHINTSEPARATOR
Fields
protected ApplicationContext applicationContext
Public Constructors
ComponentContainer()
Public Methods
<T> Map<String, T> buildMapWithRole(Class<T> clazz)
must be used only at startup of container (ie in initialize method as it can cause performance issue http://jira.springframework.org/browse/SPR-5360
Produce a map with hint as key and bean as value.
static <T> Map<String, T> buildMapWithRole(Map<String, T> beansOfType)
Mimic of lookupMap from plexus.
<T> T getComponent(Class<T> clazz, String hint)
must be used only at startup of container (ie in initialize method as it can cause performance issue http://jira.springframework.org/browse/SPR-5360
Returns bean of type T and hint .
<T> T getComponent(Class<T> clazz)
must be used only at startup of container (ie in initialize method as it can cause performance issue http://jira.springframework.org/browse/SPR-5360
Returns bean of type T.
String getDefaultRoleHint()
<T> boolean hasComponent(Class<T> clazz)
Return true if one and only bean of type T exists.
<T> boolean hasComponent(Class<T> clazz, String hint)
Return true if one and only bean of type T and hint exists.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String BEAN_NAME_ROLEHINTSEPARATOR

Constant Value: "#"

Fields

protected ApplicationContext applicationContext

Public Constructors

public ComponentContainer ()

Public Methods

public Map<String, T> buildMapWithRole (Class<T> clazz)

must be used only at startup of container (ie in initialize method as it can cause performance issue http://jira.springframework.org/browse/SPR-5360
Produce a map with hint as key and bean as value.
An internal map is used to cache call to #buildMapWithRole

public static Map<String, T> buildMapWithRole (Map<String, T> beansOfType)

Mimic of lookupMap from plexus.
Ex: if the bean is called "foo#mine" "AvlRqBuilder#1"A then the map will contains mine as key with the bean foo#mine as value if no # in the bean name then the bean name will be as it's returned.

public T getComponent (Class<T> clazz, String hint)

must be used only at startup of container (ie in initialize method as it can cause performance issue http://jira.springframework.org/browse/SPR-5360
Returns bean of type T and hint .

public T getComponent (Class<T> clazz)

must be used only at startup of container (ie in initialize method as it can cause performance issue http://jira.springframework.org/browse/SPR-5360
Returns bean of type T.
It must be unique of not RuntimeException

public String getDefaultRoleHint ()

public boolean hasComponent (Class<T> clazz)

Return true if one and only bean of type T exists.

public boolean hasComponent (Class<T> clazz, String hint)

Return true if one and only bean of type T and hint exists.