code: static AbstractBeanDefinition findServerForSpecialEnvironment() {
          boolean weblogicPresent = ClassUtils.isPresent("weblogic.management.Helper",
                  ServletContextAwareMBeanServerDefinitionParser.class.getClassLoader());
  
          boolean webspherePresent = ClassUtils.isPresent("com.ibm.websphere.management.AdminServiceFactory",
                  ServletContextAwareMBeanServerDefinitionParser.class.getClassLoader());
  
          if (weblogicPresent) {
              RootBeanDefinition bd = new RootBeanDefinition(JndiObjectFactoryBean.class);
              bd.getPropertyValues().add("jndiName", "java:comp/env/jmx/runtime");
              return bd;
          } else if (webspherePresent) {
              return new RootBeanDefinition(WebSphereMBeanServerFactoryBean.class);
          } else {
              return null;
          }
      }
docs: Logic taken from
  <code>org.springframework.context.config.MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment()</code>