001/* 002 * Copyright 2002-2016 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.messaging.simp.config; 018 019import java.util.Arrays; 020import java.util.Collection; 021import java.util.Collections; 022import java.util.List; 023 024import org.springframework.messaging.MessageChannel; 025import org.springframework.messaging.SubscribableChannel; 026import org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler; 027import org.springframework.util.Assert; 028 029/** 030 * Base class for message broker registration classes. 031 * 032 * @author Rossen Stoyanchev 033 * @since 4.0 034 */ 035public abstract class AbstractBrokerRegistration { 036 037 private final SubscribableChannel clientInboundChannel; 038 039 private final MessageChannel clientOutboundChannel; 040 041 private final List<String> destinationPrefixes; 042 043 044 public AbstractBrokerRegistration(SubscribableChannel clientInboundChannel, 045 MessageChannel clientOutboundChannel, String[] destinationPrefixes) { 046 047 Assert.notNull(clientOutboundChannel, "'clientInboundChannel' must not be null"); 048 Assert.notNull(clientOutboundChannel, "'clientOutboundChannel' must not be null"); 049 050 this.clientInboundChannel = clientInboundChannel; 051 this.clientOutboundChannel = clientOutboundChannel; 052 053 this.destinationPrefixes = (destinationPrefixes != null ? 054 Arrays.asList(destinationPrefixes) : Collections.<String>emptyList()); 055 } 056 057 058 protected SubscribableChannel getClientInboundChannel() { 059 return this.clientInboundChannel; 060 } 061 062 protected MessageChannel getClientOutboundChannel() { 063 return this.clientOutboundChannel; 064 } 065 066 protected Collection<String> getDestinationPrefixes() { 067 return this.destinationPrefixes; 068 } 069 070 071 protected abstract AbstractBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel); 072 073}