2016-09-13 4 views
3

저는 WAS에서 실행되는지 또는 Liberty Profile에서 실행 중인지 알아야하는 응용 프로그램과 함께 작업하고 있습니다.애플리케이션이 IBM WebSphere Application Server 또는 IBM WebSphere Liberty Profile에서 실행 중인지 어떻게 알 수 있습니까?

WAS에서 Admin API를 호출해야하지만 Liberty Profile에서는 JNDI를 사용하여 동일한 작업을 수행해야합니다. 여기

WebSphere:name=com.ibm.ws.config.mbeans.FeatureListMBean 여기 all MBeans provided in Liberty

의 목록입니다 당신이 조회하는 방법의 코드 예제 : 그것은 자유에서 실행중인 경우 응용 프로그램이 알 수

답변

1

한 가지 방법은 다음 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; 
} 
+1

유일한 문제는 JMX 스택을 부트 스트랩하여 느려질 수 있다는 것입니다. 또 다른 방법은 MBean 인터페이스 클래스를로드하는 것입니다.이 클래스는 오직 Liberty에만있을 것입니다. – Alasdair

관련 문제