防止 Java Applet 类加载器尝试远程检索类

发布于 2024-10-11 20:08:39 字数 353 浏览 2 评论 0 原文

我注意到,当执行 Java Applet 时,类加载器似乎会向 Web 服务器发出大量请求,这些请求本应包含在 Applet 的 jar 文件中,或者没有人需要。类、属性文件、小程序中每个类的 BeanInfo,凡是您能想到的。看起来这实际上是完全有意的,显然应该允许为 jar 中的各个文件提供更新,而不必替换整个 jar - 因此类加载器首先尝试远程检索文件,并且只有在失败时才设计使用它已经有本地副本。

我发现网络服务器不断受到它不得不拒绝的无用请求的打击,这非常烦人和浪费。是否有办法反转默认行为,即告诉类加载器首先使用本地副本,并且只有在本地找不到所需资源时,才尝试远程获取它?是否过于希望我只需要设置某种系统属性,或者我实际上必须编写一个替换类加载器来完成此任务?

I've noticed that when a Java Applet is executed, the classloader seems to be hitting the web server with a literal deluge of requests for stuff that should already be in the applet's jar file, or stuff that nobody needs. Classes, properties files, BeanInfo for each and every class in the applet, you name it. It seems this is actually fully intentional, apparently supposed to allow for providing updates to individual files within the jar without having to replace the entire jar - so the classloader first tries to retrieve the file remotely, and only if that fails it deigns to use the local copy it already has.

I find that highly annoying and wasteful, the web server keeps getting hammered by useless requests it has to deny. Isn't there a way to invert the default behaviour, i.e. to tell the class loader to use the local copy first and only once the desired resource can't be found locally, try to fetch it remotely? Would it be too much to hope for that there might some kind of system property I just have to set, or do I actually have to write a replacement class loader to accomplish this?

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

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

发布评论

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

评论(1

梓梦 2024-10-18 20:08:39

应首先从档案中读取文件。为了抑制应该失败的松散文件查找,有一个选项:

<PARAM name="codebase_lookup" value="false">

http://download.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/special_attributes.html#codebase

Files should be read from the archives first. To suppress loose file lookups that should fail, there is an option for that:

<PARAM name="codebase_lookup" value="false">

http://download.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/special_attributes.html#codebase

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