cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <johnth...@gmail.com>
Subject Re: ServerRuntime Best Practice? [3.1]
Date Thu, 28 Feb 2013 15:15:36 GMT
If it's a servlet app, then the runtime is created in CayenneFilter and
bound to the thread for each request and you access it via

WebUtil.getCayenneRuntime(servletContext);


Or you can get a context from the injector if you have bound that to a
thread:

ObjectContext context =
CayenneRuntime.getThreadInjector().getInstance(ObjectContextFactory.class
).createContext();


If not a servlet app, then yeah, I'd just store it in a static variable or
application instance.



On Thu, Feb 28, 2013 at 8:43 AM, Michael Gentry <mgentry@masslight.net>wrote:

> Is there an existing place (class) in 3.1 to stuff a ServerRuntime instance
> for global use or is it expected that you'll create a separate class to
> hold a static instance variable of ServerRuntime?
>
> Thanks,
>
> mrg
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message