info.magnolia.objectfactory
Interface ComponentProvider

All Known Implementing Classes:
DefaultComponentProvider, GuiceComponentProvider

public interface ComponentProvider

ComponentProvider is responsible for providing components, these can be scoped as singletons or live in narrower scopes such as local and session, or be non scoped in which case a new instances will be created. Magnolia "beans", "managers" etc are all provided by this. Since Magnolia 4.5, you are encouraged to use IoC, only in rare cases should you need to directly use this class.

Version:
$Id$
See Also:
ComponentFactory

Method Summary
<T> T
getComponent(Class<T> type)
          Returns the component mapped for a given type.
<T> Class<? extends T>
getImplementation(Class<T> type)
          Returns the implementation type mapped for a given type.
 ComponentProvider getParent()
           
<T> T
getSingleton(Class<T> type)
          Deprecated. since 4.5, use IoC. If you really need to look up a component, then use getComponent(Class)
<T> T
newInstance(Class<T> type, Object... parameters)
          Creates a new instance of the passed interface / class by using the registered implementation.
<T> T
newInstanceWithParameterResolvers(Class<T> type, ParameterResolver... parameters)
           
 

Method Detail

getImplementation

<T> Class<? extends T> getImplementation(Class<T> type)
                                     throws ClassNotFoundException
Returns the implementation type mapped for a given type. This is primarily used by Content2Bean.

Throws:
ClassNotFoundException - in case there's no implementation for the provided type

getSingleton

<T> T getSingleton(Class<T> type)
Deprecated. since 4.5, use IoC. If you really need to look up a component, then use getComponent(Class)

Returns the component mapped for a given type.

See Also:
getComponent(Class)

getComponent

<T> T getComponent(Class<T> type)
               throws NoSuchComponentException
Returns the component mapped for a given type.

Returns:
the component that is mapped for this type or null if there is none
Throws:
NoSuchComponentException - in case the component wasn't found

newInstance

<T> T newInstance(Class<T> type,
                  Object... parameters)
Creates a new instance of the passed interface / class by using the registered implementation. The parameters are used to build the object. Most likely they are passed to the constructor. If this fails a MgnlInstantiationException is thrown.


newInstanceWithParameterResolvers

<T> T newInstanceWithParameterResolvers(Class<T> type,
                                        ParameterResolver... parameters)

getParent

ComponentProvider getParent()


Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.