Looks pretty interesting, Hugi.
So, to keep the conversation going (hopefully), one of the things I love
about Tapestry 5 is that it does live class reloading of T5 parts (pages,
components, services, mixins) without needing JRebel. Makes the
environment much more responsive during the development cycle. Anyone have
any idea how much effort it would be for Cayenne to adopt this as well?
Pay attention to ...model and ...model.auto packages for .class changes.
This should only happen during "development" mode. I could potentially see
the need to pick up changes to the model-only, too. For example, if you
make an attribute mandatory or change a varchar(200) to varchar(220), etc.
This wouldn't require class generation, but the model needs to be re-loaded.
On Mon, May 30, 2016 at 9:21 AM, Hugi Thordarson wrote:
Initial testing seems to indicate that this works like a charm.
1) Include the JRbel SDK as a dependency in your project
2) Add the following class to your project and invoke it's register()
method at application startup time (of course you’ll have to adapt the
class to your own environment)https://gist.github.com/hugith/4d6ae65783ddb7dcd6f1aa7e4a79bc6c
Voila—instant reloading of Cayenne models.
On 30. maí 2016, at 12:52, Andrus Adamchik wrote:
Please share the recipe if it works.
On May 30, 2016, at 3:51 PM, Hugi Thordarson wrote:
In my case it’s a singleton, created by me and lazily initialized—so I
should only need to set that variable to null on a model change event.
Experimenting with this now.
On 30. maí 2016, at 12:48, Andrus Adamchik wrote:
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(..)).
On May 30, 2016, at 3:44 PM, Hugi Thordarson wrote:
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—or is there some way for me to retrieve
all ServerRuntime instances related to the modified entities?
On 30. maí 2016, at 12:31, Andrus Adamchik wrote:
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.
On May 30, 2016, at 3:27 PM, Hugi Thordarson wrote:
I’ve been working with Ebean for the past couple of months
(customer unfortunately mandated the use of Ebean). I don’t really like
working with it, but it has one feature that I really like—I can change
model classes at will (add attributes, relationships etc.) and the changes
take effect immediately, i.e. I don’t need to restart the application.
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?