public abstract class CacheAspectSupport extends AbstractCacheInvoker implements BeanFactoryAware, InitializingBean, SmartInitializingSingleton
CacheInterceptor や AspectJ アスペクトなど、アスペクトをキャッシュするための基本クラス。これにより、基になる Spring キャッシングインフラストラクチャを簡単に使用して、任意のアスペクトシステムのアスペクトを実装できます。
サブクラスは、このクラスのメソッドを正しい順序で呼び出すロールを果たします。
Strategy デザインパターンを使用します。CacheResolver 実装は、使用する実際のキャッシュを解決し、CacheOperationSource はキャッシュ操作を決定するために使用されます。
キャッシュアスペクトは、その CacheResolver と CacheOperationSource がシリアライズ可能である場合、シリアライズ可能です。
| 修飾子と型 | クラスと説明 |
|---|---|
protected class | CacheAspectSupport.CacheOperationContext |
protected static class | CacheAspectSupport.CacheOperationMetadata 特定の呼び出しに依存しないキャッシュ操作のメタデータは、キャッシュの適切な候補になります。 |
| コンストラクターと説明 |
|---|
CacheAspectSupport() |
| 修飾子と型 | メソッドと説明 |
|---|---|
void | afterPropertiesSet() 指定されたすべての Bean プロパティを設定した(そして BeanFactoryAware と ApplicationContextAware を満たした)後に BeanFactory によって呼び出されます。 |
void | afterSingletonsInstantiated() シングルトン事前インスタンス化フェーズの終わりに呼び出され、すべての通常のシングルトン Bean がすでに作成されていることを保証します。 |
protected void | clearMetadataCache() キャッシュされたメタデータをクリアします。 |
protected ObjectSE | execute(CacheOperationInvoker invoker, ObjectSE target, MethodSE method, ObjectSE[] args) |
protected <T> T | getBean(StringSE beanName, ClassSE<T> expectedType) 指定された名前と型の Bean を返します。 |
protected CacheAspectSupport.CacheOperationMetadata | getCacheOperationMetadata(CacheOperation operation, MethodSE method, ClassSE<?> targetClass) 指定された操作の CacheAspectSupport.CacheOperationMetadata を返します。 |
CacheOperationSource | getCacheOperationSource() このキャッシュアスペクトの CacheOperationSource を返します。 |
CacheResolver | getCacheResolver() このキャッシュアスペクトが委譲するデフォルトの CacheResolver を返します。 |
protected CollectionSE<? extends Cache> | getCaches(CacheOperationInvocationContext<CacheOperation> context, CacheResolver cacheResolver) |
KeyGenerator | getKeyGenerator() このキャッシュアスペクトが委譲するデフォルトの KeyGenerator を返します。 |
protected CacheAspectSupport.CacheOperationContext | getOperationContext(CacheOperation operation, MethodSE method, ObjectSE[] args, ObjectSE target, ClassSE<?> targetClass) |
protected ObjectSE | invokeOperation(CacheOperationInvoker invoker) 基本的な操作を実行し(通常はキャッシュミスの場合)、呼び出しの結果を返します。 |
protected StringSE | methodIdentification(MethodSE method, ClassSE<?> targetClass) ロギングで使用するためにこのメソッドの文字列表現を返す簡易メソッド。 |
void | setBeanFactory(BeanFactory beanFactory) 含まれている BeanFactory を CacheManager およびその他のサービス検索用に設定します。 |
void | setCacheManager(CacheManager cacheManager) デフォルト CacheResolver の作成に使用する CacheManager を設定します。 |
void | setCacheOperationSources(CacheOperationSource... cacheOperationSources) キャッシュ属性の検索に使用される 1 つ以上のキャッシュ操作ソースを設定します。 |
void | setCacheResolver(CacheResolver cacheResolver) 操作に特定のキャッシュリゾルバーが設定されていない場合に、このキャッシュアスペクトが委譲するデフォルトの CacheResolver を設定します。 |
void | setKeyGenerator(KeyGenerator keyGenerator) 操作に特定のキージェネレーターが設定されていない場合、このキャッシュアスペクトが委譲するデフォルトの KeyGenerator を設定します。 |
doClear, doEvict, doGet, doPut, getErrorHandler, setErrorHandlercloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEprotected final Log logger
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources)
CompositeCacheOperationSource を使用して集約されます。@Nullable public CacheOperationSource getCacheOperationSource()
public void setKeyGenerator(KeyGenerator keyGenerator)
KeyGenerator を設定します。 デフォルトは SimpleKeyGenerator です
public KeyGenerator getKeyGenerator()
KeyGenerator を返します。public void setCacheManager(CacheManager cacheManager)
public void setCacheResolver(@Nullable CacheResolver cacheResolver)
CacheResolver を設定します。デフォルトのリゾルバーは、名前とデフォルトのキャッシュマネージャーに対してキャッシュを解決します。
@Nullable public CacheResolver getCacheResolver()
CacheResolver を返します。public void setBeanFactory(BeanFactory beanFactory)
BeanFactory を CacheManager およびその他のサービス検索用に設定します。BeanFactoryAware の setBeanFactory beanFactory - 所有 BeanFactory(非 null)。Bean は、ファクトリのメソッドをすぐに呼び出すことができます。BeanInitializationExceptionpublic void afterPropertiesSet()
InitializingBeanこのメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されている場合にのみ可能な初期化を実行し、設定ミスの場合に例外をスローできます。
InitializingBean の afterPropertiesSet public void afterSingletonsInstantiated()
SmartInitializingSingletonListableBeanFactory.getBeansOfType(java.lang.Class<T>) 呼び出しは、ブートストラップ中に偶発的な副作用を引き起こしません。 注意 : このコールバックは、BeanFactory ブートストラップ後にオンデマンドで遅延初期化されたシングルトン Bean ではトリガーされず、他の Bean スコープでもトリガーされません。意図されたブートストラップセマンティクスのみを使用する Bean には慎重に使用してください。
SmartInitializingSingleton の afterSingletonsInstantiated protected StringSE methodIdentification(MethodSE method, ClassSE<?> targetClass)
method - 興味のある方法 targetClass - メソッドが存在するクラス ClassUtils.getQualifiedMethodName(java.lang.reflect.Method)protected CollectionSE<? extends Cache> getCaches(CacheOperationInvocationContext<CacheOperation> context, CacheResolver cacheResolver)
protected CacheAspectSupport.CacheOperationContext getOperationContext(CacheOperation operation, MethodSE method, ObjectSE[] args, ObjectSE target, ClassSE<?> targetClass)
protected CacheAspectSupport.CacheOperationMetadata getCacheOperationMetadata(CacheOperation operation, MethodSE method, ClassSE<?> targetClass)
CacheAspectSupport.CacheOperationMetadata を返します。 操作に使用する CacheResolver および KeyGenerator を解決します。
operation - 操作 method - 操作が呼び出されるメソッド targetClass - ターゲット型 protected <T> T getBean(StringSE beanName, ClassSE<T> expectedType)
CacheOperation で名前によって参照されるサービスを解決するために使用されます。beanName - 操作で定義されている Bean の名前 expectedType - Bean の型 NoSuchBeanDefinitionException - そのような Bean が存在しない場合 CacheOperation.keyGenerator, CacheOperation.cacheManager, CacheOperation.cacheResolverprotected void clearMetadataCache()
@Nullable protected ObjectSE execute(CacheOperationInvoker invoker, ObjectSE target, MethodSE method, ObjectSE[] args)
protected ObjectSE invokeOperation(CacheOperationInvoker invoker)
CacheOperationInvoker.ThrowableWrapper でラップされます。例外は処理または変更できますが、CacheOperationInvoker.ThrowableWrapper でもラップする必要があります。invoker - キャッシュされている操作を処理する呼び出し元 CacheOperationInvoker.invoke()