Monday, November 06, 2006

You can alias beans !

That sounds like a a crazy statement to any normal person not familiar with Java, or at least to my coworkers, as normal as they are. I discovered several days ago that you can assign aliases to beans in the Spring framework for J2EE, and at the time I wondered why you'd ever want to do that. I now realize why: say you have a datasource that you share among numerous aspects of your system: transactions, reports, other stuff (but most importantly the first two.) Now say that your database is growing along with your customer base and it's getting way too (computationally) expensive to run reports on your production database. Just point your report bean aliases to a new data source bean after setting up a DB replication of your main database that gets updated every night, or every few hours. Then you've effectively switched your system over to a load balanced method without changing any of your production code. Genius!

No comments: