如何在运行时获取 .ear 文件大小?
我开始尝试通过 Length ant 任务来完成此操作,但意识到这将在包装耳朵之前完成。包装耳朵,然后检查文件大小,然后将其放入耳朵中,就会影响耳朵的大小。
有没有办法在运行时以编程方式获取耳朵的大小?或者也许是一个具有该信息的 MBean?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这确实是 J2EE 禁忌,但这里有一个可能的解决方案。
创建一个具有自动启动功能的 Servlet,它从文件系统读取并获取您需要的信息。
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.
这取决于您的 .ear 在部署之前是否已解压。 WebSphere 有一个“installableapps”文件夹,其中包含 .ear 文件,并且是部署向导可见的默认文件夹。它有另一个文件夹“installedapps”(-ed 而不是 -able),其中包含扩展的 .ear 文件,并且 JVM 进程甚至无权查看“installableapps”文件夹。如果这就是您的 J2EE 容器的工作方式,那么您正在运行的代码将没有任何方法来检查 .ear 的文件大小。
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.