T
- ハンドラーメソッドを受信リクエストに一致させるために必要な条件を含む HandlerMethod
のマッピング。public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMapping implements InitializingBean
HandlerMethod
の間のマッピングを定義する HandlerMapping
実装の抽象基本クラス。 登録された各ハンドラーメソッドについて、マッピング型 <T>
の詳細を定義するサブクラスで一意のマッピングが維持されます。
mappingsLogger
logger
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, LOOKUP_PATH, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
コンストラクターと説明 |
---|
AbstractHandlerMethodMapping() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() 初期化時にハンドラーメソッドを検出します。 |
protected HandlerMethod | createHandlerMethod(ObjectSE handler, MethodSE method) HandlerMethod インスタンスを作成します。 |
protected void | detectHandlerMethods(ObjectSE handler) 指定されたハンドラー Bean でハンドラーメソッドを探します。 |
protected StringSE[] | getCandidateBeanNames() アプリケーションコンテキストで候補 Bean の名前を決定します。 |
protected CorsConfiguration | getCorsConfiguration(ObjectSE handler, HttpServletRequestEE request) 指定されたハンドラーの CORS 構成を取得します。 |
protected SetSE<StringSE> | getDirectPaths(T mapping) パターンではないリクエストマッピングパスを返します。 |
protected HandlerMethod | getHandlerInternal(HttpServletRequestEE request) 指定されたリクエストのハンドラーメソッドを検索します。 |
MapSE<T, HandlerMethod> | getHandlerMethods() すべてのマッピングと HandlerMethod を含む(読み取り専用)マップを返します。 |
ListSE<HandlerMethod> | getHandlerMethodsForMappingName(StringSE mappingName) 指定されたマッピング名のハンドラーメソッドを返します。 |
protected abstract ComparatorSE<T> | getMappingComparator(HttpServletRequestEE request) 一致するマッピングをソートするためのコンパレーターを返します。 |
protected abstract T | getMappingForMethod(MethodSE method, ClassSE<?> handlerType) ハンドラーメソッドのマッピングを提供します。 |
protected SetSE<StringSE> | getMappingPathPatterns(T mapping) 使用すべきではありません。 5.3 以降、代わりに getDirectPaths(Object) を介して非パターンマッピングを提供する |
protected abstract T | getMatchingMapping(T mapping, HttpServletRequestEE request) マッピングが現在のリクエストに一致するかどうかを確認し、現在のリクエストに関連する条件を含む(潜在的に新しい)マッピングを返します。 |
HandlerMethodMappingNamingStrategy<T> | getNamingStrategy() 構成された命名戦略または null を返します。 |
protected void | handleMatch(T mapping, StringSE lookupPath, HttpServletRequestEE request) 一致するマッピングが見つかったときに呼び出されます。 |
protected HandlerMethod | handleNoMatch(SetSE<T> mappings, StringSE lookupPath, HttpServletRequestEE request) 一致するマッピングが見つからないときに呼び出されます。 |
protected void | handlerMethodsInitialized(MapSE<T, HandlerMethod> handlerMethods) すべてのハンドラーメソッドが検出された後に呼び出されます。 |
protected boolean | hasCorsConfigurationSource(ObjectSE handler) このハンドラーに CorsConfigurationSource がある場合、true を返します。 |
protected CorsConfiguration | initCorsConfiguration(ObjectSE handler, MethodSE method, T mapping) マッピングの CORS 設定を抽出して返します。 |
protected void | initHandlerMethods() ApplicationContext で Bean をスキャンし、ハンドラーメソッドを検出して登録します。 |
protected abstract boolean | isHandler(ClassSE<?> beanType) 指定された型がハンドラーメソッドを持つハンドラーかどうか。 |
protected HandlerMethod | lookupHandlerMethod(StringSE lookupPath, HttpServletRequestEE request) 現在のリクエストに最適なハンドラーメソッドを検索します。 |
protected void | processCandidateBean(StringSE beanName) 指定された候補 Bean の型を判別し、ハンドラー型として識別された場合は detectHandlerMethods(java.lang.Object) を呼び出します。 |
protected void | registerHandlerMethod(ObjectSE handler, MethodSE method, T mapping) ハンドラーメソッドとその一意のマッピングを登録します。 |
void | registerMapping(T mapping, ObjectSE handler, MethodSE method) 指定されたマッピングを登録します。 |
void | setDetectHandlerMethodsInAncestorContexts(boolean detectHandlerMethodsInAncestorContexts) 祖先 ApplicationContexts の Bean でハンドラーメソッドを検出するかどうか。 |
void | setHandlerMethodMappingNamingStrategy(HandlerMethodMappingNamingStrategy<T> namingStrategy) マップされたすべてのハンドラーメソッドにデフォルト名を割り当てるために使用する命名戦略を構成します。 |
void | setPatternParser(PathPatternParser patternParser) AntPathMatcher との文字列パターンマッチングの代わりに、事前に解析された PathPattern の使用を有効にします。 |
void | unregisterMapping(T mapping) 指定されたマッピングを登録解除します。 |
adaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfigurationSource, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getPatternParser, getUrlPathHelper, initApplicationContext, initInterceptors, initLookupPath, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper, usesPathPatterns
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public void setPatternParser(PathPatternParser patternParser)
AbstractHandlerMapping
AntPathMatcher
との文字列パターンマッチングの代わりに、事前に解析された PathPattern
の使用を有効にします。構文はほぼ同じですが、PathPattern
構文は Web アプリケーション向けに調整されており、その実装はより効率的です。このプロパティは、これが設定されている場合は事実上無視される次の他のプロパティと相互に排他的です。
AbstractHandlerMapping.setAlwaysUseFullPath(boolean)
-- PathPatterns
は常にフルパスを使用し、デコードされて部分的に正規化されているため requestURI
EE と比較できない servletPath/pathInfo を無視します。AbstractHandlerMapping.setRemoveSemicolonContent(boolean)
-- PathPatterns
は、パスマッチングの目的で常にセミコロンの内容を無視しますが、パスパラメーターは @MatrixVariable
を介してコントローラーで使用できます。AbstractHandlerMapping.setUrlDecode(boolean)
-- PathPatterns
は、一度に 1 つのデコードされたパスセグメントに一致し、デコードされた予約文字が原因で課題を引き起こす可能性のある完全なデコードされたパスを必要としません。AbstractHandlerMapping.setUrlPathHelper(org.springframework.web.util.UrlPathHelper)
-- リクエストパスは、DispatcherServlet
または ServletRequestPathUtils
を使用する ServletRequestPathFilter
によってグローバルに事前解析され、再利用のためにリクエスト属性に保存されます。AbstractHandlerMapping.setPathMatcher(org.springframework.util.PathMatcher)
-- パターンは PathPatterns
に解析され、PathMatcher
との文字列照合の代わりに使用されます。デフォルトでは、これは設定されていません。
AbstractHandlerMapping
の setPatternParser
patternParser
- 使用するパーサー public void setDetectHandlerMethodsInAncestorContexts(boolean detectHandlerMethodsInAncestorContexts)
デフォルトは「false」: 現在の ApplicationContext の Bean のみが考慮されます。つまり、この HandlerMapping 自体が定義されているコンテキスト(通常、現在の DispatcherServlet のコンテキスト)のみが考慮されます。
このフラグをオンにして、祖先コンテキスト(通常は Spring ルート WebApplicationContext)のハンドラー Bean も検出します。
public void setHandlerMethodMappingNamingStrategy(HandlerMethodMappingNamingStrategy<T> namingStrategy)
デフォルトの命名戦略は、クラス名の大文字に基づいて "#" が続き、次にメソッド名が続きます。メソッド getFoo を持つ TestController というクラスの "TC#getFoo"。
@Nullable public HandlerMethodMappingNamingStrategy<T> getNamingStrategy()
null
を返します。public MapSE<T,HandlerMethod> getHandlerMethods()
@Nullable public ListSE<HandlerMethod> getHandlerMethodsForMappingName(StringSE mappingName)
mappingName
- マッピング名 null
のリスト。返されたリストは変更されることはなく、反復しても安全です。setHandlerMethodMappingNamingStrategy(org.springframework.web.servlet.handler.HandlerMethodMappingNamingStrategy<T>)
public void registerMapping(T mapping, ObjectSE handler, MethodSE method)
このメソッドは、初期化が完了した後、実行時に呼び出すことができます。
mapping
- ハンドラーメソッドのマッピング handler
- ハンドラー method
- メソッド public void unregisterMapping(T mapping)
このメソッドは、初期化が完了した後、実行時に呼び出すことができます。
mapping
- 登録解除するマッピング public void afterPropertiesSet()
InitializingBean
の afterPropertiesSet
initHandlerMethods()
protected void initHandlerMethods()
protected StringSE[] getCandidateBeanNames()
protected void processCandidateBean(StringSE beanName)
detectHandlerMethods(java.lang.Object)
を呼び出します。 この実装は、BeanFactory.getType(java.lang.String)
をチェックし、Bean 名で detectHandlerMethods(java.lang.Object)
を呼び出すことにより、Bean の作成を回避します。
beanName
- 候補者 Bean の名前 isHandler(java.lang.Class<?>)
, detectHandlerMethods(java.lang.Object)
protected void detectHandlerMethods(ObjectSE handler)
handler
- Bean 名または実際のハンドラーインスタンス getMappingForMethod(java.lang.reflect.Method, java.lang.Class<?>)
protected void registerHandlerMethod(ObjectSE handler, MethodSE method, T mapping)
handler
- ハンドラーまたはハンドラーインスタンスの Bean 名 method
- 登録する方法 mapping
- ハンドラーメソッドに関連付けられたマッピング条件 IllegalStateExceptionSE
- 別のメソッドが同じマッピングですでに登録されている場合 protected HandlerMethod createHandlerMethod(ObjectSE handler, MethodSE method)
handler
- Bean 名または実際のハンドラーインスタンス method
- ターゲットメソッド @Nullable protected CorsConfiguration initCorsConfiguration(ObjectSE handler, MethodSE method, T mapping)
protected void handlerMethodsInitialized(MapSE<T,HandlerMethod> handlerMethods)
handlerMethods
- ハンドラーメソッドとマッピングを含む読み取り専用マップ。@Nullable protected HandlerMethod getHandlerInternal(HttpServletRequestEE request) throws ExceptionSE
AbstractHandlerMapping
の getHandlerInternal
request
- 現在の HTTP リクエスト null
ExceptionSE
- 内部エラーがある場合 @Nullable protected HandlerMethod lookupHandlerMethod(StringSE lookupPath, HttpServletRequestEE request) throws ExceptionSE
lookupPath
- 現在のサーブレットマッピング内のマッピングルックアップパス request
- 現在のリクエスト null
ExceptionSE
handleMatch(Object, String, HttpServletRequest)
, handleNoMatch(Set, String, HttpServletRequest)
protected void handleMatch(T mapping, StringSE lookupPath, HttpServletRequestEE request)
mapping
- 一致するマッピング lookupPath
- 現在のサーブレットマッピング内のマッピングルックアップパス request
- 現在のリクエスト @Nullable protected HandlerMethod handleNoMatch(SetSE<T> mappings, StringSE lookupPath, HttpServletRequestEE request) throws ExceptionSE
mappings
- 登録済みのすべてのマッピング lookupPath
- 現在のサーブレットマッピング内のマッピングルックアップパス request
- 現在のリクエスト ServletExceptionEE
- エラーの場合 ExceptionSE
protected boolean hasCorsConfigurationSource(ObjectSE handler)
AbstractHandlerMapping
CorsConfigurationSource
がある場合、true
を返します。AbstractHandlerMapping
の hasCorsConfigurationSource
protected CorsConfiguration getCorsConfiguration(ObjectSE handler, HttpServletRequestEE request)
AbstractHandlerMapping
AbstractHandlerMapping
の getCorsConfiguration
handler
- チェックするハンドラー(非 null
)。request
- 現在のリクエスト。null
protected abstract boolean isHandler(ClassSE<?> beanType)
beanType
- チェックされている Bean の型 @Nullable protected abstract T getMappingForMethod(MethodSE method, ClassSE<?> handlerType)
method
- マッピングを提供する方法 handlerType
- ハンドラー型、場合によってはメソッドの宣言クラスのサブ型 null
@DeprecatedSE protected SetSE<StringSE> getMappingPathPatterns(T mapping)
getDirectPaths(Object)
を介して非パターンマッピングを提供することに賛成 @Nullable protected abstract T getMatchingMapping(T mapping, HttpServletRequestEE request)
mapping
- 一致を取得するマッピング request
- 現在の HTTP サーブレットリクエスト null
protected abstract ComparatorSE<T> getMappingComparator(HttpServletRequestEE request)
request
- 現在のリクエスト null
)