Class Jadice
- java.lang.Object
-
- com.levigo.jadice.document.config.Jadice
-
public class Jadice extends Object
Helper methods for object creation and configuration. The methods supplied by this class are mainly used by jadice components internally; however, they can be helpful in a few advanced integration scenarios.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidconfigure(Object instance)Apply all registered and applicableComponentConfigurers to an object.static <C> Ccreate(Class<C> componentClass)Create a new instance of the given type and apply theComponentConfigurers pertaining to it.static Resolver<Class<?>,ClassNotFoundException>getClassResolver()static voidpurgeComponentConfigurers()Remove all registeredComponentConfigurerinstances.static voidregisterComponentConfigurer(ComponentConfigurer<? extends Object> cc, Class<?>... supportedClasses)Add aComponentConfigurerto the collection of configurers which are invoked byconfigure(Object), if applicable.static voidsetClassResolver(Resolver<Class<?>,ClassNotFoundException> resolver)
-
-
-
Method Detail
-
purgeComponentConfigurers
public static void purgeComponentConfigurers()
Remove all registeredComponentConfigurerinstances.
-
registerComponentConfigurer
public static void registerComponentConfigurer(ComponentConfigurer<? extends Object> cc, Class<?>... supportedClasses)
Add aComponentConfigurerto the collection of configurers which are invoked byconfigure(Object), if applicable.- Parameters:
cc- the instance to be registeredsupportedClasses- the type (or types) of classes which thisComponentConfigureris able to configure
-
create
public static <C> C create(Class<C> componentClass)
Create a new instance of the given type and apply theComponentConfigurers pertaining to it.- Parameters:
componentClass- the class to be instantiated- Returns:
- a new instance of the requested type, readily configured.
- Throws:
IllegalArgumentException- if instantiation is not possible due to various reasons, such as Illegal Access or a non-instantiable kind of class
-
configure
public static void configure(Object instance)
Apply all registered and applicableComponentConfigurers to an object. AComponentConfigureris applicable if the type of object which it is able to configure matches the given instance's type.- Parameters:
instance- the object to be configured
-
getClassResolver
public static Resolver<Class<?>,ClassNotFoundException> getClassResolver()
-
setClassResolver
public static void setClassResolver(Resolver<Class<?>,ClassNotFoundException> resolver)
Set theResolverto be used by jadice compontents when looking upClassinstances based on their name. Setting a custom resolver is only needed in very few advanced integration scenarios.- Parameters:
resolver- theResolverto be used from now on
-
-