org.squirrelframework.foundation.component
Class SquirrelProvider

java.lang.Object
  extended by org.squirrelframework.foundation.component.SquirrelProvider
All Implemented Interfaces:
SquirrelSingleton

public class SquirrelProvider
extends Object
implements SquirrelSingleton

Central factory class for components used by squirrel-foundation.

Author:
Henry.He

Constructor Summary
SquirrelProvider()
           
 
Method Summary
 void clearRegistry()
           
<T> Class<T>
getImplementation(Class<T> clz)
          Return the current registered implementation.
static SquirrelProvider getInstance()
           
<T> T
newInstance(Class<T> clz)
          Create a new instance of the requested class using the internal registry.
<T> T
newInstance(Class<T> clz, Class<?>[] argTypes, Object[] args)
          Create a new instance of the requested class using the internal registry.
<T> T
newInstance(TypeReference<T> typeRef)
           
<T> T
newInstance(TypeReference<T> typeRef, Class<?>[] argTypes, Object[] args)
           
 void register(Class<?> clazz, Class<?> implementationClass)
          Register the implementation class for a certain class.
static void setInstance(SquirrelProvider instance)
           
 void unregister(Class<?> clazz)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SquirrelProvider

public SquirrelProvider()
Method Detail

getInstance

public static SquirrelProvider getInstance()

setInstance

public static void setInstance(SquirrelProvider instance)

newInstance

public <T> T newInstance(TypeReference<T> typeRef)

newInstance

public <T> T newInstance(TypeReference<T> typeRef,
                         Class<?>[] argTypes,
                         Object[] args)

newInstance

public <T> T newInstance(Class<T> clz)
Create a new instance of the requested class using the internal registry.


newInstance

public <T> T newInstance(Class<T> clz,
                         Class<?>[] argTypes,
                         Object[] args)
Create a new instance of the requested class using the internal registry.


register

public void register(Class<?> clazz,
                     Class<?> implementationClass)
Register the implementation class for a certain class. Note, if there is already an entry in the registry for the class, then it will be overwritten.


unregister

public void unregister(Class<?> clazz)

clearRegistry

public void clearRegistry()

getImplementation

public <T> Class<T> getImplementation(Class<T> clz)
Return the current registered implementation. If class has register a implementation class, return register implementation class. If register class or implement class is an interface, try to find corresponding implementation class over naming convention. (implementation class simple name = interface class simple name + "Impl") First try to find the implementation class with conventional naming under the same package as interface class. If still not exist, try to find implementation class in (interface class package + ".impl").

Parameters:
clz - registered class
Returns:
current registered implementation


Copyright © 2013-2014. All Rights Reserved.