use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.
the class MessageBrokerBeanDefinitionParser method registerAnnotationMethodMessageHandler.
private void registerAnnotationMethodMessageHandler(Element messageBrokerElement, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, RuntimeBeanReference converter, RuntimeBeanReference messagingTemplate, ParserContext context, Object source) {
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, inChannel);
cavs.addIndexedArgumentValue(1, outChannel);
cavs.addIndexedArgumentValue(2, messagingTemplate);
MutablePropertyValues values = new MutablePropertyValues();
String prefixAttribute = messageBrokerElement.getAttribute("application-destination-prefix");
values.add("destinationPrefixes", Arrays.asList(StringUtils.tokenizeToStringArray(prefixAttribute, ",")));
values.add("messageConverter", converter);
RootBeanDefinition beanDef = new RootBeanDefinition(WebSocketAnnotationMethodMessageHandler.class, cavs, values);
if (messageBrokerElement.hasAttribute("path-matcher")) {
String pathMatcherRef = messageBrokerElement.getAttribute("path-matcher");
beanDef.getPropertyValues().add("pathMatcher", new RuntimeBeanReference(pathMatcherRef));
}
RuntimeBeanReference validatorRef = getValidator(messageBrokerElement, source, context);
if (validatorRef != null) {
beanDef.getPropertyValues().add("validator", validatorRef);
}
Element resolversElement = DomUtils.getChildElementByTagName(messageBrokerElement, "argument-resolvers");
if (resolversElement != null) {
values.add("customArgumentResolvers", extractBeanSubElements(resolversElement, context));
}
Element handlersElement = DomUtils.getChildElementByTagName(messageBrokerElement, "return-value-handlers");
if (handlersElement != null) {
values.add("customReturnValueHandlers", extractBeanSubElements(handlersElement, context));
}
registerBeanDef(beanDef, context, source);
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.
the class MessageBrokerBeanDefinitionParser method registerUserDestResolver.
private RuntimeBeanReference registerUserDestResolver(Element brokerElem, RuntimeBeanReference userRegistry, ParserContext context, Object source) {
RootBeanDefinition beanDef = new RootBeanDefinition(DefaultUserDestinationResolver.class);
beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, userRegistry);
if (brokerElem.hasAttribute("user-destination-prefix")) {
beanDef.getPropertyValues().add("userDestinationPrefix", brokerElem.getAttribute("user-destination-prefix"));
}
if (brokerElem.hasAttribute("path-matcher")) {
String pathMatcherRef = brokerElem.getAttribute("path-matcher");
beanDef.getPropertyValues().add("pathMatcher", new RuntimeBeanReference(pathMatcherRef));
}
return new RuntimeBeanReference(registerBeanDef(beanDef, context, source));
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.
the class MessageBrokerBeanDefinitionParser method registerUserDestHandler.
private RuntimeBeanReference registerUserDestHandler(Element brokerElem, RuntimeBeanReference userRegistry, RuntimeBeanReference inChannel, RuntimeBeanReference brokerChannel, ParserContext context, Object source) {
Object userDestResolver = registerUserDestResolver(brokerElem, userRegistry, context, source);
RootBeanDefinition beanDef = new RootBeanDefinition(UserDestinationMessageHandler.class);
beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, inChannel);
beanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, brokerChannel);
beanDef.getConstructorArgumentValues().addIndexedArgumentValue(2, userDestResolver);
Element relayElement = DomUtils.getChildElementByTagName(brokerElem, "stomp-broker-relay");
if (relayElement != null && relayElement.hasAttribute("user-destination-broadcast")) {
String destination = relayElement.getAttribute("user-destination-broadcast");
beanDef.getPropertyValues().add("broadcastDestination", destination);
}
String beanName = registerBeanDef(beanDef, context, source);
return new RuntimeBeanReference(beanName);
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.
the class MessageBrokerBeanDefinitionParser method registerRequestHandler.
private RuntimeBeanReference registerRequestHandler(Element element, RuntimeBeanReference subProtoHandler, ParserContext context, Object source) {
RootBeanDefinition beanDef;
RuntimeBeanReference sockJsService = WebSocketNamespaceUtils.registerSockJsService(element, SCHEDULER_BEAN_NAME, context, source);
if (sockJsService != null) {
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, sockJsService);
cavs.addIndexedArgumentValue(1, subProtoHandler);
beanDef = new RootBeanDefinition(SockJsHttpRequestHandler.class, cavs, null);
// Register alias for backwards compatibility with 4.1
context.getRegistry().registerAlias(SCHEDULER_BEAN_NAME, SOCKJS_SCHEDULER_BEAN_NAME);
} else {
RuntimeBeanReference handshakeHandler = WebSocketNamespaceUtils.registerHandshakeHandler(element, context, source);
Element interceptorsElement = DomUtils.getChildElementByTagName(element, "handshake-interceptors");
ManagedList<? super Object> interceptors = WebSocketNamespaceUtils.parseBeanSubElements(interceptorsElement, context);
String allowedOriginsAttribute = element.getAttribute("allowed-origins");
List<String> allowedOrigins = Arrays.asList(StringUtils.tokenizeToStringArray(allowedOriginsAttribute, ","));
interceptors.add(new OriginHandshakeInterceptor(allowedOrigins));
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, subProtoHandler);
if (handshakeHandler != null) {
cavs.addIndexedArgumentValue(1, handshakeHandler);
}
beanDef = new RootBeanDefinition(WebSocketHttpRequestHandler.class, cavs, null);
beanDef.getPropertyValues().add("handshakeInterceptors", interceptors);
}
return new RuntimeBeanReference(registerBeanDef(beanDef, context, source));
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-framework by spring-projects.
the class MessageBrokerBeanDefinitionParser method registerWebSocketMessageBrokerStats.
private void registerWebSocketMessageBrokerStats(RootBeanDefinition broker, RuntimeBeanReference inChannel, RuntimeBeanReference outChannel, ParserContext context, Object source) {
RootBeanDefinition beanDef = new RootBeanDefinition(WebSocketMessageBrokerStats.class);
RuntimeBeanReference webSocketHandler = new RuntimeBeanReference(WEB_SOCKET_HANDLER_BEAN_NAME);
beanDef.getPropertyValues().add("subProtocolWebSocketHandler", webSocketHandler);
if (StompBrokerRelayMessageHandler.class == broker.getBeanClass()) {
beanDef.getPropertyValues().add("stompBrokerRelay", broker);
}
String name = inChannel.getBeanName() + "Executor";
if (context.getRegistry().containsBeanDefinition(name)) {
beanDef.getPropertyValues().add("inboundChannelExecutor", context.getRegistry().getBeanDefinition(name));
}
name = outChannel.getBeanName() + "Executor";
if (context.getRegistry().containsBeanDefinition(name)) {
beanDef.getPropertyValues().add("outboundChannelExecutor", context.getRegistry().getBeanDefinition(name));
}
Object scheduler = WebSocketNamespaceUtils.registerScheduler(SCHEDULER_BEAN_NAME, context, source);
beanDef.getPropertyValues().add("sockJsTaskScheduler", scheduler);
registerBeanDefByName("webSocketMessageBrokerStats", beanDef, context, source);
}
Aggregations