是否可以在不修改/重新部署 WAR 的情况下向已部署的 WAR 添加依赖项
我们有一个向用户显示表单的应用程序 XYZ。我们希望分发此应用程序,并允许外部开发人员创建自己的表单(扩展应用程序 XYZ 提供的接口),并以应用程序 XYZ 无需自行修改即可显示它们的方式部署这些表单。应用程序 XYZ 通过查找列出所有可用表单类的配置文件来了解它可以显示哪些表单(然后以反射方式实例化这些表单类)。
我们使用 Weblogic 10.3 作为应用程序服务器,该应用程序是 GWT / Java 应用程序。
据我所知,我所描述的场景是不可能的,因为应用程序 XYZ 需要重新编译和重新部署,并将新的依赖项添加到类路径中。我希望有人能告诉我另外的情况。
We have an application XYZ that displays forms to a user. We would like to distribute this application and allow external develops to create their own forms (extending interfaces provided by application XYZ) and deploy those forms in a way that application XYZ can display them without having to be modified itself. Application XYZ knows which forms it can display by looking up a config file which lists all of the form classes available (these are then instantiated reflectively).
We are using Weblogic 10.3 as the application server and the application is a GWT / Java app.
As far as I'm aware the scenario I've described would not be possible as application XYZ will need to be recompiled and redeployed with the new dependency added to the classpath. I am hoping that someone can tell me otherwise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Servlet 规范规定每个 WAR 文件都部署在它自己的隔离类加载器上。这可以隔离在同一 servlet 容器实例上运行的多个 Web 应用程序。
tomcat 文档 描述了各种类之间的关系装载机非常好。 (考虑到 Tomcat 是 servlet 的参考实现,Weblogic 应该以类似的方式执行)
因此,重新编译 WAR 的另一种方法是将这些额外的自定义 jar 放入“$CATALINA_BASE/lib”目录(或 Weblogic 的等效目录)中。
不过,我发现有几个需要注意的实现问题:
界面。这将使用户能够替换运行时实现
那些课程。
您的应用程序的实例。这可能会排除在同一应用程序服务器实例上运行旧版本应用程序的可能性。
The Servlet specification states that each WAR file is deployed on it's own isolated class loader. This enables the isolation of multiple web applications, running on the same servlet container instance.
The tomcat documentation describes the relationship of the various class-loaders very well. (Considering Tomcat was the reference implementation for servlets, Weblogic should execute in a similar manner)
So an alternative to recompiling you WAR would be to place these extra custom jars into the "$CATALINA_BASE/lib" directory (or Weblogic's equivolent).
However I see a couple of implementation issues to be aware of:
interface. This would enable users to substitute a run-time implementation of
those classes.
instances of your application. This might rule out running older versions of your app on the same appserver instance.