Package org.springframework.aop.scope

# Class ScopedProxyFactoryBean

java.lang.Object
org.springframework.aop.framework.ProxyConfig
org.springframework.aop.scope.ScopedProxyFactoryBean

All Implemented Interfaces:
  `Serializable`, `AopInfrastructureBean`, `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.BeanFactoryAware`, `org.springframework.beans.factory.FactoryBean<Object>`

public class ScopedProxyFactoryBean extends ProxyConfig implements org.springframework.beans.factory.FactoryBean<Object>, org.springframework.beans.factory.BeanFactoryAware, AopInfrastructureBean
Convenient proxy factory bean for scoped objects.

Proxies created using this factory bean are thread-safe singletons and may be injected into shared objects, with transparent scoping behavior.

Proxies returned by this class implement the `ScopedObject` interface. This presently allows for removing the corresponding object from the scope, seamlessly creating a new instance in the scope on next access.

Please note that the proxies created by this factory are class-based proxies by default. This can be customized through switching the "proxyTargetClass" property to "false".

Since:
  2.0
Author:
  Rod Johnson, Juergen Hoeller
See Also:
  - `ProxyConfig.setProxyTargetClass(boolean)`
  - Serialized Form

## Field Summary

### Fields inherited from interface org.springframework.beans.factory.FactoryBean

`OBJECT_TYPE_ATTRIBUTE`

## Constructor Summary

Constructors
Constructor
Description
`ScopedProxyFactoryBean()`
Create a new ScopedProxyFactoryBean instance.

## Method Summary

Modifier and Type
Method
Description
`Object`
`getObject()`
`Class<?>`
`getObjectType()`
`boolean`
`isSingleton()`
`void`
`setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)`
`void`
`setTargetBeanName(String targetBeanName)`
Set the name of the bean that is to be scoped.

### Methods inherited from class org.springframework.aop.framework.ProxyConfig

`copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### ScopedProxyFactoryBean

public ScopedProxyFactoryBean()
Create a new ScopedProxyFactoryBean instance.

## Method Details

### setTargetBeanName

public void setTargetBeanName(String targetBeanName)
Set the name of the bean that is to be scoped.

### setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)

Specified by:
  `setBeanFactory` in interface `org.springframework.beans.factory.BeanFactoryAware`

### getObject

@Nullable public Object getObject()

Specified by:
  `getObject` in interface `org.springframework.beans.factory.FactoryBean<Object>`

### getObjectType

@Nullable public Class<?> getObjectType()

Specified by:
  `getObjectType` in interface `org.springframework.beans.factory.FactoryBean<Object>`

### isSingleton

public boolean isSingleton()

Specified by:
  `isSingleton` in interface `org.springframework.beans.factory.FactoryBean<Object>`