private void addLocalHandlerClassSteps(List<Object> handlerInstances, CompositeStepInvokerProvider compositeStepProvider) { for ( Object handler : handlerInstances) { HandlerClassInvokerFactory f = new HandlerClassInvokerFactory(handler); compositeStepProvider.addChild(f); } }
/** * Add handler classes containing the step definitions to publish * This must be done before publish is called (or while the step publisher is disconnected) */ public void addHandlers(Object... handlers) { for ( Object handler : handlers) { //assert that this is a Handler checkValidHandlerType(handler); StepInvokerProvider invokerFactory = new HandlerClassInvokerFactory(handler); List<StepInvoker> invokers = invokerFactory.getStepInvokers(); if (invokers.isEmpty()) { Class<?> handlerClass = handler.getClass(); log.warn(String.format("Cannot export object of type (%s) it either: 1) Has no methods that declare the @Step annotation " + "2) Returns zero StepInvoker's from a StepInvokerProvider instance", handlerClass.getName())); } for ( StepInvoker i : invokers) { addStepInvoker(i); } } }
/** * @param patternPreProcessor - A function to perform a mapping on the patterns of all exported handler steps * @param handlers - Instances of handler classes which should be exported */ public ChorusHandlerJmxExporter(UnaryOperator<Pattern> patternPreProcessor, Object... handlers) { this.patternPreProcessor = patternPreProcessor; for ( Object handler : handlers) { //assert that this is a Handler checkValidHandlerType(handler); StepInvokerProvider invokerFactory = new HandlerClassInvokerFactory(handler); //Process the patterns if a step pattern pre processor is set //This mechanism lets the user transform the patterns of all steps exported by a component, for example if ( patternPreProcessor != DEFAULT_STEP_PATTERN_PREPROCESSOR) { invokerFactory = new PatternPreProcessingProvider(patternPreProcessor, invokerFactory); } List<StepInvoker> invokers = invokerFactory.getStepInvokers(); if (invokers.isEmpty()) { Class<?> handlerClass = handler.getClass(); log.warn(String.format("Cannot export object of type (%s) it either: 1) Has no methods that declare the @Step annotation " + "2) Returns zero StepInvoker's from a StepInvokerProvider instance", handlerClass.getName())); } for ( StepInvoker i : invokers) { addStepInvoker(i); } } }