cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Getting the currently active ServerRuntime
Date Thu, 27 Aug 2015 10:44:49 GMT
Hi Hugi,

Are you using DI by any chance in your app? Cause if you do, it becomes as simple as making
ServerRuntime one of the "services" and injecting it into your framework.

Or maybe you can invert that? Instead of telling the framework about ServerRuntime, you tell
ServerRuntime about your framework (essentially relying on Cayenne to be your DI provider).
To do that you expose your framework as a DI Module. That's our preferred way of loading Cayenne
extensions. Maybe you can use the same approach with your own code:

  // this comes from your framework. The module can define a class that decla
  public class MyModule implements Module {
      public void configure(Binder binder) {

         // MyFrameworkImpl may inject ObjectContextFactory to obtain contexts

  // this is how you bootstrap both Cayenne and your framework in your app
  MyModule m = new MyModule();
  ServerRuntime runtime = new ServerRuntime("myproject.xml", m);

  MyFramework f = runtime.getInjector().getInstance(MyFramework.class);
  // now you can call methods on f.


> On Aug 27, 2015, at 11:54 AM, Hugi Thordarson <> wrote:
>> On 27/08/2015 6:37pm, Hugi Thordarson wrote:
>>> I’m writing a Cayenne-based CRUD framework of sorts, in the form of a jar that
plugs into Cayenne applications. 
>> Is there overlap with this: which was already built
over the top of Cayenne?
> Not really, what we're doing works at a little lower level and serves more specific requirements.
Framework looks nice though—and it’s fun to see Cayenne in the wild.
> - hugi

View raw message