Mar 1st, 2007, 01:23 PM
replacing custom springlike framework
I wrote my own kind of springish framework, and there's one thing it does that I haven't found a way to do in spring. Basically I want to reload a single bean on demand.
My current frameworks works like:
Loader servlet runs first, and creates and loads Engines into the servlet context.
Servlets come along and register the Engines into a Context Bus.
These Engines are executed in order, passing a custom context object between them.
Now at any time, we can reload on demand a particular Engine, such as, say,
the TemplateEngine, which contains templates. We can edit templates, then in a script create a new TemplateSystem which the TemplateEngine loads when it comes alive. Then on the next hit, the Servlets immediately see the new templates, and the old TemplateEngine passes out of existence.
Is there a way to tell Spring "hey, go make me a new TemplateEngine!"?
Mar 1st, 2007, 01:29 PM
Well you can reload an applicationcontext, however that is a total reload. But reloading parts of the context I don't think it is able to do by default.
One solution would be to create a TargetSource which checks to see if it should reload/create a new Engine, create the Engine or return the old instance. Shouldn't be that hard to implement.
Mar 2nd, 2007, 02:59 PM
Thanks for the reply! Yes, refreshing all the beans would definitely not be an option.. In looking at TargetSource i found: http://www.springframework.org/docs/...freshable.html
which looks like it might be interesting... Has anyone worked with it?
Mar 2nd, 2007, 04:06 PM
this isn't what Refreshable does
Oh well, the search continues!
Mar 3rd, 2007, 03:18 AM
Just out of interest, when you say reload an engine what does that really mean? Is this something Spring should actually do, or is this simply the overlap between the two approaches? At this point your code kicks in a does it's magic.
Mar 6th, 2007, 03:49 PM
Engines in my system are a type of module or plugin. I create servlets by configuring a bus of engines. The ones that periodically need refreshing are typically ones that encapsulate some data, such as html templates, or whatever without having to stop and start the server. At the moment i use a home grown loader to load them into the servlet context. If I were going to move to Spring, I'd have to have a way to duplicate this functionality.
Mar 7th, 2007, 11:42 AM
It very much sounds like you want several modules each of which can be refreshed independently. I'm thinking this might sound like OSGi ground.