Yes, normally a Cayenne stack should be shared between all servlets, filters, etc. in a webapp. "Application" scope is provided by javax.servlet.ServletContext per servlet specification.
Bootstrapping ServerRuntime and placing it in the app scope can be done via a variety of ways - Filter.init, Servlet.init, ServletContextListener.contextInitialized. CayenneFilter provided by Cayenne is a good template for how ServerRuntime should be started and stopped: https://github.com/apache/cayenne/blob/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java Andrus On Feb 22, 2012, at 1:12 AM, John Huss wrote: > I'm new to Servlets and containers and all that. If I have multiple > servlets, where is the best place to create and store a reference to the > cayenne ServerRuntime (I'm using 3.1)? One of my servlets is an > ROPHessianServlet and it gets the ServerRuntime information from the > web.xml file. But the others are just regular servlets. I want to avoid > creating a bunch of different runtimes and just have one. > > Thanks, > John
