Re: Re: What is best way for ServerResource to get DB connection?

2011-01-02 Thread Tim Peierls
All reasonable advice, but if you're going to be doing this a lot, I highly recommend using a dependency injection framework rather than explicit singletons. I use Guice, but many people have reported great things of Spring. If you need to have your resource injected with dependencies that might b

Re: Re: What is best way for ServerResource to get DB connection?

2011-01-02 Thread Fabian Mandelbaum
You are welcomed Anthony. Here you have some 'general' singleton coding that works 'everywhere' in Java: public class MySingleton { private static class MySingletonHolder { private static final MySingleton INSTANCE = new MySingleton(); } private MySingleton() { // You'll do all ini

RE: Re: What is best way for ServerResource to get DB connection?

2011-01-02 Thread Anthony
Fabian, Being determined to accomplish the task via one of the methods I outlined in original post I completely neglected to consider this approach. I'll give the Singleton a go as time is slipping through my fingers. Thanks Fabian!!! -- http

Re: What is best way for ServerResource to get DB connection?

2011-01-01 Thread Fabian Mandelbaum
Hello Anthony, I use a single(ton) SessionManager of sorts which 'serves' the connections when asked, something like: DBSessionManager.getInstance().getSessionRO(); DBSessionManager.getInstance().getSessionRW(); and of course, the corresponding: DBSessionManager.getInstance().releaseSessionRO(s

What is best way for ServerResource to get DB connection?

2011-01-01 Thread Anthony
I have a class that handles a pool of Oracle DB connections with methods to get and free (return to pool) a connection. This connection pool class will be instantiated in my class that extends org.restlet.Application. My question is how to make a connection availble to a ServerResource. Should