// since initializing with a connection already
isConnectNeeded = false;
jmxFileTrans.setTargetServer(instanceName);
} catch (InstanceException ie) {
throw new SynchronizationException(
_strMgr.getString("synchronization.api.conn_reg_get_failed",
instanceName),ie);
} catch (IOException ioe) {
throw new SynchronizationException(
_strMgr.getString("synchronization.api.jmx_ctor_failed",
instanceName),ioe);
}
} else { // A server connecting to DAS or another server.
String url =null;
String user = IdentityManager.getUser();
if (user == null ) {
String msg =_localStrMgr.getString("ClientUserNotFound",
instanceName);
throw new RuntimeException(msg);
}
String password = IdentityManager.getPassword();
if (password == null) {
String msg =_localStrMgr.getString("PassWordNotFound",
instanceName);
throw new RuntimeException(msg);
}
// connecting to DAS. Using DAS property reader
if ( SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME.compareTo(
instanceName) == 0 ) {
DASPropertyReader dpr = new DASPropertyReader(
new InstanceConfig());
try {
dpr.read();
} catch (IOException ioe) {
String msg = _localStrMgr.getString("DASPropReadNotFound");
throw new SynchronizationException(msg);
}
url = dpr.getJMXURL();
}
else {
try {
ConfigContext cfgCtx = ApplicationServer.getServerContext().
getConfigContext();
assert(cfgCtx != null);
JMXConnectorConfig jmxConfig = ServerHelper.
getJMXConnectorInfo(cfgCtx, instanceName);
if ( jmxConfig == null ) {
String msg = _localStrMgr.getString("JMXInfoNotFound",
instanceName);
throw new RuntimeException(msg);
}
/* Need a better way of handling connector configuration */
final JMXServiceURL theUrl =
JmxServiceUrlFactory.forRmiWithJndiInAppserver(
jmxConfig.getHost(),
Integer.parseInt(jmxConfig.getPort()));
url = theUrl.toString();
} catch (ConfigException ce) {
throw new SynchronizationException(
_strMgr.getString(
"synchronization.api.jmx_config_ctor_failed",
instanceName),ce);
}
}
try {
JMXServiceURL jmxurl = new JMXServiceURL(url);
jmxFileTrans=new JMXFileTransfer(jmxurl, user, password, false);
isConnectNeeded = true;
assert(jmxFileTrans != null);
jmxFileTrans.setTargetServer(instanceName);
} catch (IOException ie) {
throw new SynchronizationException(
_strMgr.getString("synchronization.api.jmx_ctor_failed",
instanceName),ie);
}
}
}