@Component
public class HandlerUtil
extends java.lang.Object
implements org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Handler
annotationConstructor and Description |
---|
HandlerUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
clearCachedHandlers() |
static <H,T> java.util.List<H> |
getHandlersForType(java.lang.Class<H> handlerType,
java.lang.Class<T> type)
Retrieves a List of all registered components from the Context that are of the passed
handlerType and one or more of the following is true:
The handlerType is annotated as a
Handler that supports the passed type
The passed type is null - this effectively returns all components of the passed
handlerType
The returned handlers are ordered in the list based upon the order property. |
static java.lang.Integer |
getOrderOfHandler(java.lang.Class<?> handlerClass)
Utility method to return the order attribute of the
Handler annotation on the passed
class. |
static <H,T> H |
getPreferredHandler(java.lang.Class<H> handlerType,
java.lang.Class<T> type)
Retrieves the preferred Handler for a given handlerType and type.
|
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
public static void clearCachedHandlers()
public static <H,T> java.util.List<H> getHandlersForType(java.lang.Class<H> handlerType, java.lang.Class<T> type)
Handler
that supports the passed typehandlerType
- Indicates the type of class to returntype
- Indicates the type that the given handlerType must support (or null for any)public static <H,T> H getPreferredHandler(java.lang.Class<H> handlerType, java.lang.Class<T> type)
public static java.lang.Integer getOrderOfHandler(java.lang.Class<?> handlerClass)
Handler
annotation on the passed
class. If the passed class does not have a Handler
annotation, a RuntimeException is
thrownhandlerClass
- public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent
in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Copyright © 2018 OpenMRS Inc.. All Rights Reserved.