public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHandler<SimpMessageMappingInfo> implements EmbeddedValueResolverAware, SmartLifecycle
@MessageMapping
および @SubscribeMapping
アノテーション付きメソッドに委譲するメッセージのハンドラー。テンプレート変数で Ant スタイルのパスパターンをサポートします。
logger
DEFAULT_PHASE
コンストラクターと説明 |
---|
SimpAnnotationMethodMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SimpMessageSendingOperations brokerTemplate) 指定されたメッセージチャネルとブローカーメッセージングテンプレートを使用して SimpAnnotationMethodMessageHandler のインスタンスを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected AbstractExceptionHandlerMethodResolver | createExceptionHandlerMethodResolverFor(ClassSE<?> beanType) |
ConversionService | getConversionService() 設定された ConversionService を返します。 |
protected StringSE | getDestination(Message<?> message) |
protected SetSE<StringSE> | getDirectLookupDestinations(SimpMessageMappingInfo mapping) マッピングに含まれ、パターンではないため、直接ルックアップに適した戻り先。 |
protected Log | getHandlerMethodLogger() InvocableHandlerMethod に設定するロガーを返します。 |
MessageHeaderInitializer | getHeaderInitializer() 設定済みのヘッダー初期化子を返します。 |
protected StringSE | getLookupDestination(StringSE destination) (受信メッセージの)指定された宛先が構成済み宛先プレフィックスの 1 つと一致するかどうかを確認し、一致する場合は、一致したプレフィックスの後に宛先の残りの部分を返します。 |
protected ComparatorSE<SimpMessageMappingInfo> | getMappingComparator(Message<?> message) 一致するマッピングをソートするためのコンパレーターを返します。 |
protected SimpMessageMappingInfo | getMappingForMethod(MethodSE method, ClassSE<?> handlerType) ハンドラーメソッドのマッピングを提供します。 |
protected SimpMessageMappingInfo | getMatchingMapping(SimpMessageMappingInfo mapping, Message<?> message) マッピングが現在のメッセージと一致するかどうかを確認し、現在のリクエストに関連する条件を含む新しいマッピングを返す可能性があります。 |
MessageConverter | getMessageConverter() 設定された MessageConverter を返します。 |
PathMatcher | getPathMatcher() 一致する宛先に使用する PathMatcher 実装を返します。 |
protected Log | getReturnValueHandlerLogger() HandlerMethodReturnValueHandlerComposite に設定するロガーを返します。 |
Validator | getValidator() 設定された Validator インスタンスを返します。 |
protected void | handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod, StringSE lookupDestination, Message<?> message) |
protected ListSE<HandlerMethodArgumentResolver> | initArgumentResolvers() 使用する引数リゾルバーのリストを返します。 |
protected ListSE<? extends HandlerMethodReturnValueHandler> | initReturnValueHandlers() 使用する戻り値ハンドラーのリストを返します。 |
protected boolean | isHandler(ClassSE<?> beanType) 指定された Bean 型をメッセージング処理メソッドに対してイントロスペクトする必要があるかどうか。 |
boolean | isRunning() このコンポーネントが現在実行されているかどうかを確認します。 |
protected StringSE[] | resolveEmbeddedValuesInDestinations(StringSE[] destinations) 指定された宛先配列のプレースホルダー値を解決します。 |
void | setConversionService(ConversionService conversionService) メッセージヘッダー値などのメソッド引数を解決するときに使用する ConversionService を構成します。 |
void | setDestinationPrefixes(CollectionSE<StringSE> prefixes) このプロパティが設定されている場合、設定された接頭辞のいずれかに一致する宛先へのメッセージのみが処理に適しています。 |
void | setEmbeddedValueResolver(StringValueResolver resolver) StringValueResolver を設定して、埋め込まれた定義値の解決に使用します。 |
void | setHeaderInitializer(MessageHeaderInitializer headerInitializer) コントローラーの戻り値からメッセージを送信する HandlerMethodReturnValueHandlers に渡すように MessageHeaderInitializer を構成します。 |
void | setMessageConverter(MessageConverter converter) メッセージのペイロードを特定の MIME 型の直列化された形式からターゲットメソッドパラメーターに一致するオブジェクトに変換するために使用する MessageConverter を構成します。 |
void | setPathMatcher(PathMatcher pathMatcher) PathMatcher 実装を設定して、設定された宛先パターンに対して宛先を照合するために使用します。 |
void | setValidator(Validator validator) @Payload 引数の検証に使用される Validator インスタンスを設定します。 |
void | start() このコンポーネントを起動します。 |
void | stop() このメソッドを返すとコンポーネントが完全に停止するように、通常は同期的にこのコンポーネントを停止します。 |
void | stop(RunnableSE callback) Lifecycle コンポーネントが現在実行中の場合、停止する必要があることを示します。 |
afterPropertiesSet, createHandlerMethod, detectHandlerMethods, getApplicationContext, getArgumentResolvers, getCustomArgumentResolvers, getCustomReturnValueHandlers, getDestinationPrefixes, getExceptionHandlerMethod, getHandlerMethods, getReturnValueHandlers, handleMessage, handleMessageInternal, handleNoMatch, processHandlerMethodException, registerExceptionHandlerAdvice, registerHandlerMethod, setApplicationContext, setArgumentResolvers, setCustomArgumentResolvers, setCustomReturnValueHandlers, setReturnValueHandlers, toString
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
getPhase, isAutoStartup
public SimpAnnotationMethodMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SimpMessageSendingOperations brokerTemplate)
clientInboundChannel
- クライアントからメッセージを受信するためのチャネル (たとえば WebSocket クライアント)clientOutboundChannel
- クライアントへのメッセージのチャネル (たとえば WebSocket クライアント)brokerTemplate
- アプリケーションメッセージをブローカーに送信するためのメッセージングテンプレート public void setDestinationPrefixes(@Nullable CollectionSE<StringSE> prefixes)
デフォルトでは、プレフィックスは設定されていません。この場合、すべてのメッセージが処理に適格です。
宛先の接頭辞はスラッシュで区切られた文字列であることが期待されているため、適切な接頭辞ベースの一致(つまり、完全なセグメントの一致)を確実にするために、欠落している場所にスラッシュが自動的に追加されます。
ただし、設定された PathMatcher
に応じて、プレフィックスの後の宛先の残りの部分では、異なるセパレーター(たとえば、メッセージングでは通常 "." )を使用する場合があることに注意してください。
AbstractMethodMessageHandler<SimpMessageMappingInfo>
の setDestinationPrefixes
public void setMessageConverter(MessageConverter converter)
MessageConverter
を構成します。コンバーターは、メッセージブローカーにメッセージを送信するときにも使用されます。public MessageConverter getMessageConverter()
MessageConverter
を返します。public void setConversionService(ConversionService conversionService)
ConversionService
を構成します。 デフォルトでは、DefaultFormattingConversionService
が使用されます。
public ConversionService getConversionService()
ConversionService
を返します。public void setPathMatcher(PathMatcher pathMatcher)
デフォルトでは、AntPathMatcher
が使用されます。
public PathMatcher getPathMatcher()
public void setValidator(@Nullable Validator validator)
@Payload
引数の検証に使用される Validator インスタンスを設定します。public void setEmbeddedValueResolver(StringValueResolver resolver)
EmbeddedValueResolverAware
EmbeddedValueResolverAware
の setEmbeddedValueResolver
public void setHeaderInitializer(@Nullable MessageHeaderInitializer headerInitializer)
HandlerMethodReturnValueHandlers
に渡すように MessageHeaderInitializer
を構成します。デフォルトでは、このプロパティは設定されていません。
@Nullable public MessageHeaderInitializer getHeaderInitializer()
public final void start()
Lifecycle
コンポーネントがすでに実行されている場合は、例外をスローしないでください。
コンテナーの場合、これは適用されるすべてのコンポーネントに開始シグナルを伝播します。
Lifecycle
の start
SmartLifecycle.isAutoStartup()
public final void stop()
Lifecycle
SmartLifecycle
とその stop(Runnable)
バリアントの実装を検討してください。 この停止通知は破棄前に送信されるとは限らないことに注意してください。通常のシャットダウンでは、一般的な破棄コールバックが伝播される前に、Lifecycle
Bean は最初に停止通知を受信します。ただし、コンテキストの存続期間中のホットリフレッシュまたは中断されたリフレッシュ試行では、特定の Bean の destroy メソッドが、停止シグナルを事前に考慮することなく呼び出されます。
コンポーネントが実行されていない(まだ開始されていない)場合は、例外をスローしないでください。
コンテナーの場合、これは停止シグナルを適用するすべてのコンポーネントに伝播します。
Lifecycle
の stop
SmartLifecycle.stop(Runnable)
, DisposableBean.destroy()
public final void stop(RunnableSE callback)
SmartLifecycle
提供されたコールバックは、LifecycleProcessor
によって使用され、共通のシャットダウン順序値を持つすべてのコンポーネントの順序付けられた、潜在的に同時のシャットダウンをサポートします。コールバック は、SmartLifecycle
コンポーネントが実際に停止した後に実行する必要があります。
LifecycleProcessor
は、stop
メソッドのこのバリアントのみを呼び出します。つまり、SmartLifecycle
実装では、このメソッドの実装内に明示的に委譲されない限り、Lifecycle.stop()
は呼び出されません。
デフォルトの実装は Lifecycle.stop()
に委譲し、呼び出しスレッドで指定されたコールバックをすぐにトリガーします。2 つの間に同期がないことに注意してください。カスタム実装では、少なくとも共通のライフサイクルモニター(存在する場合)内に同じ手順を入れたい場合があります。
SmartLifecycle
の stop
Lifecycle.stop()
, SmartLifecycle.getPhase()
public final boolean isRunning()
Lifecycle
コンテナーの場合、これは、適用されるすべてのコンポーネントが現在実行されている場合にのみ、true
を返します。
protected ListSE<HandlerMethodArgumentResolver> initArgumentResolvers()
AbstractMethodMessageHandler
AbstractMethodMessageHandler.setArgumentResolvers(java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver>)
を介してリゾルバーがまだ設定されていない場合にのみ呼び出されます。 サブクラスでは、AbstractMethodMessageHandler.setCustomArgumentResolvers(java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver>)
を介して構成されたカスタム引数型も考慮する必要があります。
protected ListSE<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers()
AbstractMethodMessageHandler
AbstractMethodMessageHandler.setReturnValueHandlers(java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler>)
を介してまだ設定されていない場合にのみ呼び出されます。 サブクラスは、AbstractMethodMessageHandler.setCustomReturnValueHandlers(java.util.List<org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler>)
を介して構成されたカスタム戻り値型も考慮する必要があります。
protected Log getReturnValueHandlerLogger()
AbstractMethodMessageHandler
HandlerMethodReturnValueHandlerComposite
に設定するロガーを返します。protected Log getHandlerMethodLogger()
AbstractMethodMessageHandler
InvocableHandlerMethod
に設定するロガーを返します。AbstractMethodMessageHandler<SimpMessageMappingInfo>
の getHandlerMethodLogger
protected boolean isHandler(ClassSE<?> beanType)
AbstractMethodMessageHandler
AbstractMethodMessageHandler<SimpMessageMappingInfo>
の isHandler
@Nullable protected SimpMessageMappingInfo getMappingForMethod(MethodSE method, ClassSE<?> handlerType)
AbstractMethodMessageHandler
AbstractMethodMessageHandler<SimpMessageMappingInfo>
の getMappingForMethod
method
- マッピングを提供する方法 handlerType
- ハンドラー型、場合によってはメソッドの宣言クラスのサブ型 null
protected StringSE[] resolveEmbeddedValuesInDestinations(StringSE[] destinations)
protected SetSE<StringSE> getDirectLookupDestinations(SimpMessageMappingInfo mapping)
AbstractMethodMessageHandler
protected StringSE getLookupDestination(@Nullable StringSE destination)
AbstractMethodMessageHandler
一致するプレフィックスがない場合は、null
を返します。
宛先プレフィックスがない場合は、宛先をそのまま返します。
AbstractMethodMessageHandler<SimpMessageMappingInfo>
の getLookupDestination
@Nullable protected SimpMessageMappingInfo getMatchingMapping(SimpMessageMappingInfo mapping, Message<?> message)
AbstractMethodMessageHandler
AbstractMethodMessageHandler<SimpMessageMappingInfo>
の getMatchingMapping
mapping
- 一致を取得するマッピング message
- 処理されているメッセージ null
protected ComparatorSE<SimpMessageMappingInfo> getMappingComparator(Message<?> message)
AbstractMethodMessageHandler
AbstractMethodMessageHandler<SimpMessageMappingInfo>
の getMappingComparator
message
- 現在のメッセージ null
protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod, StringSE lookupDestination, Message<?> message)
AbstractMethodMessageHandler<SimpMessageMappingInfo>
の handleMatch
protected AbstractExceptionHandlerMethodResolver createExceptionHandlerMethodResolverFor(ClassSE<?> beanType)