public abstract class ObjectAwareUtils
extends java.lang.Object
managed object
aware objects
,
such as ApplicationContextAware
objects
in a Spring context.Consumer
,
BeanClassLoaderAware
,
BeanFactoryAware
,
BeanNameAware
,
ApplicationContextAware
,
ApplicationEventPublisherAware
,
EnvironmentAware
,
ResourceLoaderAware
Modifier and Type | Field and Description |
---|---|
static java.util.function.Consumer<java.lang.Object> |
NO_OP |
Constructor and Description |
---|
ObjectAwareUtils() |
Modifier and Type | Method and Description |
---|---|
static java.util.function.Consumer<java.lang.Object> |
applicationContextAwareObjectInitializer(org.springframework.context.ApplicationContext applicationContext)
Returns a
Consumer capable of initializing an ApplicationContextAware Object
with the given ApplicationContext . |
static java.util.function.Consumer<java.lang.Object> |
applicationEventPublisherAwareObjectInitializer(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
Returns a
Consumer capable of initializing an ApplicationEventPublisherAware Object
with the given ApplicationEventPublisher . |
static java.util.function.Consumer<java.lang.Object> |
beanClassLoaderAwareObjectInitializer(java.lang.ClassLoader beanClassLoader)
Returns a
Consumer capable of initializing an BeanClassLoaderAware Object
with the given bean ClassLoader . |
static java.util.function.Consumer<java.lang.Object> |
beanFactoryAwareObjectInitializer(org.springframework.beans.factory.BeanFactory beanFactory)
Returns a
Consumer capable of initializing an BeanFactoryAware Object
with the given BeanFactory . |
static java.util.function.Consumer<java.lang.Object> |
beanNameAwareObjectInitializer(java.lang.String beanName)
Returns a
Consumer capable of initializing an BeanNameAware Object
with the given bean name . |
static java.util.function.Consumer<java.lang.Object> |
environmentAwareObjectInitializer(org.springframework.core.env.Environment environment)
Returns a
Consumer capable of initializing an EnvironmentAware Object
with the given Environment . |
static java.util.function.Consumer<java.lang.Object> |
resourceLoaderAwareObjectInitializer(org.springframework.core.io.ResourceLoader resourceLoader)
Returns a
Consumer capable of initializing an ResourceLoaderAware Object
with the given ResourceLoader . |
@NonNull public static java.util.function.Consumer<java.lang.Object> applicationContextAwareObjectInitializer(@Nullable org.springframework.context.ApplicationContext applicationContext)
Consumer
capable of initializing an ApplicationContextAware
Object
with the given ApplicationContext
.
The ApplicationContextAware.setApplicationContext(ApplicationContext)
method is only called on
the ApplicationContextAware
Object
if the ApplicationContext
is not null.applicationContext
- ApplicationContext
set on the ApplicationContextAware
Object
by the Consumer
.Consumer
capable of initializing an ApplicationContextAware
Object
with the given ApplicationContext
; never null.ApplicationContextAware
,
ApplicationContext
,
Consumer
@NonNull public static java.util.function.Consumer<java.lang.Object> applicationEventPublisherAwareObjectInitializer(@Nullable org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
Consumer
capable of initializing an ApplicationEventPublisherAware
Object
with the given ApplicationEventPublisher
.
The ApplicationEventPublisherAware.setApplicationEventPublisher(ApplicationEventPublisher)
method is only
called on the ApplicationEventPublisherAware
Object
if the ApplicationEventPublisherAware
is not null.applicationEventPublisher
- ApplicationEventPublisher
set on
the ApplicationEventPublisherAware
Object
by the Consumer
.Consumer
capable of initializing an ApplicationEventPublisherAware
Object
with the given ApplicationEventPublisher
; never null.ApplicationEventPublisherAware
,
ApplicationEventPublisher
,
Consumer
@NonNull public static java.util.function.Consumer<java.lang.Object> beanClassLoaderAwareObjectInitializer(@Nullable java.lang.ClassLoader beanClassLoader)
Consumer
capable of initializing an BeanClassLoaderAware
Object
with the given bean ClassLoader
.
The BeanClassLoaderAware.setBeanClassLoader(ClassLoader)
method is only called on
the BeanClassLoaderAware
Object
if the ClassLoader
is not null.beanClassLoader
- ClassLoader
set on the BeanClassLoaderAware
Object
by the Consumer
.Consumer
capable of initializing an BeanClassLoaderAware
Object
with the given bean ClassLoader
; never null.BeanClassLoaderAware
,
Consumer
,
ClassLoader
@NonNull public static java.util.function.Consumer<java.lang.Object> beanFactoryAwareObjectInitializer(@Nullable org.springframework.beans.factory.BeanFactory beanFactory)
Consumer
capable of initializing an BeanFactoryAware
Object
with the given BeanFactory
.
The BeanFactoryAware.setBeanFactory(BeanFactory)
method is only called on the BeanFactoryAware
Object
if the BeanFactory
is not null.beanFactory
- BeanFactory
set on the BeanFactoryAware
Object
by the Consumer
.Consumer
capable of initializing an BeanFactoryAware
Object
with the given BeanFactory
; never null.BeanFactoryAware
,
BeanFactory
,
Consumer
@NonNull public static java.util.function.Consumer<java.lang.Object> beanNameAwareObjectInitializer(@Nullable java.lang.String beanName)
Consumer
capable of initializing an BeanNameAware
Object
with the given bean name
.
The BeanNameAware.setBeanName(String)
method is only called on the BeanNameAware
Object
if the bean name
is not null.beanName
- String
containing the bean name to set on the BeanNameAware
Object
by the Consumer
.Consumer
capable of initializing an BeanNameAware
Object
with the given bean name
; never null.BeanNameAware
,
Consumer
@NonNull public static java.util.function.Consumer<java.lang.Object> environmentAwareObjectInitializer(@Nullable org.springframework.core.env.Environment environment)
Consumer
capable of initializing an EnvironmentAware
Object
with the given Environment
.
The EnvironmentAware.setEnvironment(Environment)
method is only called on the EnvironmentAware
Object
if the Environment
is not null.environment
- Environment
set on the EnvironmentAware
Object
by the Consumer
.Consumer
capable of initializing an EnvironmentAware
Object
with the given Environment
; never null.EnvironmentAware
,
Environment
,
Consumer
@NonNull public static java.util.function.Consumer<java.lang.Object> resourceLoaderAwareObjectInitializer(@Nullable org.springframework.core.io.ResourceLoader resourceLoader)
Consumer
capable of initializing an ResourceLoaderAware
Object
with the given ResourceLoader
.
The ResourceLoaderAware.setResourceLoader(ResourceLoader)
method is only called on
the ResourceLoaderAware
Object
if the ResourceLoader
is not null.resourceLoader
- ResourceLoader
set on the ResourceLoaderAware
Object
by the Consumer
.Consumer
capable of initializing an ResourceLoaderAware
Object
with the given ResourceLoader
; never null.ResourceLoaderAware
,
ResourceLoader
,
Consumer