I have a few Restful web services made in Apache CXF. I'm using the non-spring version of the CXFServlet. The logs for my web services go into a mongo database. Right now my web services are configured in such a way that everytime my web services are called, a new connection is created to connect the db. I want to configure the Mongo Client object in the application scope. So i get only one connection object shared between multiple web services. I looked at the Apache CXF docs but could'nt get most of it. I had stumbled upon this question about creating singleton objects, I don't know if that's true for my case. So I need a way to configure my logger as global object for the whole application.
If there's a similar question already asked please give me a link to that
Asked
Active
Viewed 177 times
0

Community
- 1
- 1

Aditya Cherla
- 27
- 12
-
Don't use singletons! If you need to have a global object, use a global object. Just make absolutely sure that you actually need a global object. – thecoshman Jun 30 '14 at 08:18
-
@thecoshman: yes i need a global object, but why should'nt i use singletons? – Aditya Cherla Jun 30 '14 at 08:23
-
Your problem is that you need a global object to access the DB. So make a single global object to access the DB. – thecoshman Jun 30 '14 at 08:26
-
OK, but how should i configure the global object in the cxf? – Aditya Cherla Jun 30 '14 at 08:30
-
I don't know, I don't use cxf. – thecoshman Jun 30 '14 at 08:38
-
Finally did this by creating a separate Listener for the CXFServlet and added the Required Object in the ServletContext. – Aditya Cherla Jul 08 '14 at 11:12