簡體   English   中英

應用程序如何判斷它是否在IBM WebSphere Application Server或IBM WebSphere Liberty Profile上運行?

[英]How can an application tell if its running on IBM WebSphere Application Server or IBM WebSphere Liberty Profile?

我正在使用一個應用程序,需要知道它是在WAS上運行還是在Liberty Profile上運行。

在WAS上,它必須調用Admin API,但在Liberty Profile上它必須使用JNDI來執行相同的操作。

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

以下是Liberty中提供所有MBean的列表

以下是如何查詢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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM