org.springframework.messaging.simp.user.SimpSubscriptionMatcher Java Examples

The following examples show how to use org.springframework.messaging.simp.user.SimpSubscriptionMatcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultSimpUserRegistry.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) {
	Set<SimpSubscription> result = new HashSet<>();
	for (LocalSimpSession session : this.sessions.values()) {
		for (SimpSubscription subscription : session.subscriptions.values()) {
			if (matcher.match(subscription)) {
				result.add(subscription);
			}
		}
	}
	return result;
}
 
Example #2
Source File: DefaultSimpUserRegistryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void findSubscriptions() throws Exception {
	DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry();

	TestPrincipal user = new TestPrincipal("joe");
	Message<byte[]> message = createMessage(SimpMessageType.CONNECT_ACK, "123");
	SessionConnectedEvent event = new SessionConnectedEvent(this, message, user);
	registry.onApplicationEvent(event);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub1", "/match");
	SessionSubscribeEvent subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub2", "/match");
	subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub3", "/not-a-match");
	subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	Set<SimpSubscription> matches = registry.findSubscriptions(new SimpSubscriptionMatcher() {
		@Override
		public boolean match(SimpSubscription subscription) {
			return subscription.getDestination().equals("/match");
		}
	});

	assertEquals(2, matches.size());

	Iterator<SimpSubscription> iterator = matches.iterator();
	Set<String> sessionIds = new HashSet<>(2);
	sessionIds.add(iterator.next().getId());
	sessionIds.add(iterator.next().getId());
	assertEquals(new HashSet<>(Arrays.asList("sub1", "sub2")), sessionIds);
}
 
Example #3
Source File: DefaultSimpUserRegistry.java    From java-technology-stack with MIT License 5 votes vote down vote up
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) {
	Set<SimpSubscription> result = new HashSet<>();
	for (LocalSimpSession session : this.sessions.values()) {
		for (SimpSubscription subscription : session.subscriptions.values()) {
			if (matcher.match(subscription)) {
				result.add(subscription);
			}
		}
	}
	return result;
}
 
Example #4
Source File: DefaultSimpUserRegistryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void findSubscriptions() throws Exception {
	DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry();

	TestPrincipal user = new TestPrincipal("joe");
	Message<byte[]> message = createMessage(SimpMessageType.CONNECT_ACK, "123");
	SessionConnectedEvent event = new SessionConnectedEvent(this, message, user);
	registry.onApplicationEvent(event);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub1", "/match");
	SessionSubscribeEvent subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub2", "/match");
	subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub3", "/not-a-match");
	subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	Set<SimpSubscription> matches = registry.findSubscriptions(new SimpSubscriptionMatcher() {
		@Override
		public boolean match(SimpSubscription subscription) {
			return subscription.getDestination().equals("/match");
		}
	});

	assertEquals(2, matches.size());

	Iterator<SimpSubscription> iterator = matches.iterator();
	Set<String> sessionIds = new HashSet<>(2);
	sessionIds.add(iterator.next().getId());
	sessionIds.add(iterator.next().getId());
	assertEquals(new HashSet<>(Arrays.asList("sub1", "sub2")), sessionIds);
}
 
Example #5
Source File: DefaultSimpUserRegistry.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) {
	Set<SimpSubscription> result = new HashSet<SimpSubscription>();
	for (DefaultSimpSession session : this.sessions.values()) {
		for (SimpSubscription subscription : session.subscriptions.values()) {
			if (matcher.match(subscription)) {
				result.add(subscription);
			}
		}
	}
	return result;
}
 
Example #6
Source File: DefaultSimpUserRegistryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void findSubscriptions() throws Exception {

	DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry();

	TestPrincipal user = new TestPrincipal("joe");
	Message<byte[]> message = createMessage(SimpMessageType.CONNECT_ACK, "123");
	SessionConnectedEvent event = new SessionConnectedEvent(this, message, user);
	registry.onApplicationEvent(event);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub1", "/match");
	SessionSubscribeEvent subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub2", "/match");
	subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	message = createMessage(SimpMessageType.SUBSCRIBE, "123", "sub3", "/not-a-match");
	subscribeEvent = new SessionSubscribeEvent(this, message, user);
	registry.onApplicationEvent(subscribeEvent);

	Set<SimpSubscription> matches = registry.findSubscriptions(new SimpSubscriptionMatcher() {
		@Override
		public boolean match(SimpSubscription subscription) {
			return subscription.getDestination().equals("/match");
		}
	});

	assertEquals(2, matches.size());

	Iterator<SimpSubscription> iterator = matches.iterator();
	Set<String> sessionIds = new HashSet<>(2);
	sessionIds.add(iterator.next().getId());
	sessionIds.add(iterator.next().getId());
	assertEquals(new HashSet<>(Arrays.asList("sub1", "sub2")), sessionIds);
}
 
Example #7
Source File: MessageBrokerConfigurationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) { return null; }
 
Example #8
Source File: MessageBrokerConfigurationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) { return null; }