public class InterceptorService extends Object implements IInterceptorService, IInterceptorBroadcaster
| Constructor and Description |
|---|
InterceptorService()
Constructor which uses a default name of "default"
|
InterceptorService(String theName)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
callHooks(Pointcut thePointcut,
HookParams theParams)
Invoke registered interceptor hook methods for the given Pointcut.
|
Object |
callHooksAndReturnObject(Pointcut thePointcut,
HookParams theParams)
Invoke registered interceptor hook methods for the given Pointcut.
|
List<Object> |
getAllRegisteredInterceptors()
Returns all currently registered interceptors (excluding any thread local interceptors).
|
boolean |
hasHooks(Pointcut thePointcut)
Does this broadcaster have any hooks for the given pointcut?
|
boolean |
isThreadlocalInvokersEnabled()
Are threadlocal interceptors enabled on this registry (defaults to true)
|
void |
registerAnonymousInterceptor(Pointcut thePointcut,
IAnonymousInterceptor theInterceptor) |
void |
registerAnonymousInterceptor(Pointcut thePointcut,
int theOrder,
IAnonymousInterceptor theInterceptor) |
boolean |
registerInterceptor(Object theInterceptor)
Register an interceptor.
|
void |
registerInterceptors(Collection<?> theInterceptors) |
boolean |
registerThreadLocalInterceptor(Object theInterceptor)
Register an interceptor that will be used in a
ThreadLocal context. |
void |
setName(String theName) |
void |
setThreadlocalInvokersEnabled(boolean theThreadlocalInvokersEnabled)
Are threadlocal interceptors enabled on this registry (defaults to true)
|
void |
unregisterAllInterceptors()
Unregisters all registered interceptors.
|
boolean |
unregisterInterceptor(Object theInterceptor)
Unregister an interceptor.
|
void |
unregisterInterceptors(Collection<?> theInterceptors) |
void |
unregisterThreadLocalInterceptor(Object theInterceptor)
Unregisters a ThreadLocal interceptor
|
public InterceptorService()
public InterceptorService(String theName)
theName - The name for this registry (useful for troubleshooting)public boolean isThreadlocalInvokersEnabled()
public void setThreadlocalInvokersEnabled(boolean theThreadlocalInvokersEnabled)
public void registerAnonymousInterceptor(Pointcut thePointcut, IAnonymousInterceptor theInterceptor)
registerAnonymousInterceptor in interface IInterceptorServicepublic void registerAnonymousInterceptor(Pointcut thePointcut, int theOrder, IAnonymousInterceptor theInterceptor)
registerAnonymousInterceptor in interface IInterceptorServicepublic List<Object> getAllRegisteredInterceptors()
IInterceptorServicegetAllRegisteredInterceptors in interface IInterceptorServicepublic void unregisterAllInterceptors()
IInterceptorServicethread local interceptors.unregisterAllInterceptors in interface IInterceptorServicepublic void unregisterInterceptors(@Nullable Collection<?> theInterceptors)
unregisterInterceptors in interface IInterceptorServicepublic void registerInterceptors(@Nullable Collection<?> theInterceptors)
registerInterceptors in interface IInterceptorServicepublic boolean registerThreadLocalInterceptor(Object theInterceptor)
IInterceptorServiceThreadLocal context.
This means that events will only be broadcast to the given interceptor if
they were fired from the current thread.
Note that it is almost always desirable to call this method with a try-finally statement that removes the interceptor afterwards, since this can lead to memory leakage, poor performance due to ever-increasing numbers of interceptors, etc.
Note that most methods such as IInterceptorService.getAllRegisteredInterceptors() and
IInterceptorService.unregisterAllInterceptors() do not affect thread local interceptors
as they are kept in a separate list.
registerThreadLocalInterceptor in interface IInterceptorServicetheInterceptor - The interceptortrue if at least one valid hook method was found on this interceptorpublic void unregisterThreadLocalInterceptor(Object theInterceptor)
IInterceptorServiceunregisterThreadLocalInterceptor in interface IInterceptorServicetheInterceptor - The interceptorIInterceptorService.registerThreadLocalInterceptor(Object)public boolean registerInterceptor(Object theInterceptor)
IInterceptorServiceregisterInterceptor in interface IInterceptorServicetheInterceptor - The interceptor to registertrue if at least one valid hook method was found on this interceptorpublic boolean unregisterInterceptor(Object theInterceptor)
IInterceptorServiceunregisterInterceptor in interface IInterceptorServicetheInterceptor - The interceptor to unregistertrue if the interceptor was found and removedpublic Object callHooksAndReturnObject(Pointcut thePointcut, HookParams theParams)
IInterceptorBroadcastervoid or booleancallHooksAndReturnObject in interface IInterceptorBroadcasternullpublic boolean hasHooks(Pointcut thePointcut)
IInterceptorBroadcasterhasHooks in interface IInterceptorBroadcasterthePointcut - The poointcutpublic boolean callHooks(Pointcut thePointcut, HookParams theParams)
IInterceptorBroadcastercallHooks in interface IInterceptorBroadcasterfalse if any of the invoked hook methods returned
false, and returns true otherwise.Copyright © 2014–2019 University Health Network. All rights reserved.