views:

71

answers:

2

I started out attempting to do this with the Length ant task, but realized that that would be done before the ear is packaged. Packaging the ear, then checking the file size, and then placing it in the ear would effect the size of the ear.

Is there a way to get the ear's size programmatically at run-time? Or perhaps an MBean that would have that information?

A: 

It depends on whether your .ear was unpacked before deployment. WebSphere has a 'installableapps' folder which held .ear files and was the default folder visible to the deployment wizard. It has another folder 'installedapps' (-ed instead of -able) which contains expanded .ear files and the JVM processes didn't have permission to even see the 'installableapps' folder. If this is how your J2EE container works than your running code won't have any way to check the .ear's filesize.

Kelly French
A: 

This is really a J2EE No-No but here is a possible solution.
Create a Servlet with AutoStart capabilities that reads from the file system and gets the information that you need.

Romain Hippeau