Hi,

The entry point to Cayenne in 3.1 is ServerRuntime. If you already have 
CayenneFilter elsewhere in the application, it means ServerRuntime is already 
created and can be retrieved by your code outside of HttpRequest:

ServletContext servletContext = // you can get this one during app 
initialization (or maybe Spring can inject it?)
CayenneRuntime runtime = WebUtil.getCayenneRuntime(servletContext);
ObjectContext newContext = runtime.getContext();

Andrus

On Oct 4, 2012, at 9:16 PM, Ramiro Aparicio <ramiro.apari...@prot-on.com> wrote:

> Hi,
> I am back again with some questions, after migrating to 3.1 it seems almost 
> everything is working as it should except timed task, this kind of process is 
> timed using spring and does not pass throught CayenneFilter and there is no 
> context attached, so I need to be able to create context on demand for those 
> cases and that is changed to DI in 3.1 wich is undocummented afaik, I have 
> tried with:
>    @Inject
>    private Injector injector;
> and then:
>            DataContext context = (DataContext) 
> injector.getInstance(ObjectContextFactory.class).createContext();
> but injector is not injected, so right now I am out of options, can someone 
> point me how Cayenne DI is working or how can I create a new context at 3.1?
> 
> Thanks in advance for the help.
> 
> Ramiro Aparicio
> 
> 

Reply via email to