// to read this file to get the port.
// If port/host are available in the optionsList, then getPassword() will
// get the admin password from .asadminpass file.
private void getPortAndHost(final AgentConfig ac)
{
final EEFileLayout efl = new EEFileLayout(ac);
try {
final File xmlFile = efl.getDomainConfigFile();
if (xmlFile.exists()) {
final ConfigContext cc = ConfigFactory.createConfigContext(xmlFile.getAbsolutePath());
//get port from HttpListener in domain.xml
final HttpListener admin = ServerHelper.getHttpListener(cc,
SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME,
ServerHelper.ADMIN_HTTP_LISTNER_ID);
if (admin != null) {
final String port = admin.getPort();
//set port and host options so that password can be retrieved from .asadminpass
setOption("port", port);
}
}
}
catch (Exception e) {
//Ignore the exception
//if there are any issues with reading the port then the port specified in
// asadminenv.conf will be used.
}
try {
//get the host from das.properties
final File dasProperties = new File(efl.getConfigRoot(), DAS_PROPERTY_FILE_NAME);
if (dasProperties.exists()) {
final Properties prop = new Properties();
prop.load(new BufferedInputStream(new FileInputStream(dasProperties)));
final String host = prop.getProperty(AgentConfig.K_DAS_HOST);
setOption("host", host);