|
| 1 | +/* |
| 2 | + * Copyright 2002-present 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 | + * https://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 | +package org.springframework.web.socket.config.annotation; |
| 18 | + |
| 19 | +import java.lang.annotation.Documented; |
| 20 | +import java.lang.annotation.ElementType; |
| 21 | +import java.lang.annotation.Retention; |
| 22 | +import java.lang.annotation.RetentionPolicy; |
| 23 | +import java.lang.annotation.Target; |
| 24 | + |
| 25 | +import org.springframework.context.annotation.Scope; |
| 26 | +import org.springframework.context.annotation.ScopedProxyMode; |
| 27 | +import org.springframework.core.annotation.AliasFor; |
| 28 | + |
| 29 | +/** |
| 30 | + * {@code @WebSocketScope} is a specialization of {@link Scope @Scope} for a |
| 31 | + * component whose lifecycle is bound to the current WebSocket lifecycle. |
| 32 | + * |
| 33 | + * <p>Specifically, {@code @WebSocketScope} is a <em>composed annotation</em> that |
| 34 | + * acts as a shortcut for {@code @Scope("websocket")} with the default |
| 35 | + * {@link #proxyMode} set to {@link ScopedProxyMode#TARGET_CLASS TARGET_CLASS}. |
| 36 | + * |
| 37 | + * <p>{@code @WebSocketScope} may be used as a meta-annotation to create custom |
| 38 | + * composed annotations. |
| 39 | + * |
| 40 | + * @author Juergen Hoeller |
| 41 | + * @since 7.0 |
| 42 | + * @see org.springframework.context.annotation.Scope |
| 43 | + * @see WebSocketMessageBrokerConfigurationSupport#SCOPE_WEBSOCKET |
| 44 | + * @see org.springframework.stereotype.Component |
| 45 | + * @see org.springframework.context.annotation.Bean |
| 46 | + */ |
| 47 | +@Target({ElementType.TYPE, ElementType.METHOD}) |
| 48 | +@Retention(RetentionPolicy.RUNTIME) |
| 49 | +@Documented |
| 50 | +@Scope(WebSocketMessageBrokerConfigurationSupport.SCOPE_WEBSOCKET) |
| 51 | +public @interface WebSocketScope { |
| 52 | + |
| 53 | + /** |
| 54 | + * Alias for {@link Scope#proxyMode}. |
| 55 | + * <p>Defaults to {@link ScopedProxyMode#TARGET_CLASS}. |
| 56 | + */ |
| 57 | + @AliasFor(annotation = Scope.class) |
| 58 | + ScopedProxyMode proxyMode() default ScopedProxyMode.TARGET_CLASS; |
| 59 | + |
| 60 | +} |
0 commit comments