Nov 6th, 2011, 01:56 PM
Autocreating a proxy for a chain of targets based on interface
I have a problem and I'm unsure how to approach it. I've used spring since v 1.0, and I'm very comfortable with the framework. Here is our use case.
* We must have 0 downtime
* As a result of the first condition, if we change storage mechanisms, we will have more than 1 implementation of a DAO object during the migration process
* We need a bean instance that is proxy for a chain of target instances, and invokes the write operations on all DAO objects, while performing reads on the specified index. The proxy DAO will be exposed to the service tier, and the proxy will contain a list of implementations of the same interface type.
This allows the following migration case.
1. Writes occur to all data formats on deploy, both new and old
2. Reads occur on the old data format
3. After modifying the properties for the target instance to read, reads will occur in the new instance
This allows us to perform background migrations, then restart the services to use the "new" data access object for reads.
I've created several of my own aspects for around advice, mostly dealing with validation and custom auditing. I'm unsure how to approach this problem. It seems that I will most likely need some sort of factory bean to create a dynamic instance of my interface. I can then use just indexes ordered by bean name (we use the naming convention v1, v2 etc) to determine which index to read from. Using our method naming conventions I can easily delegate writes to all and use the index for other operations. Are there any examples or code in the core that is similar to my requirements so I have some guidance on where to start?
(perform writes to both)
Service -> PointDaoProxy.write* -> PointDaoV1
(perform reads from configured index)
Service -> PointDaoProxy.* -> PointDaoV[configured index]
Any help would be greatly appreciated.
Thanks in advance,