gpt4 book ai didi

websphere - 应用程序如何判断它是在 IBM WebSphere Application Server 还是 IBM WebSphere Liberty Profile 上运行?

转载 作者:行者123 更新时间:2023-12-02 03:12:02 31 4
gpt4 key购买 nike

我正在处理一个应用程序,它需要知道它是在 WAS 上运行还是在 Liberty Profile 上运行。

在 WAS 上,它必须调用 Admin API,但在 Liberty Profile 上,它必须使用 JNDI 来做同样的事情。

最佳答案

应用程序可以判断它是否在 Liberty 上运行的一种方法是搜索以下 MBean:WebSphere:name=com.ibm.ws.config.mbeans.FeatureListMBean

这是 all MBeans provided in Liberty 的列表

以下是您可能如何查询 MBean 的代码示例:

private boolean isLiberty() throws Exception {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName obn = new ObjectName("WebSphere:name=com.ibm.websphere.config.mbeans.FeatureListMBean");
Set<ObjectInstance> s = mbs.queryMBeans(obn, null);
return s.size() > 0;
}

关于websphere - 应用程序如何判断它是在 IBM WebSphere Application Server 还是 IBM WebSphere Liberty Profile 上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39475482/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com