使用 WebLogic 获取当前 EAR 路径

发布于 2024-10-19 16:14:48 字数 93 浏览 9 评论 0原文

在我的源代码中,我希望以编程方式获取部署代码的当前 EAR 的最后修改日期。 我正在使用 Oracle WebLogic。 我怎么能这么做呢?

谢谢你的回答

In my source code, I'd like to get programmatically, the last modified date of the current EAR from which my code is deployed.
I'm using Oracle WebLogic.
How could I do that?

Thx for your answers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简美 2024-10-26 16:14:48

我建议退后一步,看看你想要解决的问题,埃里克。

您想知道应用程序的构建时间或您部署的应用程序的特定版本吗?如果是这种情况,最好的方法可能是在构建过程中加入一些东西来设置它。理想情况下,用于打包应用程序的特定组件版本的清单。

如果您想知道管理员首次部署应用程序的时间,或者最近部署的时间,那就更棘手了。依靠文件系统来解决这个问题是一个坏主意,因为您受到 WebLogic Server 所做的任何事情的支配,这无疑有点不透明。

如果您绝对需要这样做,WebLogic Server 的标准暂存行为会将文件的一个版本放入每个服务器实例上的特定子目录中,然后快速将其分开。 (它是域根目录 ($DOMAIN_HOME) 下的“servers//stage”子目录,$DOMAIN_HOME 是运行时所有服务器进程的当前目录,因此相对路径应该可以正常工作。

应该 为您提供该文件在网络上部署的时间,但您肯定希望通过重新启动服务器实例来测试观察到的行为,

问题是它不会为您提供任何您无法更优雅地确定的内容。通过构建过程或围绕部署过程的 WLST 脚本

如果这是应用程序本身的最后一次部署(无论版本如何),那么应用程序生命周期事件侦听器绝对是最好的方法,不幸的是没有 MBean 可以为您提供。单个应用程序的正常运行时间

在这里有一个关于生命周期侦听器的很好的参考:

http://download.oracle.com/docs/cd/E17904_01/web.1111/e13712/app_events.htm#i178290

I'd suggest stepping back and looking at the problem you're trying to solve, Eric.

Do you want to know when the application was built or the particular version of the application you've got deployed? If that's the case, you're probably best served by incorporating something into the build process to set this. Ideally a manifest of the specific component versions used to package up your application.

If you want to know when the application was first deployed by an administrator, or most recently deployed that gets more tricky. Relying on the filesystem to solve this problem is a bad idea because you're at the mercy of whatever WebLogic Server is doing, which is admittedly more than a bit opaque.

If you absolutely need to do this, WebLogic Server's standard staging behaviour puts a version of the file in a particular subdirectory on each server instance, then very quickly pulls it apart. (it's the 'servers//stage' subdirectory underneath the root directory of the domain ($DOMAIN_HOME) $DOMAIN_HOME is the current directory for all server processes at runtime, so the relative path should work fine.

That should give you the time that file was deployed across the network, but you'd definitely want to test the observed behaviour from rebooting your server instance.

The problem with that is that it doesn't give you anything you couldn't determine more elegantly via either the build process, or WLST scripting around the deployment process.

If it's the last time the application itself was deployed (regardless of the version) then application lifecycle event listeners are definitely the best way to go. Unfortunately there's no MBean that gives you the uptime of an individual application.

There's a great reference on lifecycle listeners here:

http://download.oracle.com/docs/cd/E17904_01/web.1111/e13712/app_events.htm#i178290

捂风挽笑 2024-10-26 16:14:48

您可以检查文件属性或查看 EAR 内的 MANIFEST.MF。

You could either check the file properties or see inside the MANIFEST.MF present inside the EAR.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文