I'm working with an application that needs to know if its running on WAS or its running on Liberty Profile.
On WAS, it has to make a call to an Admin API but on Liberty Profile it has to use JNDI to do the same thing.
One way that an application can tell if it's running on Liberty is to search for the following MBean: WebSphere:name=com.ibm.ws.config.mbeans.FeatureListMBean
Here is a list of all MBeans provided in Liberty
Here is a code example of how you might query for the 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With