views:

210

answers:

4

I want to reload just my web layer classes without reloading my service layer classes (which take longer to initialize and change less frequently). There are no references from my service layer into the web layer and I can create a whole new instance of the web layer without problems.

I can conceive of a solution involving complicated class-loader tricks to isolate the web layer in its own class-loader and I think this is probably the only way to do this so what I'm asking is, is there a library out there which does this?

I know about JavaRebel - I don't need that much power and I'm really looking for a more lightweight free solution.

A: 

Not sure this will solve your problem, but if you can instantiate a whole instance of web layer easily , maybe you can create a method that does that called reloadWebLayer(), for example. Then add a button to an admin page that calls reoladWebLayer() when clicked?

If you need it to reload automatically, you could set a timer and call reloadWebLayer() every x seconds, or maybe you could write a file listener that runs reloadWebLayer() whenever a file on the classpath changes?

Dave Paroulek
This will not reload the classes themselves though, which is really what I want.
Ramon
+3  A: 

If your web layer is separated from the service layer would it be possible for you to deploy them as to separate applications? Then the web app could be reloaded as often as necessary.

In case the reason for reloading of the webapp is changes in configuration, then move properties etc away from WEB-INF-folder (as they normally are not reloaded/reloadable). Ideas for handling reloadable configs etc can be found in Spring and FreeMarker

Kennet
How would the web layer reference the service layer objects if they're in a different application?
Ramon
Well, if they are truly separated, you could use sockets, webservices, REST... instead of direct reference within the same application.
Kennet
+1  A: 

I think you will end up wasting more time developing the feature than actually developing the webapp. Just life with it, that's where you're paid for. I can imagine that this may be frustating for PHP-originated developers who used to F5/refresh on every new line of code... However, it also depends on appserver you're using. Most just supports hotdeploys. Ensure that yours is configured to do so as well, usually the IDE should already take care over this (at least, mine does: Eclipse + Tomcat6 or Glassfish3).

It may also depend on the appserver in question whether hotdeploys are fast and/or succesful. I've experienced that Glassfish -although it's a slow starter- is extremely fast in hotdeploys. I like it. Tomcat is a bit slower in this and also not always succesful (e.g. old stuff/garbage still in memory and so on).

BalusC
If I wait 10 seconds for my webapp to reload and I reload it 3 times an hour for 8 hours a day over a working month thats 10 * 3 * 8 * 20 = 4800 seconds = 1 hour 20 min of my time every month. I work with 5 other developers, thats 80 man-hours a year for my one small company. These things add up.
Ramon
With other words, you aren't using hotdeploys and/or Glassfish? BTW: I honestly don't think that you get such thing developed and rock solid robust in 80 hours ;)
BalusC
Hot deploys still require the service layer to re-initialize itself - its *that* I'm trying to avoid so any webapp reloading is exactly what I'm trying to avoid - hot or not.
Ramon