Top Description Fields Constructors Methods
org.springframework.aop.framework.autoproxy

public abstract Class AutoProxyUtils

extends Object
Class Inheritance
Imports
org.springframework.beans.factory.config.AutowireCapableBeanFactory, .BeanDefinition, .ConfigurableListableBeanFactory, org.springframework.core.Conventions, org.springframework.lang.Nullable, org.springframework.util.StringUtils

Utilities for auto-proxy aware components. Mainly for internal use within the framework.
Author
Juergen Hoeller
Since
2.0.3
See Also
AbstractAutoProxyCreator

Field Summary

Modifier and TypeField and Description
public static final String
ORIGINAL_TARGET_CLASS_ATTRIBUTE

Bean definition attribute that indicates the original target class of an auto-proxied bean, e.g. to be used for the introspection of annotations on the target class behind an interface-based proxy.

public static final String
PRESERVE_TARGET_CLASS_ATTRIBUTE

Bean definition attribute that may indicate whether a given bean is supposed to be proxied with its target class (in case of it getting proxied in the first place).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Class<?>

Returns:

the original target class as stored in the bean definition, if any
determineTargetClass
(ConfigurableListableBeanFactory
the containing ConfigurableListableBeanFactory
beanFactory
,
String
the name of the bean
beanName
)

Determine the original target class for the specified bean, if possible, otherwise falling back to a regular getType lookup.

pack-priv static void
exposeTargetClass(ConfigurableListableBeanFactory
the containing ConfigurableListableBeanFactory
beanFactory
,
String
the name of the bean
beanName
,
Class<?>
the corresponding target class
targetClass
)

Expose the given target class for the specified bean, if possible.

pack-priv static boolean
isOriginalInstance(String
the name of the bean
beanName
,
Class<?>
the corresponding bean class
beanClass
)

Determine whether the given bean name indicates an "original instance" according to AutowireCapableBeanFactory#ORIGINAL_INSTANCE_SUFFIX, skipping any proxy attempts for it.

public static boolean

Returns:

whether the given bean should be proxied with its target class
shouldProxyTargetClass
(ConfigurableListableBeanFactory
the containing ConfigurableListableBeanFactory
beanFactory
,
String
the name of the bean
beanName
)

Determine whether the given bean should be proxied with its target class rather than its interfaces.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ORIGINAL_TARGET_CLASS_ATTRIBUTEback to summary
public static final String ORIGINAL_TARGET_CLASS_ATTRIBUTE

Bean definition attribute that indicates the original target class of an auto-proxied bean, e.g. to be used for the introspection of annotations on the target class behind an interface-based proxy.

Since
4.2.3
See Also
determineTargetClass
PRESERVE_TARGET_CLASS_ATTRIBUTEback to summary
public static final String PRESERVE_TARGET_CLASS_ATTRIBUTE

Bean definition attribute that may indicate whether a given bean is supposed to be proxied with its target class (in case of it getting proxied in the first place). The value is Boolean.TRUE or Boolean.FALSE.

Proxy factories can set this attribute if they built a target class proxy for a specific bean, and want to enforce that bean can always be cast to its target class (even if AOP advices get applied through auto-proxying).

See Also
shouldProxyTargetClass

Constructor Detail

AutoProxyUtilsback to summary
public AutoProxyUtils()

Method Detail

determineTargetClassback to summary
public static Class<?> determineTargetClass(ConfigurableListableBeanFactory beanFactory, String beanName)

Determine the original target class for the specified bean, if possible, otherwise falling back to a regular getType lookup.

Parameters
beanFactory:ConfigurableListableBeanFactory

the containing ConfigurableListableBeanFactory

beanName:String

the name of the bean

Returns:Class<?>

the original target class as stored in the bean definition, if any

Annotations
@Nullable
Since
4.2.3
See Also
org.springframework.beans.factory.BeanFactory#getType(String)
exposeTargetClassback to summary
pack-priv static void exposeTargetClass(ConfigurableListableBeanFactory beanFactory, String beanName, Class<?> targetClass)

Expose the given target class for the specified bean, if possible.

Parameters
beanFactory:ConfigurableListableBeanFactory

the containing ConfigurableListableBeanFactory

beanName:String

the name of the bean

targetClass:Class<?>

the corresponding target class

Since
4.2.3
isOriginalInstanceback to summary
pack-priv static boolean isOriginalInstance(String beanName, Class<?> beanClass)

Determine whether the given bean name indicates an "original instance" according to AutowireCapableBeanFactory#ORIGINAL_INSTANCE_SUFFIX, skipping any proxy attempts for it.

Parameters
beanName:String

the name of the bean

beanClass:Class<?>

the corresponding bean class

Since
5.1
See Also
AutowireCapableBeanFactory#ORIGINAL_INSTANCE_SUFFIX
shouldProxyTargetClassback to summary
public static boolean shouldProxyTargetClass(ConfigurableListableBeanFactory beanFactory, String beanName)

Determine whether the given bean should be proxied with its target class rather than its interfaces. Checks the "preserveTargetClass" attribute of the corresponding bean definition.

Parameters
beanFactory:ConfigurableListableBeanFactory

the containing ConfigurableListableBeanFactory

beanName:String

the name of the bean

Returns:boolean

whether the given bean should be proxied with its target class