1 16 17 package org.springframework.aop.scope; 18 19 import org.springframework.beans.factory.config.ConfigurableBeanFactory; 20 import org.springframework.util.Assert; 21 22 35 public class DefaultScopedObject implements ScopedObject { 36 37 private final ConfigurableBeanFactory beanFactory; 38 39 private final String targetBeanName; 40 41 42 49 public DefaultScopedObject(ConfigurableBeanFactory beanFactory, String targetBeanName) { 50 Assert.notNull(beanFactory, "BeanFactory must not be null"); 51 Assert.hasText(targetBeanName, "'targetBeanName' must not be empty"); 52 this.beanFactory = beanFactory; 53 this.targetBeanName = targetBeanName; 54 } 55 56 57 public Object getTargetObject() { 58 return this.beanFactory.getBean(this.targetBeanName); 59 } 60 61 public void removeFromScope() { 62 this.beanFactory.destroyScopedBean(this.targetBeanName); 63 } 64 65 } 66 | Popular Tags |