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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
defineContext
(org.springframework.context.ApplicationContext newContext) Set the spring context to retrive objects.static <T> T
getBeanFrom
(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.Environment
Get the context environmentstatic String
getPropertyValue
(String key) Get the property value.void
setApplicationContext
(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
Environment
object
-
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:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-