简体   繁体   中英

Singleton with jetty webapps

I want to inject object that has 12mb into my jetty webapp. I deploy my app as WAR file so I cannot add guice injector as it is shown in other question.

How to do it? I quess I need to use applicationContext.xml

Use the ServletContext.setAttribute(String,Object) to store your object.

Then use ServletContext.getAttribute(String) to access that singleton from your Servlets and Filters.

Make sure your object is safe to use from multiple threads!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM