001/* 002 * Copyright 2002-2019 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.rsocket.annotation; 018 019import java.lang.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Retention; 022import java.lang.annotation.RetentionPolicy; 023import java.lang.annotation.Target; 024 025import io.rsocket.ConnectionSetupPayload; 026 027/** 028 * Annotation to map the initial {@link ConnectionSetupPayload} and subsequent 029 * metadata pushes onto a handler method. 030 * 031 * <p>This is a method-level annotation that can be combined with a type-level 032 * {@link org.springframework.messaging.handler.annotation.MessageMapping @MessageMapping} 033 * for a combined route pattern. It supports the same arguments as 034 * {@code @MessageMapping} but the return value must be {@code void}. On a 035 * server, handling can be asynchronous (e.g. {@code Mono<Void>}), in which 036 * case the connection is accepted if and when the {@code Mono<Void>} completes. 037 * On the client side this method is only a callback and does not affect the 038 * establishment of the connection. 039 * 040 * <p><strong>Note:</strong> an {@code @ConnectMapping} method may start 041 * requests to the remote through an 042 * {@link org.springframework.messaging.rsocket.RSocketRequester RSocketRequester} 043 * method argument, but it must do so independent of the handling thread (e.g. 044 * via subscribing on a different thread). 045 * 046 * @author Rossen Stoyanchev 047 * @since 5.2 048 */ 049@Target(ElementType.METHOD) 050@Retention(RetentionPolicy.RUNTIME) 051@Documented 052public @interface ConnectMapping { 053 054 /** 055 * Mappings expressed by this annotation to match to the route from the 056 * metadata of the initial {@link ConnectionSetupPayload} or in 057 * subsequent metadata pushes. 058 * <p>Depending on the configured 059 * {@link org.springframework.util.RouteMatcher RouteMatcher}, the pattern may be 060 * {@link org.springframework.util.AntPathMatcher AntPathMatcher} or 061 * {@link org.springframework.web.util.pattern.PathPattern PathPattern} based. 062 * <p>By default this is an empty array in which case it matches all 063 * {@link ConnectionSetupPayload} and metadata pushes. 064 */ 065 String[] value() default {}; 066 067}