Package org.dellroad.stuff.spring
Class AbstractSpringSchemaUpdate<T>
java.lang.Object
org.dellroad.stuff.schema.AbstractSchemaUpdate<T>
org.dellroad.stuff.spring.AbstractSpringSchemaUpdate<T>
- Type Parameters:
T
- database transaction type
- All Implemented Interfaces:
SchemaUpdate<T>
,Aware
,BeanFactoryAware
,BeanNameAware
,InitializingBean
- Direct Known Subclasses:
SpringPersistentObjectSchemaUpdate
,SpringSQLSchemaUpdate
public abstract class AbstractSpringSchemaUpdate<T>
extends AbstractSchemaUpdate<T>
implements BeanNameAware, BeanFactoryAware, InitializingBean
Support superclass for
SchemaUpdate
s declared in Spring BeanFactory
s 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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Configures the update name and required predecessors based on the Spring bean's name andBeanFactory
dependencies.void
setBeanFactory
(BeanFactory beanFactory) void
setBeanName
(String beanName) protected void
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 Details
-
beanName
-
beanFactory
-
-
Constructor Details
-
AbstractSpringSchemaUpdate
public AbstractSpringSchemaUpdate()
-
-
Method Details
-
setBeanName
- Specified by:
setBeanName
in interfaceBeanNameAware
-
setBeanFactory
- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
-
afterPropertiesSet
Configures the update name and required predecessors based on the Spring bean's name andBeanFactory
dependencies.- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
setRequiredPredecessorsFromDependencies
protected void setRequiredPredecessorsFromDependencies()Infer required predecessors from Spring dependencies.- Throws:
IllegalArgumentException
- if this instance'sbeanFactory
is not yet configured, or not aConfigurableBeanFactory
-