private void connectToProfileService() {
if (this.connection != null) {
return;
}
// TODO: Check for a defunct connection and if found try to reconnect?
ProfileServiceConnectionProvider connectionProvider;
if (runningEmbedded()) {
connectionProvider = new LocalProfileServiceConnectionProvider();
} else {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
String namingURL = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.NAMING_URL,
null);
validateNamingURL(namingURL);
String principal = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.PRINCIPAL,
null);
String credentials = pluginConfig.getSimpleValue(
ApplicationServerPluginConfigurationProperties.CREDENTIALS, null);
connectionProvider = new RemoteProfileServiceConnectionProvider(namingURL, principal, credentials);
}
if (Thread.interrupted()) {
// In case we've been timed out by the component facet invoker, clear the interrupted status,
// so that when the below call to connect() tried to make a remote call, JBoss Remoting
// doesn't throw an InterruptedException and short circuit our attempts to reconnect.
log.debug("Ignoring facet timeout in order to reconnect to Profile Service.");
}
try {
this.connection = connectionProvider.connect();
} catch (RuntimeException e) {
Throwable rootCause = ExceptionUtils.getRootCause(e);
rootCause = rootCause == null ? e : rootCause;
if (rootCause instanceof SecurityException) {
if (log.isDebugEnabled()) {