T
- ハンドラーメソッドを受信リクエストに一致させるために必要な条件を含む HandlerMethod
のマッピング。public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMapping implements InitializingBean
HandlerMethod
の間のマッピングを定義する HandlerMapping
実装の抽象基本クラス。 登録された各ハンドラーメソッドについて、マッピング型 <T>
の詳細を定義するサブクラスで一意のマッピングが維持されます。
logger
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, 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 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 abstract SetSE<StringSE> | getMappingPathPatterns(T mapping) マッピングに含まれる URL パスを抽出して返します。 |
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 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 | unregisterMapping(T mapping) 指定されたマッピングを登録解除します。 |
adaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfigurations, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initApplicationContext, initInterceptors, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
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 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
- ハンドラーメソッドとマッピングを含む読み取り専用マップ。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 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
protected abstract SetSE<StringSE> getMappingPathPatterns(T mapping)
@Nullable protected abstract T getMatchingMapping(T mapping, HttpServletRequestEE request)
mapping
- 一致を取得するマッピング request
- 現在の HTTP サーブレットリクエスト null
protected abstract ComparatorSE<T> getMappingComparator(HttpServletRequestEE request)
request
- 現在のリクエスト null
)