org.dellroad.stuff.schema
Class AbstractSpringSchemaUpdate<T>

java.lang.Object
  extended by org.dellroad.stuff.schema.AbstractSchemaUpdate<T>
      extended by org.dellroad.stuff.schema.AbstractSpringSchemaUpdate<T>
Type Parameters:
T - database transaction type
All Implemented Interfaces:
SchemaUpdate<T>, BeanFactoryAware, BeanNameAware, InitializingBean
Direct Known Subclasses:
SpringPersistentObjectSchemaUpdate, SpringSQLSchemaUpdate

public abstract class AbstractSpringSchemaUpdate<T>
extends AbstractSchemaUpdate<T>
implements BeanNameAware, BeanFactoryAware, InitializingBean

Support superclass for SchemaUpdates declared in Spring BeanFactorys that infer their names and required predecessors from their Spring bean attributes.

Instances infer their name and required predecessors from their Spring bean name (specified by the id XML attribute) and Spring dependencies (specified by the depends-on XML attribute), respectively.

Note: the use of depends-on is an abuse of Spring's dependency notation for convenience. Normally depends-on refers to bean intialization ordering, whereas this class uses it to refer to schema update ordering. Schema updates are not normally expected to have any initialization ordering requirements, so this abuse shouldn't matter. If they do, this class should not be used.

The containing BeanFactory must be a ConfigurableBeanFactory (normally this is always the case).


Field Summary
protected  BeanFactory beanFactory
           
protected  String beanName
           
 
Constructor Summary
AbstractSpringSchemaUpdate()
           
 
Method Summary
 void afterPropertiesSet()
          Configures the update name and required predecessors based on the Spring bean's name and BeanFactory dependencies.
 void setBeanFactory(BeanFactory beanFactory)
           
 void setBeanName(String beanName)
           
protected  void setRequiredPredecessorsFromDependencies()
          Infer required predecessors from Spring dependencies.
 
Methods inherited from class org.dellroad.stuff.schema.AbstractSchemaUpdate
getName, getRequiredPredecessors, isSingleAction, setName, setRequiredPredecessors, setSingleAction, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.dellroad.stuff.schema.SchemaUpdate
getDatabaseActions
 

Field Detail

beanName

protected String beanName

beanFactory

protected BeanFactory beanFactory
Constructor Detail

AbstractSpringSchemaUpdate

public AbstractSpringSchemaUpdate()
Method Detail

setBeanName

public void setBeanName(String beanName)
Specified by:
setBeanName in interface BeanNameAware

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
Specified by:
setBeanFactory in interface BeanFactoryAware

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Configures the update name and required predecessors based on the Spring bean's name and BeanFactory dependencies.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

setRequiredPredecessorsFromDependencies

protected void setRequiredPredecessorsFromDependencies()
Infer required predecessors from Spring dependencies.

Throws:
IllegalArgumentException - if this instance's beanFactory is not yet configured, or not a ConfigurableBeanFactory