1 /* 2 * Copyright 2002-2018 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 module hunt.stomp.core.AbstractDestinationResolvingMessagingTemplate; 18 19 import hunt.stomp.core.AbstractMessagingTemplate; 20 import hunt.stomp.core.DestinationResolvingMessageSendingOperations; 21 import hunt.stomp.core.DestinationResolvingMessageReceivingOperations; 22 import hunt.stomp.core.DestinationResolvingMessageRequestReplyOperations; 23 import hunt.stomp.Message; 24 25 import hunt.collection.Map; 26 27 28 /** 29 * An extension of {@link AbstractMessagingTemplate} that adds operations for sending 30 * messages to a resolvable destination name. Supports destination resolving as defined by 31 * the following interfaces: 32 * <ul> 33 * <li>{@link DestinationResolvingMessageSendingOperations}</li> 34 * <li>{@link DestinationResolvingMessageReceivingOperations}</li> 35 * <li>{@link DestinationResolvingMessageRequestReplyOperations}</li> 36 * </ul> 37 * 38 * @author Mark Fisher 39 * @author Rossen Stoyanchev 40 * @since 4.0 41 * @param (T) the destination type 42 */ 43 abstract class AbstractDestinationResolvingMessagingTemplate(T) : AbstractMessagingTemplate!(T), 44 DestinationResolvingMessageSendingOperations!(T), 45 DestinationResolvingMessageReceivingOperations!(T), 46 DestinationResolvingMessageRequestReplyOperations!(T) { 47 48 private DestinationResolver!(T) destinationResolver; 49 50 51 /** 52 * Configure the {@link DestinationResolver} to use to resolve string destination 53 * names into actual destinations of type {@code !(T)}. 54 * <p>This field does not have a default setting. If not configured, methods that 55 * require resolving a destination name will raise an {@link IllegalArgumentException}. 56 * @param destinationResolver the destination resolver to use 57 */ 58 void setDestinationResolver(DestinationResolver!(T) destinationResolver) { 59 this.destinationResolver = destinationResolver; 60 } 61 62 /** 63 * Return the configured destination resolver. 64 */ 65 66 DestinationResolver!(T) getDestinationResolver() { 67 return this.destinationResolver; 68 } 69 70 71 // override 72 // void send(string destinationName, MessageBase message) { 73 // T destination = resolveDestination(destinationName); 74 // doSend(destination, message); 75 // } 76 77 // protected final T resolveDestination(string destinationName) { 78 // assert(this.destinationResolver !is null, "DestinationResolver is required to resolve destination names"); 79 // return this.destinationResolver.resolveDestination(destinationName); 80 // } 81 82 // override 83 // <T> void convertAndSend(string destinationName, T payload) { 84 // convertAndSend(destinationName, payload, null, null); 85 // } 86 87 // override 88 // <T> void convertAndSend(string destinationName, T payload, Map!(string, Object) headers) { 89 // convertAndSend(destinationName, payload, headers, null); 90 // } 91 92 // override 93 // <T> void convertAndSend(string destinationName, T payload, MessagePostProcessor postProcessor) { 94 // convertAndSend(destinationName, payload, null, postProcessor); 95 // } 96 97 // override 98 // <T> void convertAndSend(string destinationName, T payload, 99 // Map!(string, Object) headers, MessagePostProcessor postProcessor) { 100 101 // T destination = resolveDestination(destinationName); 102 // super.convertAndSend(destination, payload, headers, postProcessor); 103 // } 104 105 // override 106 107 // Message!(T) receive(string destinationName) { 108 // T destination = resolveDestination(destinationName); 109 // return super.receive(destination); 110 // } 111 112 // override 113 114 // <T> T receiveAndConvert(string destinationName, Class!(T) targetClass) { 115 // T destination = resolveDestination(destinationName); 116 // return super.receiveAndConvert(destination, targetClass); 117 // } 118 119 // override 120 121 // Message!(T) sendAndReceive(string destinationName, Message!(T) requestMessage) { 122 // T destination = resolveDestination(destinationName); 123 // return super.sendAndReceive(destination, requestMessage); 124 // } 125 126 // override 127 128 // <T> T convertSendAndReceive(string destinationName, Object request, Class!(T) targetClass) { 129 // T destination = resolveDestination(destinationName); 130 // return super.convertSendAndReceive(destination, request, targetClass); 131 // } 132 133 // override 134 135 // <T> T convertSendAndReceive(string destinationName, Object request, 136 // Map!(string, Object) headers, Class!(T) targetClass) { 137 138 // T destination = resolveDestination(destinationName); 139 // return super.convertSendAndReceive(destination, request, headers, targetClass); 140 // } 141 142 // override 143 144 // <T> T convertSendAndReceive(string destinationName, Object request, Class!(T) targetClass, 145 // MessagePostProcessor postProcessor) { 146 147 // T destination = resolveDestination(destinationName); 148 // return super.convertSendAndReceive(destination, request, targetClass, postProcessor); 149 // } 150 151 // override 152 153 // <T> T convertSendAndReceive(string destinationName, Object request, 154 // Map!(string, Object) headers, Class!(T) targetClass, 155 // MessagePostProcessor postProcessor) { 156 157 // T destination = resolveDestination(destinationName); 158 // return super.convertSendAndReceive(destination, request, headers, targetClass, postProcessor); 159 // } 160 161 }