Search code examples
javamaven-2antjakarta-eembeans

How could I get an .ear's filesize at runtime?


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?


Solution

  • 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.