tags:

views:

36

answers:

2

As I understand it, JBoss* monitors a variety of file types in /deploy and performs certain actions when the file changes. For example, JBoss will redeploy an EAR when its last-modified time changes.

Therefore, I could use some really nasty code to make an EAR redeploy itself, like this:

URL url = this.getClass().getClassLoader().getResource("../RavenWeb.ear");
String path = url.getPath();

File ear = new File(path);
ear.setLastModified(System.currentTimeMillis());

But what I really want to do is just have JBoss redeploy the webapp when an external config file changes. Say the config file lives at C:/foo/bar.properties.

Is there an MBean or some other way getting this done that won't get me mauled by velociraptors?


*I'm using JBoss 5.1.0, if it matters.

A: 

I think your best shot is having a MBean that will reload your config file whenever you call a function on it. If you wan't this to happen automatically, you can also consider having a MBean handling the configuration file for you. This way, you can just update MBean properties instead of changing a configuration file.

Pablo Santa Cruz
Reloading the config file isn't an issue. My application can easily monitor the file itself, but I'm hoping to delegate the responsibility, not to mention the bad taste I get in my mouth from having the application essentially managing its own life cycle.
Matt Ball
A: 

I've copied the Log4JService implementation and put it in a .sar.

It just simply polls the configuration file, parse it and put a Configuration object in the JNDI, so that I can retrieve it in my application. In this way you don't have to redeploy the entire application, and you can use the new configuration in the app.

If you have to do something else than simply reloading the app, you can do it in this service.

volothamp