Hi all,
Our app uses a mix of JDO and straight DAO objects. I have created an interface "MigrationCapable". I'm using @Autowired in the following code.
As you can see, this postconstruct simply gets the meta data, then passes it off to the migrate call. Unfortunately, I can't simply put this in an abstract class since our inheritance tree doesn't allow it. I have the following dependency order.Code:@Configuration public class MigrationHelper { @Autowired private ICassandraConnection connection; @Autowired private List<MigrationCapable> migrations; @PostConstruct public void migration() throws Exception{ String keySpace = connection.getKeyspace(); for(MigrationCapable current: migrations){ //get a fresh view of the cluster for each migration ColumnFamilyManager cm = Pelops.createColumnFamilyManager(connection.getCluster(),keySpace); KeyspaceManager manager = Pelops.createKeyspaceManager(connection.getCluster()); current.migrate(cm, manager.getKeyspaceSchema(keySpace)); } } }
service --> DAO --> connection
When spring is creating the service tier, @PostConstruct methods are being invoked before my MigrationHelper configuration bean. Given that this only need to run at startup, is there a way I can get the migration help to run once all it's dependencies have been met BEFORE any other objects are configured?
Thanks,
Todd


Reply With Quote