我有一个创建RuntimeFactory
和Application
对象的无状态会话 bean。这两个类都是 Social Business Toolkit 的一部分。Application
用于读取属性和托管 bean 文件,但这并没有发生,因为RuntimeFactory
无法获取Application
对象。
AbstractRuntimeFactory
有一个Map
对象Application
:
private Map<ClassLoader,AbstractApplication> applications = new HashMap<ClassLoader, AbstractApplication>();
ClassLoader
使用此方法设置:
protected ClassLoader getContextClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
使用Application
此方法检索对象:
public Application getApplicationUnchecked() {
ClassLoader cl = getContextClassLoader();
return applications.get(cl);
}
在调试过程中,我注意到 Thread id 保持不变,但是有两个不同的ClassLoader
. 这是怎么发生的?只有一个会话 bean,RuntimeFactory 和 Application。getContextClassLoader() 不应该总是给我同样的对象吗?
当我工作时,我现在使用:
ClassLoader cl = this.getClass().getClassLoader();
哪里this
是RuntimeFactory
,但我不确定这是否是一个好的解决方案.. 感觉更像是解决实际问题的方法。
ps:我使用WebSphere Portal 作为应用服务器。