Global Variables or Singleton or ServletContext or Other?

722 views
Skip to first unread message

Tim Molter

unread,
Mar 31, 2013, 5:17:39 PM3/31/13
to dropwiz...@googlegroups.com
Hi,

Where is the best place for me store and update a global variable that can be updated from several places and be available to all my resources?

When I create a normal Java web app deployed in Tomcat for example, I put these global things in the servlet context. What would be the equivalent in DropWizard? Can I actually access the servlet context of the underlying web app?

Thanks in advance!

~Tim

Coda Hale

unread,
Mar 31, 2013, 5:19:51 PM3/31/13
to dropwiz...@googlegroups.com
Create them as local variables in your service's run method, then pass them to their dependents via their constructors.
--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Coda Hale
http://codahale.com

Tim Molter

unread,
Mar 31, 2013, 5:22:11 PM3/31/13
to dropwiz...@googlegroups.com
Thanks. So easy and obvious now!


On Sunday, March 31, 2013 11:19:51 PM UTC+2, Coda Hale wrote:
Create them as local variables in your service's run method, then pass them to their dependents via their constructors.

On Sunday, March 31, 2013, Tim Molter wrote:
Hi,

Where is the best place for me store and update a global variable that can be updated from several places and be available to all my resources?

When I create a normal Java web app deployed in Tomcat for example, I put these global things in the servlet context. What would be the equivalent in DropWizard? Can I actually access the servlet context of the underlying web app?

Thanks in advance!

~Tim

--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-user+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages