org.springframework.aop.target
Class AbstractPrototypeTargetSource

java.lang.Object
  extended byorg.springframework.aop.target.AbstractPrototypeTargetSource
All Implemented Interfaces:
BeanFactoryAware, InitializingBean, TargetSource
Direct Known Subclasses:
AbstractPoolingTargetSource, PrototypeTargetSource, ThreadLocalTargetSource

public abstract class AbstractPrototypeTargetSource
extends java.lang.Object
implements TargetSource, BeanFactoryAware, InitializingBean

Base class for dynamic TargetSources that can create new prototype bean instances to support a pooling or new-instance-per-invocation strategy. Such TargetSources must run in a BeanFactory, as it needs to call the getBean() method to create a new prototype instance.

Version:
$Id: AbstractPrototypeTargetSource.java,v 1.5 2004/03/18 10:38:13 jhoeller Exp $
Author:
Rod Johnson

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
AbstractPrototypeTargetSource()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
 java.lang.String getTargetBeanName()
          Return the name of the target bean in the factory.
 java.lang.Class getTargetClass()
           
 boolean isStatic()
           
protected  java.lang.Object newPrototypeInstance()
          Subclasses should use this method to create a new prototype instance.
 void setBeanFactory(BeanFactory beanFactory)
          Set the owning BeanFactory.
 void setTargetBeanName(java.lang.String targetBeanName)
          Set the name of the target bean in the factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.aop.TargetSource
getTarget, releaseTarget
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

AbstractPrototypeTargetSource

public AbstractPrototypeTargetSource()
Method Detail

setTargetBeanName

public void setTargetBeanName(java.lang.String targetBeanName)
Set the name of the target bean in the factory. This bean should be a prototype, or the same instance will always be obtained from the factory, resulting in the same behaviour as the InvokerInterceptor

Parameters:
targetBeanName - name of the target bean in the BeanFactory that owns this interceptor

getTargetBeanName

public java.lang.String getTargetBeanName()
Return the name of the target bean in the factory.


setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
                    throws BeansException
Set the owning BeanFactory. We need to save a reference so that we can use the getBean() method on every invocation.

Specified by:
setBeanFactory in interface BeanFactoryAware
Parameters:
beanFactory - owning BeanFactory (may not be null). The bean can immediately call methods on the factory.
Throws:
BeansException - in case of initialization errors
See Also:
BeanInitializationException

newPrototypeInstance

protected java.lang.Object newPrototypeInstance()
Subclasses should use this method to create a new prototype instance.


getTargetClass

public java.lang.Class getTargetClass()
Specified by:
getTargetClass in interface TargetSource

isStatic

public boolean isStatic()
Specified by:
isStatic in interface TargetSource

afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean


Copyright (C) 2003-2004 The Spring Framework Project.