
Package ca.uhn.fhir.interceptor.executor
Class BaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
java.lang.Object
ca.uhn.fhir.interceptor.executor.BaseInterceptorService<POINTCUT>
- All Implemented Interfaces:
IBaseInterceptorBroadcaster<POINTCUT>,IBaseInterceptorService<POINTCUT>
- Direct Known Subclasses:
InterceptorService
public abstract class BaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
extends Object
implements IBaseInterceptorService<POINTCUT>, IBaseInterceptorBroadcaster<POINTCUT>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected classNested classes/interfaces inherited from interface ca.uhn.fhir.interceptor.api.IBaseInterceptorBroadcaster
IBaseInterceptorBroadcaster.IInterceptorFilterHook, IBaseInterceptorBroadcaster.IInvoker -
Constructor Summary
ConstructorsConstructorDescriptionBaseInterceptorService(Class<POINTCUT> thePointcutType) Constructor which uses a default name of "default"BaseInterceptorService(Class<POINTCUT> thePointcutType, String theName) Deprecated, for removal: This API element is subject to removal in a future version.The name parameter is not used for anything -
Method Summary
Modifier and TypeMethodDescriptionbooleancallHooks(POINTCUT thePointcut, HookParams theParams) Invoke registered interceptor hook methods for the given Pointcut.callHooksAndReturnObject(POINTCUT thePointcut, HookParams theParams) Invoke registered interceptor hook methods for the given Pointcut.static ObjectcallInvokers(IPointcut thePointcut, HookParams theParams, List<IBaseInterceptorBroadcaster.IInvoker> invokers) protected static <T extends Annotation>
Optional<T> findAnnotation(AnnotatedElement theObject, Class<T> theHookClass) Returns all currently registered interceptors (excluding any thread local interceptors).protected Class<?> getInvokersForPointcut(POINTCUT thePointcut) Returns a list of all invokers registered for the given pointcut.booleanDoes this broadcaster have any hooks for the given pointcut?static booleanhaveAppropriateParams(IPointcut thePointcut, HookParams theParams) Only call this when assertions are enabled, it's expensiveprotected voidregisterAnonymousInterceptor(POINTCUT thePointcut, Object theInterceptor, BaseInterceptorService.BaseInvoker theInvoker) booleanregisterInterceptor(Object theInterceptor) Register an interceptor.voidregisterInterceptors(Collection<?> theInterceptors) protected abstract Optional<BaseInterceptorService<POINTCUT>.HookDescriptor> scanForHook(Method nextMethod) voidDeprecated, for removal: This API element is subject to removal in a future version.This value is not used anywherevoidsetWarnOnInterceptorWithNoHooks(boolean theWarnOnInterceptorWithNoHooks) Should a warning be issued if an interceptor is registered and it has no hooksunion(List<List<IBaseInterceptorBroadcaster.IInvoker>> theInvokersLists) First argument must be the global invoker list!!voidUnregisters all anonymous interceptors (i.e. all interceptors registered withregisterAnonymousInterceptor)voidUnregisters all registered interceptors.booleanunregisterInterceptor(Object theInterceptor) Unregister an interceptor.voidunregisterInterceptors(Collection<?> theInterceptors) voidunregisterInterceptorsIf(Predicate<Object> theShouldUnregisterFunction) Unregisters all interceptors that are indicated by the given callback function returningtrueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ca.uhn.fhir.interceptor.api.IBaseInterceptorBroadcaster
ifHasCallHooks, ifHasCallHooksAndReturnObject, runWithFilterHooks, runWithFilterHooksMethods inherited from interface ca.uhn.fhir.interceptor.api.IBaseInterceptorService
hasRegisteredInterceptor
-
Constructor Details
-
BaseInterceptorService
Constructor which uses a default name of "default" -
BaseInterceptorService
@Deprecated(since="8.0.0", forRemoval=true) public BaseInterceptorService(Class<POINTCUT> thePointcutType, String theName) Deprecated, for removal: This API element is subject to removal in a future version.The name parameter is not used for anythingConstructor- Parameters:
theName- The name for this registry (useful for troubleshooting)
-
-
Method Details
-
setWarnOnInterceptorWithNoHooks
Should a warning be issued if an interceptor is registered and it has no hooks -
setName
Deprecated, for removal: This API element is subject to removal in a future version.This value is not used anywhere -
registerAnonymousInterceptor
protected void registerAnonymousInterceptor(POINTCUT thePointcut, Object theInterceptor, BaseInterceptorService.BaseInvoker theInvoker) -
getAllRegisteredInterceptors
Description copied from interface:IBaseInterceptorServiceReturns all currently registered interceptors (excluding any thread local interceptors).- Specified by:
getAllRegisteredInterceptorsin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
-
unregisterAllInterceptors
Description copied from interface:IBaseInterceptorServiceUnregisters all registered interceptors.- Specified by:
unregisterAllInterceptorsin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
-
unregisterInterceptors
- Specified by:
unregisterInterceptorsin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
-
registerInterceptors
- Specified by:
registerInterceptorsin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
-
unregisterAllAnonymousInterceptors
Description copied from interface:IBaseInterceptorServiceUnregisters all anonymous interceptors (i.e. all interceptors registered withregisterAnonymousInterceptor)- Specified by:
unregisterAllAnonymousInterceptorsin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
-
unregisterInterceptorsIf
Description copied from interface:IBaseInterceptorServiceUnregisters all interceptors that are indicated by the given callback function returningtrue- Specified by:
unregisterInterceptorsIfin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>
-
registerInterceptor
Description copied from interface:IBaseInterceptorServiceRegister an interceptor. This method has no effect if the given interceptor is already registered.- Specified by:
registerInterceptorin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>- Parameters:
theInterceptor- The interceptor to register- Returns:
- Returns
trueif at least one valid hook method was found on this interceptor
-
unregisterInterceptor
Description copied from interface:IBaseInterceptorServiceUnregister an interceptor. This method has no effect if the given interceptor is not already registered.- Specified by:
unregisterInterceptorin interfaceIBaseInterceptorService<POINTCUT extends Enum<POINTCUT> & IPointcut>- Parameters:
theInterceptor- The interceptor to unregister- Returns:
- Returns
trueif the interceptor was found and removed
-
callHooksAndReturnObject
Description copied from interface:IBaseInterceptorBroadcasterInvoke registered interceptor hook methods for the given Pointcut. This method should only be called for pointcuts that return a type other thanvoidorboolean- Specified by:
callHooksAndReturnObjectin interfaceIBaseInterceptorBroadcaster<POINTCUT extends Enum<POINTCUT> & IPointcut>- Returns:
- Returns the object returned by the first hook method that did not return
null
-
hasHooks
Description copied from interface:IBaseInterceptorBroadcasterDoes this broadcaster have any hooks for the given pointcut? -
getBooleanReturnType
-
callHooks
Description copied from interface:IBaseInterceptorBroadcasterInvoke registered interceptor hook methods for the given Pointcut. -
getInvokersForPointcut
Returns a list of all invokers registered for the given pointcut. The list is ordered by the invoker order (specified on theInterceptor.order()andHook.order()values.- Specified by:
getInvokersForPointcutin interfaceIBaseInterceptorBroadcaster<POINTCUT extends Enum<POINTCUT> & IPointcut>- Returns:
- The list returned by this method will always be a newly created list, so it will be stable and can be modified.
-
haveAppropriateParams
Only call this when assertions are enabled, it's expensive -
scanForHook
protected abstract Optional<BaseInterceptorService<POINTCUT>.HookDescriptor> scanForHook(Method nextMethod) -
callInvokers
public static Object callInvokers(IPointcut thePointcut, HookParams theParams, List<IBaseInterceptorBroadcaster.IInvoker> invokers) -
union
public static List<IBaseInterceptorBroadcaster.IInvoker> union(List<List<IBaseInterceptorBroadcaster.IInvoker>> theInvokersLists) First argument must be the global invoker list!! -
findAnnotation
protected static <T extends Annotation> Optional<T> findAnnotation(AnnotatedElement theObject, Class<T> theHookClass)
-