@Component public class HandlerUtil extends 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> List<H> |
getHandlersForType(Class<H> handlerType,
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 Integer |
getOrderOfHandler(Class<?> handlerClass)
Utility method to return the order attribute of the
Handler annotation on the passed
class. |
static <H,T> H |
getPreferredHandler(Class<H> handlerType,
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> List<H> getHandlersForType(Class<H> handlerType, 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(Class<H> handlerType, Class<T> type)
handlerType
- the class that is an annotated Handler
to retrievetype
- the class that the annotated Handler
must supportpublic static Integer getOrderOfHandler(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 © 2024 OpenMRS Inc.. All rights reserved.