|
|
|
@ -96,8 +96,8 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { |
|
|
|
SessionSubscriptionInfo info = this.subscriptionRegistry.getSubscriptions(sessionId); |
|
|
|
SessionSubscriptionInfo info = this.subscriptionRegistry.getSubscriptions(sessionId); |
|
|
|
if (info != null) { |
|
|
|
if (info != null) { |
|
|
|
String destination = info.removeSubscription(subsId); |
|
|
|
String destination = info.removeSubscription(subsId); |
|
|
|
if (destination != null && info.getSubscriptions(destination) == null) { |
|
|
|
if (destination != null) { |
|
|
|
this.destinationCache.updateAfterRemovedSubscription(destination, sessionId, subsId); |
|
|
|
this.destinationCache.updateAfterRemovedSubscription(sessionId, subsId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -187,54 +187,51 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateAfterRemovedSubscription(String destination, String sessionId, String subsId) { |
|
|
|
public void updateAfterRemovedSubscription(String sessionId, String subsId) { |
|
|
|
synchronized (this.updateCache) { |
|
|
|
synchronized (this.updateCache) { |
|
|
|
Set<String> destinationsToRemove = new HashSet<String>(); |
|
|
|
Set<String> destinationsToRemove = new HashSet<String>(); |
|
|
|
for (Map.Entry<String, MultiValueMap<String, String>> entry : this.updateCache.entrySet()) { |
|
|
|
for (Map.Entry<String, MultiValueMap<String, String>> entry : this.updateCache.entrySet()) { |
|
|
|
String cachedDestination = entry.getKey(); |
|
|
|
String destination = entry.getKey(); |
|
|
|
if (getPathMatcher().match(destination, cachedDestination)) { |
|
|
|
MultiValueMap<String, String> sessionMap = entry.getValue(); |
|
|
|
MultiValueMap<String, String> subs = entry.getValue(); |
|
|
|
List<String> subscriptions = sessionMap.get(sessionId); |
|
|
|
List<String> subsIds = subs.get(sessionId); |
|
|
|
if (subscriptions != null) { |
|
|
|
subsIds.remove(subsId); |
|
|
|
subscriptions.remove(subsId); |
|
|
|
if (subsIds.isEmpty()) { |
|
|
|
if (subscriptions.isEmpty()) { |
|
|
|
subs.remove(sessionId); |
|
|
|
sessionMap.remove(sessionId); |
|
|
|
} |
|
|
|
} |
|
|
|
if (subs.isEmpty()) { |
|
|
|
if (sessionMap.isEmpty()) { |
|
|
|
destinationsToRemove.add(cachedDestination); |
|
|
|
destinationsToRemove.add(destination); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
this.accessCache.put(cachedDestination, new LinkedMultiValueMap<String, String>(subs)); |
|
|
|
this.accessCache.put(destination, new LinkedMultiValueMap<String, String>(sessionMap)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (String destinationToRemove : destinationsToRemove) { |
|
|
|
for (String destination : destinationsToRemove) { |
|
|
|
this.updateCache.remove(destinationToRemove); |
|
|
|
this.updateCache.remove(destination); |
|
|
|
this.accessCache.remove(destinationToRemove); |
|
|
|
this.accessCache.remove(destination); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateAfterRemovedSession(SessionSubscriptionInfo info) { |
|
|
|
public void updateAfterRemovedSession(SessionSubscriptionInfo info) { |
|
|
|
synchronized (this.updateCache) { |
|
|
|
synchronized (this.updateCache) { |
|
|
|
for (String destination : info.getDestinations()) { |
|
|
|
Set<String> destinationsToRemove = new HashSet<String>(); |
|
|
|
Set<String> destinationsToRemove = new HashSet<String>(); |
|
|
|
for (Map.Entry<String, MultiValueMap<String, String>> entry : this.updateCache.entrySet()) { |
|
|
|
for (Map.Entry<String, MultiValueMap<String, String>> entry : this.updateCache.entrySet()) { |
|
|
|
String destination = entry.getKey(); |
|
|
|
String cachedDestination = entry.getKey(); |
|
|
|
MultiValueMap<String, String> sessionMap = entry.getValue(); |
|
|
|
if (getPathMatcher().match(destination, cachedDestination)) { |
|
|
|
if (sessionMap.remove(info.getSessionId()) != null) { |
|
|
|
MultiValueMap<String, String> subs = entry.getValue(); |
|
|
|
if (sessionMap.isEmpty()) { |
|
|
|
subs.remove(info.getSessionId()); |
|
|
|
destinationsToRemove.add(destination); |
|
|
|
if (subs.isEmpty()) { |
|
|
|
} |
|
|
|
destinationsToRemove.add(cachedDestination); |
|
|
|
else { |
|
|
|
} |
|
|
|
this.accessCache.put(destination, new LinkedMultiValueMap<String, String>(sessionMap)); |
|
|
|
else { |
|
|
|
|
|
|
|
this.accessCache.put(cachedDestination,new LinkedMultiValueMap<String, String>(subs)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (String d : destinationsToRemove) { |
|
|
|
} |
|
|
|
this.updateCache.remove(d); |
|
|
|
for (String destination : destinationsToRemove) { |
|
|
|
this.accessCache.remove(d); |
|
|
|
this.updateCache.remove(destination); |
|
|
|
} |
|
|
|
this.accessCache.remove(destination); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|