Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D7C5910A88 for ; Fri, 28 Aug 2015 07:17:08 +0000 (UTC) Received: (qmail 79225 invoked by uid 500); 28 Aug 2015 07:17:08 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 79196 invoked by uid 500); 28 Aug 2015 07:17:08 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 79185 invoked by uid 99); 28 Aug 2015 07:17:08 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Aug 2015 07:17:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id F300618222E for ; Fri, 28 Aug 2015 07:17:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.001 X-Spam-Level: **** X-Spam-Status: No, score=4.001 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id mF0jCA7EI9vC for ; Fri, 28 Aug 2015 07:16:56 +0000 (UTC) Received: from mail-03.1984.is (mail-03.1984.is [93.95.224.70]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id D5F6D21277 for ; Fri, 28 Aug 2015 07:16:55 +0000 (UTC) Received: from localhost by mail-03.1984.is with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.84) (envelope-from ) id 1ZVDu4-0003p3-Bz for user@cayenne.apache.org; Fri, 28 Aug 2015 07:16:48 +0000 From: Hugi Thordarson Content-Type: multipart/alternative; boundary="Apple-Mail=_FB2ED9A7-E571-40BE-B4E2-289144DF4D37" Message-Id: <58614420-97DA-4C29-8E8F-87150BB67085@karlmenn.is> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: Getting the currently active ServerRuntime Date: Fri, 28 Aug 2015 07:16:47 +0000 References: <5013630B-823F-4EA4-802C-CA7792DB103A@karlmenn.is> <55DECDE4.5040501@maniatis.org> <2A6FB45E-97DC-4D7B-AD00-3AB641869A22@karlmenn.is> <3322C225-C965-4A66-AA5B-5498D6FB791E@karlmenn.is> <87FC8F2F-A541-47EE-8153-2F69F2885F64@objectstyle.org> To: user@cayenne.apache.org In-Reply-To: <87FC8F2F-A541-47EE-8153-2F69F2885F64@objectstyle.org> X-Mailer: Apple Mail (2.2102) --Apple-Mail=_FB2ED9A7-E571-40BE-B4E2-289144DF4D37 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 That=E2=80=99s great, thanks! - hugi // Hugi Thordarson // http://www.loftfar.is/ // s. 895-6688 > On 27. =C3=A1g=C3=BA. 2015, at 18:04, Andrus Adamchik = wrote: >=20 > You can add it to a List of project locations inside your Module = 'configure': >=20 > public void configure(Binder binder) { > = binder.bindList(Constants.SERVER_PROJECT_LOCATIONS_LIST).add("cayenne-xyz.= xml"); > } >=20 > Or explicitly pass it to ServerRuntime, when you are creating it.=20 >=20 > Though the first approach provides better encapsulation of your = framework. >=20 > Andrus >=20 >=20 >> On Aug 27, 2015, at 6:45 PM, Hugi Thordarson = wrote: >>=20 >> That=E2=80=99s pretty awesome. One question though, how do I tell the = Module about the location of it's Cayenne Model? (like I do with the = configurationLocation parameter in ServerRuntime) >>=20 >> Thanks! >> - hugi >>=20 >>=20 >>=20 >>> On 27. =C3=A1g=C3=BA. 2015, at 10:44, Andrus Adamchik = wrote: >>>=20 >>> Hi Hugi, >>>=20 >>> 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. >>>=20 >>> 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: >>>=20 >>> // this comes from your framework. The module can define a class = that decla >>> public class MyModule implements Module { >>> public void configure(Binder binder) { >>>=20 >>> // MyFrameworkImpl may inject ObjectContextFactory to obtain = contexts >>> binder.bind(MyFramework.class).to(MyFrameworkImpl.class); >>> } >>> } >>>=20 >>> // this is how you bootstrap both Cayenne and your framework in your = app >>> MyModule m =3D new MyModule(); >>> ServerRuntime runtime =3D new ServerRuntime("myproject.xml", m); >>>=20 >>> MyFramework f =3D = runtime.getInjector().getInstance(MyFramework.class); >>> // now you can call methods on f. >>>=20 >>>=20 >>> Andrus >>>=20 >>>=20 >>>> On Aug 27, 2015, at 11:54 AM, Hugi Thordarson = wrote: >>>>=20 >>>>> On 27/08/2015 6:37pm, Hugi Thordarson wrote: >>>>>> I=E2=80=99m writing a Cayenne-based CRUD framework of sorts, in = the form of a jar that plugs into Cayenne applications.=20 >>>>>=20 >>>>> Is there overlap with this: http://nhl.github.io/link-rest/ which = was already built over the top of Cayenne? >>>>=20 >>>> Not really, what we're doing works at a little lower level and = serves more specific requirements. Framework looks nice though=E2=80=94and= it=E2=80=99s fun to see Cayenne in the wild. >>>>=20 >>>> - hugi >>>=20 >>=20 >=20 --Apple-Mail=_FB2ED9A7-E571-40BE-B4E2-289144DF4D37--