Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 652692009E8 for ; Mon, 30 May 2016 15:22:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 638C9160A19; Mon, 30 May 2016 13:22:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AB212160A16 for ; Mon, 30 May 2016 15:22:03 +0200 (CEST) Received: (qmail 65492 invoked by uid 500); 30 May 2016 13:22:02 -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 65445 invoked by uid 99); 30 May 2016 13:22:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 May 2016 13:22:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 103F4C0D9E for ; Mon, 30 May 2016 13:22:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.299 X-Spam-Level: X-Spam-Status: No, score=0.299 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id l8QLD9SabGzX for ; Mon, 30 May 2016 13:22:00 +0000 (UTC) Received: from mail-03.1984.is (mail-03.1984.is [93.95.224.70]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 96E185F3A0 for ; Mon, 30 May 2016 13:21:59 +0000 (UTC) Received: from localhost by mail-03.1984.is with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.84) (envelope-from ) id 1b7N8i-0004TB-EE for user@cayenne.apache.org; Mon, 30 May 2016 13:21:52 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: Dynamically reloading the model on change From: Hugi Thordarson In-Reply-To: <24546E5A-B339-4C8E-99C6-7E6F223148CB@objectstyle.org> Date: Mon, 30 May 2016 13:21:45 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <39634F75-DDA4-4F2B-9A8C-96141C7AA011@karlmenn.is> <02613541-E9F6-4AFE-9E67-754A548D84BE@objectstyle.org> <5954B38C-D8AD-407F-8F62-24B8A661FE6B@karlmenn.is> <01F17D00-DBCD-4A77-9534-A6090B7AE938@objectstyle.org> <85C8D86B-3F2F-4F7A-807A-5A843911FE5C@karlmenn.is> <24546E5A-B339-4C8E-99C6-7E6F223148CB@objectstyle.org> To: user@cayenne.apache.org X-Mailer: Apple Mail (2.3124) archived-at: Mon, 30 May 2016 13:22:04 -0000 Initial testing seems to indicate that this works like a charm. 1) Include the JRbel SDK as a dependency in your project org.zeroturnaround javarebel-sdk 2.0.2 2) Add the following class to your project and invoke it's register() = method at application startup time (of course you=E2=80=99ll have to = adapt the class to your own environment) https://gist.github.com/hugith/4d6ae65783ddb7dcd6f1aa7e4a79bc6c Voila=E2=80=94instant reloading of Cayenne models. - hugi > On 30. ma=C3=AD 2016, at 12:52, Andrus Adamchik = wrote: >=20 > Please share the recipe if it works. >=20 > A. >=20 >> On May 30, 2016, at 3:51 PM, Hugi Thordarson = wrote: >>=20 >> In my case it=E2=80=99s a singleton, created by me and lazily = initialized=E2=80=94so I should only need to set that variable to null = on a model change event. Experimenting with this now. >>=20 >> - hugi >>=20 >>=20 >>=20 >>> On 30. ma=C3=AD 2016, at 12:48, Andrus Adamchik = wrote: >>>=20 >>> In a typical app ServerRuntime is a singleton controlled by your = code. You are probably creating it explicitly in your app somewhere on = startup. Or are you relying on CayenneFilter to bootstrap Cayenne? (in = which case runtime is accessible via WebUtil.getCayenneRuntime(..)). >>>=20 >>> Andrus >>>=20 >>>> On May 30, 2016, at 3:44 PM, Hugi Thordarson = wrote: >>>>=20 >>>> I currently use JRebel for class reloading when developing WO. It = has a relatively simple plugin API that can be used to watch changes to = Cayenne project files and trigger stuff on file/class modification. It = could replace the ServerRuntime instance, but it would need some way to = know what ServerRuntime instances to replace with a new instance. This = could be specified in a configuration file=E2=80=94or is there some way = for me to retrieve all ServerRuntime instances related to the modified = entities? >>>>=20 >>>> - hugi >>>>=20 >>>>=20 >>>>=20 >>>>> On 30. ma=C3=AD 2016, at 12:31, Andrus Adamchik = wrote: >>>>>=20 >>>>> Doable in theory - just create a new runtime every time you detect = a change. The bigger question is how practical this is, considering you = also need to reload Java classes. I guess also doable if you run in = debug mode that does class reloading. >>>>>=20 >>>>> Andrus >>>>>=20 >>>>>> On May 30, 2016, at 3:27 PM, Hugi Thordarson = wrote: >>>>>>=20 >>>>>> Hi all, >>>>>> I=E2=80=99ve been working with Ebean for the past couple of = months (customer unfortunately mandated the use of Ebean). I don=E2=80=99t= really like working with it, but it has one feature that I really = like=E2=80=94I can change model classes at will (add attributes, = relationships etc.) and the changes take effect immediately, i.e. I = don=E2=80=99t need to restart the application. >>>>>>=20 >>>>>> Is it possible to do something similes in Cayenne? I.e., can I = make changes to the model and then reload the runtime, or something of = the ilk? >>>>>>=20 >>>>>> Cheers, >>>>>> - hugi >>>>>=20 >>>>=20 >>>=20 >>=20 >=20