Package org.imageconverter.util
Class BeanUtil
java.lang.Object
org.imageconverter.util.BeanUtil
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Component
public class BeanUtil
extends Object
implements org.springframework.context.ApplicationContextAware
Utils to retrieves spring objects to non managed objects.
- Author:
- Fernando Romulo da Silva
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddefineContext(org.springframework.context.ApplicationContext newContext) Set the spring context to retrive objects.static <T> TgetBeanFrom(Class<T> beanClass) Get a bean from its type.static <T> org.springframework.beans.factory.ObjectProvider<T>getBeanProviderFrom(Class<T> beanClass) Get a bean provider (factory) from its type.static org.springframework.core.env.EnvironmentGet the context environmentstatic StringgetPropertyValue(String key) Get the property value.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
Constructor Details
-
BeanUtil
public BeanUtil()
-
-
Method Details
-
defineContext
public static void defineContext(org.springframework.context.ApplicationContext newContext) Set the spring context to retrive objects.- Parameters:
newContext- The new context
-
getBeanFrom
Get a bean from its type.- Type Parameters:
T- The type- Parameters:
beanClass- The class type- Returns:
- A bean retrieved
-
getBeanProviderFrom
public static <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProviderFrom(Class<T> beanClass) Get a bean provider (factory) from its type.- Type Parameters:
T- The type- Parameters:
beanClass- The class type- Returns:
- A bean retrieved
-
getEnvironment
public static org.springframework.core.env.Environment getEnvironment()Get the context environment- Returns:
- A
Environmentobject
-
getPropertyValue
Get the property value.- Parameters:
key- The property value- Returns:
- The String value property
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-