Reputation: 29
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.
Upvotes: 3
Views: 685
Reputation: 42926
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;
}
Upvotes: 1