-
1. Re: DAO without Factory?
spiritualmechanic Apr 17, 2004 3:13 PM (in response to tsagovic)I'd avoid a singleton DAO. You will have to synchronize things, which will slow you down if thread A is already in your singleton.
In general, avoid dealing with your own threads inside of the container. The whole point of J2EE is to let the container-developers figure it out for you.
I personally have used DAOFactory, and not used DAOFactory. If you're really doing some nutty stuff like changing which implementation you want to use on the fly (i.e., changing the value in a file, that is being read-in on a regular basis), you'd prefer writing a little MBean to do that. It'll be cached in memory and can be changed.
But most things don't need to be that dynamic. I definitely wouldn't make a DAOImpl too dynamic. Are you going to switch our databases on the fly? Just curious why you might want to replace DAOImpl.
There *is* a way in JBoss to have your interfaces not change, and change the implementation. Break the two into separate jars. If your implementation changes, just copy over the impl.jar. JBoss will pick it up without blowing away the objects that reference the interfaces.
Steve