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 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

      public static <T> T getBeanFrom(Class<T> beanClass)
      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

      public static String getPropertyValue(String key)
      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 interface org.springframework.context.ApplicationContextAware