/** * Create a StepInvoker from an instance of a class annotated with @Handler * @param handlerInstance */ public HandlerClassInvokerFactory(Object handlerInstance) { Objects.requireNonNull(handlerInstance, "Handler instance cannot be null"); this.handlerInstance = handlerInstance; Class<?> handlerClazz = handlerInstance.getClass(); Handler handlerAnnotation = handlerClazz.getAnnotation(Handler.class); this.handlerName = handlerAnnotation == null ? handlerClazz.getName() : handlerAnnotation.value(); }
private Object getHandlerResource(String resourceName, Iterable<Object> handlerInstances) { Object o = null; String handlerName = resourceName.substring(ChorusResource.handlerPrefix.length()); for ( Object handlerInstance : handlerInstances) { Handler h = handlerInstance.getClass().getAnnotation(Handler.class); if ( handlerName.trim().toLowerCase().equals(h.value().trim().toLowerCase())) { o = handlerInstance; break; } } if ( o == null) { log.warn("Could not find a handler named " + handlerName + " to inject field annotated @ChorusResource(\"handler." + handlerName + "\", missing Uses: statement?"); } return o; }
public void createFeatureScopedHandlers() throws Exception { for (Class handlerClass : orderedHandlerClasses) { //create a new SCENARIO scoped handler Handler handlerAnnotation = (Handler) handlerClass.getAnnotation(Handler.class); if (handlerAnnotation.scope() != Scope.SCENARIO) { //feature or unmanaged Object handler = createAndInitHandlerInstance(handlerClass); featureScopedHandlers.put(handlerClass, handler); log.debug("Created new feature scoped handler: " + handlerAnnotation.value()); } } }
for (Class handlerClass : classes) { Handler f = (Handler) handlerClass.getAnnotation(Handler.class); String handlerName = f.value(); if (handlerNameToHandlerClass.containsKey(handlerName)) { String currentHandler = handlerNameToHandlerClass.get(handlerName).getName();