public abstract class AbstractView extends ObjectSE implements View, BeanNameAware, ApplicationContextAware
View
実装の基本クラス。修飾子と型 | フィールドと説明 |
---|---|
protected Log | logger サブクラスで利用可能なロガー。 |
static StringSE | REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME Bean ファクトリの RequestDataValueProcessor のよく知られた名前。 |
BINDING_CONTEXT_ATTRIBUTE
コンストラクターと説明 |
---|
AbstractView() |
AbstractView(ReactiveAdapterRegistry reactiveAdapterRegistry) |
修飾子と型 | メソッドと説明 |
---|---|
protected RequestContext | createRequestContext(ServerWebExchange exchange, MapSE<StringSE, ObjectSE> model) 指定された属性名で公開する RequestContext を作成します。 |
protected StringSE | formatViewName() |
ApplicationContext | getApplicationContext() |
StringSE | getBeanName() ビューの名前を取得します。 |
CharsetSE | getDefaultCharset() コンテンツ型に文字セットが含まれていない場合に使用されるデフォルトの文字セットを取得します。 |
protected reactor.core.publisher.Mono<MapSE<StringSE, ObjectSE>> | getModelAttributes(MapSE<StringSE,?> model, ServerWebExchange exchange) レンダリングに使用するモデルを準備します。 |
StringSE | getRequestContextAttribute() このビューの RequestContext 属性の名前を取得します(ある場合)。 |
protected RequestDataValueProcessor | getRequestDataValueProcessor() 使用する RequestDataValueProcessor を取得します。 |
ListSE<MediaType> | getSupportedMediaTypes() このビューでサポートされている構成済みメディア型を取得します。 |
protected ApplicationContext | obtainApplicationContext() 実際に使用するために ApplicationContext を取得します。 |
reactor.core.publisher.Mono<VoidSE> | render(MapSE<StringSE,?> model, MediaType contentType, ServerWebExchange exchange) レンダリングするモデルを準備します。 |
protected abstract reactor.core.publisher.Mono<VoidSE> | renderInternal(MapSE<StringSE, ObjectSE> renderAttributes, MediaType contentType, ServerWebExchange exchange) ビューを実際にレンダリングするには、サブクラスでこのメソッドを実装する必要があります。 |
protected reactor.core.publisher.Mono<VoidSE> | resolveAsyncAttributes(MapSE<StringSE, ObjectSE> model) 使用すべきではありません。 5.1.8 では、このメソッドはまだ呼び出されていますが、何もしません。代わりに resolveAsyncAttributes(Map, ServerWebExchange) を使用してください。これの後に呼び出され、実際の作業を行います。 |
protected reactor.core.publisher.Mono<VoidSE> | resolveAsyncAttributes(MapSE<StringSE, ObjectSE> model, ServerWebExchange exchange) |
void | setApplicationContext(ApplicationContext applicationContext) このオブジェクトが実行される ApplicationContext を設定します。 |
void | setBeanName(StringSE beanName) ビューの名前を設定します。 |
void | setDefaultCharset(CharsetSE defaultCharset) このビューのデフォルトの文字セットを設定します。コンテンツ型に文字セットが含まれていない場合に使用されます。 |
void | setRequestContextAttribute(StringSE requestContextAttribute) このビューの RequestContext 属性の名前を設定します。 |
void | setSupportedMediaTypes(ListSE<MediaType> supportedMediaTypes) このビューでサポートされるメディア型を設定します。 |
StringSE | toString() |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
isRedirectView
public static final StringSE REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME
protected final Log logger
public AbstractView()
public AbstractView(ReactiveAdapterRegistry reactiveAdapterRegistry)
public void setSupportedMediaTypes(ListSE<MediaType> supportedMediaTypes)
デフォルトは "text/html;charset=UTF-8"
です。
public ListSE<MediaType> getSupportedMediaTypes()
View
の getSupportedMediaTypes
public void setDefaultCharset(CharsetSE defaultCharset)
public CharsetSE getDefaultCharset()
public void setRequestContextAttribute(@Nullable StringSE requestContextAttribute)
RequestContext
属性の名前を設定します。 デフォルトはなし(null
)です。
@Nullable public StringSE getRequestContextAttribute()
RequestContext
属性の名前を取得します(ある場合)。public void setBeanName(@Nullable StringSE beanName)
フレームワークコードは、ビューを構築するときにこれを呼び出す必要があります。
BeanNameAware
の setBeanName
beanName
- ファクトリ内の Bean の名前。この名前は、ファクトリで使用される実際の Bean 名であり、最初に指定した名前とは異なる場合があります。特に内部 Bean 名の場合、実際の Bean 名は "#..." サフィックスを追加することで一意になります。必要に応じて、BeanFactoryUtils.originalBeanName(String)
メソッドを使用して、元の Bean 名(サフィックスなし)を抽出します。public void setApplicationContext(@Nullable ApplicationContext applicationContext)
ApplicationContextAware
通常の Bean プロパティの設定後、ただし InitializingBean.afterPropertiesSet()
またはカスタム init メソッドなどの init コールバックの前に呼び出されます。ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
、ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
および MessageSourceAware
の後に呼び出されます(該当する場合)。
ApplicationContextAware
の setApplicationContext
applicationContext
- このオブジェクトによって使用される ApplicationContext オブジェクト BeanInitializationException
@Nullable public ApplicationContext getApplicationContext()
protected final ApplicationContext obtainApplicationContext()
ApplicationContext
を取得します。ApplicationContext
(非 null
)IllegalStateExceptionSE
- ApplicationContext が入手できない場合 getApplicationContext()
public reactor.core.publisher.Mono<VoidSE> render(@Nullable MapSE<StringSE,?> model, @Nullable MediaType contentType, ServerWebExchange exchange)
View
の render
model
- 属性名をキーとして、対応するモデルオブジェクトを値として持つマップ (空のモデルの場合、マップは null
にすることもできます)contentType
- レンダリングするために選択されたコンテンツ型。supported media types
のいずれかと一致する必要があります exchange
- 現在の交換 Mono
protected reactor.core.publisher.Mono<MapSE<StringSE,ObjectSE>> getModelAttributes(@Nullable MapSE<StringSE,?> model, ServerWebExchange exchange)
デフォルトの実装では、モデルと静的属性を含む結合出力マップが作成され、前者が優先されます。
protected reactor.core.publisher.Mono<VoidSE> resolveAsyncAttributes(MapSE<StringSE,ObjectSE> model, ServerWebExchange exchange)
ReactiveAdapterRegistry
を使用して、非同期属性を Mono<T>
または Mono<List<T>>
に適応させ、実際の値に解決するのを待ちます。返された Mono<Void>
が完了すると、モデルの非同期属性は、対応する解決された値に置き換えられます。Mono
の結果 @DeprecatedSE protected reactor.core.publisher.Mono<VoidSE> resolveAsyncAttributes(MapSE<StringSE,ObjectSE> model)
resolveAsyncAttributes(Map, ServerWebExchange)
を使用してください。これはこのメソッドの後に呼び出され、実際の作業を行います。ReactiveAdapterRegistry
を使用して、非同期属性を Mono<T>
または Mono<List<T>>
に適応させ、実際の値に解決するのを待ちます。返された Mono<Void>
が完了すると、モデルの非同期属性は対応する解決された値に置き換えられます。Mono
protected RequestContext createRequestContext(ServerWebExchange exchange, MapSE<StringSE,ObjectSE> model)
RequestContext
を作成します。 デフォルトの実装では、指定された交換とモデルの標準 RequestContext
インスタンスを作成します。
サブクラスでオーバーライドして、カスタムインスタンスを作成できます。
exchange
- 現在の交換 model
- 動的な値が静的な属性よりも優先される、結合された出力マップ(決して null
ではない)RequestContext
インスタンス setRequestContextAttribute(java.lang.String)
@Nullable protected RequestDataValueProcessor getRequestDataValueProcessor()
RequestDataValueProcessor
を取得します。 デフォルトの実装では、REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME
という名前の RequestDataValueProcessor
Bean を ApplicationContext
で探します。
RequestDataValueProcessor
、またはアプリケーションコンテキストに何もない場合は null
protected abstract reactor.core.publisher.Mono<VoidSE> renderInternal(MapSE<StringSE,ObjectSE> renderAttributes, @Nullable MediaType contentType, ServerWebExchange exchange)
renderAttributes
- 静的な属性よりも動的な値が優先される、結合された出力マップ(非 null
)contentType
- レンダリングするために選択されたコンテンツ型。サポートされているメディア型のいずれかと一致する必要があります exchange
- 現在の交換 Mono
public StringSE toString()
ObjectSE
の toStringSE
protected StringSE formatViewName()