*
* @param joinPoint
*/
public void setConnectionProxy(JoinPoint joinPoint) {
// connection to-be inspect/adjusted
Connection connection = null;
if (joinPoint.getTarget() instanceof Connection) {
connection = (Connection) joinPoint.getTarget();
} else if (joinPoint.getTarget() instanceof MetadataStubExt) {
MetadataStubExt stub = (MetadataStubExt) joinPoint.getTarget();
connection = stub.getConnection();
} else if (joinPoint.getTarget() instanceof ToolingStubExt) {
ToolingStubExt stub = (ToolingStubExt) joinPoint.getTarget();
connection = stub.getConnection();
} else if (Utils.isNotEmpty(joinPoint.getArgs())) {
Object[] objects = joinPoint.getArgs();
for (Object object : objects) {
if (object instanceof IProject && connectionFactory != null) {
try {
connection = connectionFactory.getConnection((IProject) object);
} catch (Exception e) {
logger.warn("Unable to get connection for project");
}
break;
}
}
} else {
logger.warn("Unable to set proxy settings - could not get Connection from joinpoint");
return;
}
if (connection == null) {
logger.warn("Unable to set proxy settings - could not get Connection from joinpoint");
return;
}
// current proxy settings
IProxy proxy = preferenceManager.getProxyManager().getProxy();
// connection to-be inspect/adjusted
// evaluate server root for exclusion
String endpoint = connection.getServerName();
if (Utils.isEmpty(endpoint)) {
endpoint = connection.getForceProject().getEndpointServer();
}
if (proxy.isProxiesEnabled() && !proxy.isServerExcluded(endpoint)) {
// update w/ last proxy settings
updateConnectionProxy(connection, proxy);
} else {
// proxy is disabled, clear jvm-wide settings
connection.getConnectorConfig().setProxy(Proxy.NO_PROXY);
//clearConnectionProxySettings(connection);
}
}