mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +02:00
Bug 499696 - add synchronization to service maps
Change-Id: I64775d4976c96a20bee934cf024064ef18896be9 Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
707299e380
commit
a50bad7272
1 changed files with 58 additions and 42 deletions
|
@ -149,6 +149,7 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
*/
|
||||
@Override
|
||||
public <T extends Service> T getService(Class<T> service) {
|
||||
synchronized (serviceDefinitionMap) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T obj = (T) serviceMap.get(service);
|
||||
if (obj == null) {
|
||||
|
@ -167,11 +168,14 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getServices() {
|
||||
synchronized (serviceDefinitionMap) {
|
||||
return new ArrayList<>(serviceDefinitionMap.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -180,8 +184,10 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
*/
|
||||
@Override
|
||||
public <T extends Service> boolean hasService(Class<T> service) {
|
||||
synchronized (serviceDefinitionMap) {
|
||||
return serviceDefinitionMap.get(service.getName()) != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the connection to get a service object for that connection.
|
||||
|
@ -194,6 +200,7 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
* @throws CoreException
|
||||
*/
|
||||
public <T extends IRemoteConnection.Service> T getConnectionService(IRemoteConnection connection, Class<T> service) {
|
||||
synchronized (connectionServiceDefinitionMap) {
|
||||
IConfigurationElement ce = connectionServiceDefinitionMap.get(service.getName());
|
||||
if (ce != null) {
|
||||
try {
|
||||
|
@ -206,14 +213,16 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
RemoteCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getConnectionServices() {
|
||||
synchronized (connectionServiceDefinitionMap) {
|
||||
return new ArrayList<>(connectionServiceDefinitionMap.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -222,8 +231,10 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
*/
|
||||
@Override
|
||||
public <T extends IRemoteConnection.Service> boolean hasConnectionService(Class<T> service) {
|
||||
synchronized (connectionServiceDefinitionMap) {
|
||||
return connectionServiceDefinitionMap.get(service.getName()) != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the remote process to get a service object for that process.
|
||||
|
@ -236,6 +247,7 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
* @throws CoreException
|
||||
*/
|
||||
public <T extends IRemoteProcess.Service> T getProcessService(IRemoteProcess process, Class<T> service) {
|
||||
synchronized (processServiceDefinitionMap) {
|
||||
IConfigurationElement ce = processServiceDefinitionMap.get(service.getName());
|
||||
if (ce != null) {
|
||||
try {
|
||||
|
@ -247,14 +259,16 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
RemoteCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getProcessServices() {
|
||||
synchronized (processServiceDefinitionMap) {
|
||||
return new ArrayList<>(processServiceDefinitionMap.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -263,8 +277,10 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
*/
|
||||
@Override
|
||||
public <T extends IRemoteProcess.Service> boolean hasProcessService(Class<T> service) {
|
||||
synchronized (processServiceDefinitionMap) {
|
||||
return processServiceDefinitionMap.get(service.getName()) != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the remote service manager to register a service extension for
|
||||
|
@ -301,7 +317,7 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
}
|
||||
|
||||
/**
|
||||
* Signal a connnection is about to be removed.
|
||||
* Signal a connection is about to be removed.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue