public EventProcessor getEventProcessor(String processorName){ return this.eventProcessingConfiguration .eventProcessor(processorName) .orElseThrow(() -> new RuntimeException("Processor not found")); }
/** * Returns the {@link EventProcessor} with the given {@code name} if present, matching the given * {@code expectedType}. * * @param name a {@link String} specifying the name of the {@link EventProcessor} to return * @param expectedType the type of the {@link EventProcessor} to return * @param <T> the type of the expected {@link EventProcessor} * @return an {@link Optional} referencing the {@link EventProcessor}, if present and of expected type */ default <T extends EventProcessor> Optional<T> eventProcessor(String name, Class<T> expectedType) { return eventProcessor(name).filter(expectedType::isInstance).map(expectedType::cast); }
/** * Returns the Event Processor with the given {@code name}, if present and of the given {@code expectedType}. * * @param name The name of the processor to return * @param expectedType The type of processor expected * @param <T> The type of processor expected * @return an Optional referencing the processor, if present and of expected type */ public <T extends EventProcessor> Optional<T> eventProcessor(String name, Class<T> expectedType) { return eventProcessor(name).filter(expectedType::isInstance).map(expectedType::cast); }
/** * Returns the {@link EventProcessor} with the given {@code name} if present, matching the given * {@code expectedType}. * * @param name a {@link String} specifying the name of the {@link EventProcessor} to return * @param expectedType the type of the {@link EventProcessor} to return * @param <T> the type of the expected {@link EventProcessor} * @return an {@link Optional} referencing the {@link EventProcessor}, if present and of expected type */ default <T extends EventProcessor> Optional<T> eventProcessor(String name, Class<T> expectedType) { return eventProcessor(name).filter(expectedType::isInstance).map(expectedType::cast); }
public EventProcessor getEventProcessor(String processorName){ return this.eventProcessingConfiguration .eventProcessor(processorName) .orElseThrow(() -> new RuntimeException("Processor not found")); }
/** * Register the given {@code interceptorBuilder} to build an Message Handling Interceptor for the Event Processor * with given {@code processorName}. * <p> * The {@code interceptorBuilder} may return {@code null}, in which case the return value is ignored. * * @param processorName The name of the processor to register the interceptor on * @param interceptorBuilder The function providing the interceptor to register, or {@code null} * @return event processing configuration for chaining purposes */ public EventProcessingConfiguration registerHandlerInterceptor(String processorName, Function<Configuration, MessageHandlerInterceptor<? super EventMessage<?>>> interceptorBuilder) { if (configuration != null) { eventProcessor(processorName).ifPresent(eventProcessor -> eventProcessor .registerInterceptor(interceptorBuilder.apply(configuration))); } handlerInterceptorsBuilders.computeIfAbsent(processorName, k -> new ArrayList<>()) .add(interceptorBuilder); return this; }
/** * Returns the Event Processor with the given {@code name}, if present. This method also returns an unresolved * optional if the Processor was configured, but it hasn't been assigned any Event Handlers. * * @param name The name of the processor to return * @return an Optional referencing the processor, if present. * @deprecated use {@link EventProcessingConfiguration#eventProcessor(String)} instead */ @Deprecated public <T extends EventProcessor> Optional<T> getProcessor(String name) { Assert.state(config != null, () -> "Configuration is not initialized yet"); //noinspection unchecked return (Optional<T>) config.eventProcessingConfiguration().eventProcessor(name); }
/** * Returns the Event Processor with the given {@code name}, if present and of the given {@code expectedType}. This * method also returns an empty optional if the Processor was configured, but it hasn't been assigned any Event * Handlers. * * @param name The name of the processor to return * @param expectedType The type of processor expected * @param <T> The type of processor expected * @return an Optional referencing the processor, if present and of expected type. * @deprecated use {@link EventProcessingConfiguration#eventProcessor(String, Class)} instead */ @Deprecated public <T extends EventProcessor> Optional<T> getProcessor(String name, Class<T> expectedType) { Assert.state(config != null, () -> "Configuration is not initialized yet"); return config.eventProcessingConfiguration().eventProcessor(name, expectedType); }