4
자바 클래스에서 Websphere 변수 ORB_LISTENER_PORT의 값을 얻고 싶습니다. 어떻게 할 수 있습니까?Websphere 변수에 액세스하기
나는 topik을 읽고 이해했습니다. 나는 "expandVariable"대신에 어떤 값을 사용해야한다고 생각한다. 그러나 어떤 가치가 있습니까?
자바 클래스에서 Websphere 변수 ORB_LISTENER_PORT의 값을 얻고 싶습니다. 어떻게 할 수 있습니까?Websphere 변수에 액세스하기
나는 topik을 읽고 이해했습니다. 나는 "expandVariable"대신에 어떤 값을 사용해야한다고 생각한다. 그러나 어떤 가치가 있습니까?
저는 혼자서 문제를 해결했습니다. 다음 코드 샘플과 그의 작업 결과. 함수
import com.ibm.websphere.management.Session;
import com.ibm.websphere.management.configservice.ConfigService;
import com.ibm.websphere.management.configservice.ConfigServiceFactory;
import com.ibm.websphere.management.configservice.ConfigServiceHelper;
public void readWebsphereConfiguration(PrintWriter out){
try{
out.println("<p>Using ConfigService to get the hostName and port of this server.</p>");
Session session = new Session();
ConfigService cs = ConfigServiceFactory.getConfigService();
ObjectName[] serverIndexONs = cs.resolve(session, "ServerIndex=");
String hostName = (String) cs.getAttribute(session, serverIndexONs[0], "hostName");
out.println("<p>HostName: " + hostName + "</p>");
ObjectName[] namedEndPointsONs = cs.queryConfigObjects(session, serverIndexONs[0], ConfigServiceHelper.createObjectName(null, "NamedEndPoint"), null);
for (int i = 0; i < namedEndPointsONs.length; ++i){
String str = (String) cs.getAttribute(session, namedEndPointsONs[i], "endPointName");
ObjectName[] theEndPoints = cs.queryConfigObjects(session, namedEndPointsONs[i], ConfigServiceHelper.createObjectName(null, "EndPoint"), null);
String szValue = "";
if(theEndPoints != null && theEndPoints.length > 0){
szValue = ((Integer) cs.getAttribute(session, theEndPoints[0], "port")).toString();
}
out.println("<p>" + str + "=" + szValue +"</p>");
}
}catch(Exception e){
out.println("<p>Exception while trying to fetch the hostname and port information.: " + e.getMessage() + "</p>");
out.println("<p>Exception:" + e.getStackTrace() + "</p>");
}
}
목록이다 :
참고 ORB_LISTENER_PORT가 WebSphere 변수가 아 U니다). –