info.magnolia.objectfactory
Class DefaultComponentProvider

java.lang.Object
  extended by info.magnolia.objectfactory.DefaultComponentProvider
All Implemented Interfaces:
ComponentProvider

public class DefaultComponentProvider
extends Object
implements ComponentProvider

This ComponentProvider is using the configuration provided by SystemProperty. Each property key is the interface/base-class, and the value is either the implementation-to-use class name, an implementation of ComponentFactory which is used to instantiate the desired implementation, or the path to a node in the repository (in the form of repository:/path/to/node or /path/to/node, which defaults to the config repository). In the latter case, the component is constructed via ObservedComponentFactory and reflects (through observation) the contents of the given path.

Version:
$Revision: 25238 $ ($Author: pbaerfuss $)
Author:
Philipp Bracher

Method Summary
 void clear()
          Used only in tests.
<C> Class<? extends C>
getImplementation(Class<C> type)
           
protected  String getImplementationName(Class<?> type)
           
<T> T
getSingleton(Class<T> type)
           
protected  boolean isConcrete(Class<?> clazz)
           
<T> T
newInstance(Class<T> type)
          Creates a new instance of the passed interface / class by using the registered implementation.
 void setImplementation(Class<?> type, String impl)
          Used only in tests.
 void setInstance(Class<?> type, Object instance)
          Used only in tests.
 void setInstanceFactory(Class<?> type, ComponentFactory<?> factory)
          Used only in tests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSingleton

public <T> T getSingleton(Class<T> type)
Specified by:
getSingleton in interface ComponentProvider

newInstance

public <T> T newInstance(Class<T> type)
Creates a new instance of the passed interface / class by using the registered implementation. If this fails a MgnlInstantiationException is thrown.

Specified by:
newInstance in interface ComponentProvider
Throws:
MgnlInstantiationException

isConcrete

protected boolean isConcrete(Class<?> clazz)

getImplementation

public <C> Class<? extends C> getImplementation(Class<C> type)
                                     throws ClassNotFoundException
Specified by:
getImplementation in interface ComponentProvider
Throws:
ClassNotFoundException

getImplementationName

protected String getImplementationName(Class<?> type)

setImplementation

public void setImplementation(Class<?> type,
                              String impl)
Used only in tests.

See Also:
info.magnolia.test.ComponentsTestUtil}

setInstance

public void setInstance(Class<?> type,
                        Object instance)
Used only in tests.

See Also:
info.magnolia.test.ComponentsTestUtil}

setInstanceFactory

public void setInstanceFactory(Class<?> type,
                               ComponentFactory<?> factory)
Used only in tests.

See Also:
info.magnolia.test.ComponentsTestUtil}

clear

public void clear()
Used only in tests. Warning: this does NOT clear the *mappings*. With the current/default implementation, this means tests also have to call SystemProperty.clearr()

See Also:
info.magnolia.test.ComponentsTestUtil}


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