是否有类似Tomcat的类加载器可以单独使用? [英] Is there a Tomcat-like classloader that can be used standalone?

查看:284
本文介绍了是否有类似Tomcat的类加载器可以单独使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java应用程序服务器(Smartfox),它可以运行多个应用程序(扩展),但是它有一个非常不方便的类路径设置,以及它在尝试使用时的问题SLF4J。

I'm working with a Java sort-of-application-server (Smartfox) which can run multiple applications ("extensions") but has a very inconvenient classpath setup to go along with it, along with issues when trying to use SLF4J.

为了解决这个问题,我想将我的应用程序包装在他们自己的类加载器中。这样的包含类加载器应该与Tomcat类似,因为它

To work around that I'd like to wrap my applications in their own classloaders. Such a containing classloader should be much like Tomcat's, in that it


  • 可以从包含JAR的目录中加载类。

  • 喜欢自己的类路径中的类而不是来自父类的类

是否有某个库有这样的类加载器我可以在我的项目中拖放吗?如果没有,自己创建它会难吗?任何已知的陷阱?

Is there a library somewhere that has such a classloader I can just "drag and drop" in my project? If not, would it be hard to create it myself? Any known pitfalls?

推荐答案

OSGi (和其他模块系统)旨在处理完全这类问题。

OSGi (and other module systems) are designed to handle exactly this kind of problem.

它可能看起来起初就像是矫枉过正,但我​​认为你会很快重新实现OSGi为你做的事情的重要部分。

It might look like overkill at first, but I think you'll quickly re-implement significant parts of the things that OSGi alread does for you.

Equinox 是Eclipse使用的OSGi实现。例如。

Equinox is the OSGi implementation used by Eclipse, for example.

这篇关于是否有类似Tomcat的类加载器可以单独使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆