gpt4 book ai didi

java - 访问 Websphere 变量

转载 作者:搜寻专家 更新时间:2023-11-01 03:26:32 26 4
gpt4 key购买 nike

我想从 java 类中获取 Websphere 变量 ORB_LISTENER_PORT 的值。如何实现?

我已阅读 topik并理解它。我想我必须使用一些值而不是“expandVariable”。但是什么样的值(value)呢?

最佳答案

我自己解决了这个问题。以下代码示例和他的工作结果。

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>");
}
}

函数列表是:

  • BOOTSTRAP_ADDRESS=2809
  • SOAP_CONNECTOR_ADDRESS=8880
  • SAS_SSL_SERVERAUTH_LISTENER_ADDRESS=9401
  • CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS=9403
  • CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS=9402
  • WC_adminhost=9060
  • WC_defaulthost=9080
  • DCS_UNICAST_ADDRESS=9353
  • WC_adminhost_secure=9043
  • WC_defaulthost_secure=9443
  • ORB_LISTENER_ADDRESS=9100
  • SIP_DEFAULTHOST=5060
  • SIP_DEFAULTHOST_SECURE=5061
  • SIB_ENDPOINT_ADDRESS=7276
  • SIB_ENDPOINT_SECURE_ADDRESS=7286
  • SIB_MQ_ENDPOINT_ADDRESS=5558
  • SIB_MQ_ENDPOINT_SECURE_ADDRESS=5578
  • IPC_CONNECTOR_ADDRESS=9633
  • OVERLAY_UDP_LISTENER_ADDRESS=11003
  • OVERLAY_TCP_LISTENER_ADDRESS=11004

关于java - 访问 Websphere 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12603461/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com