1 /*
2 * Copyright (C) 2012-2024 RRiBbit.org
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.rribbit.execution;
17
18 import java.util.Collection;
19 import java.util.stream.Collectors;
20
21 import org.rribbit.ListenerObject;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26 * This {@link AbstractListenerObjectExecutor} executes the {@link ListenerObject}s one after the other in the {@link Thread} of the caller.
27 *
28 * @author G.J. Schouten
29 *
30 */
31 public class SequentialListenerObjectExecutor extends AbstractListenerObjectExecutor {
32
33 private static final Logger log = LoggerFactory.getLogger(SequentialListenerObjectExecutor.class);
34
35 @Override
36 protected Collection<ExecutionResult> doExecuteListeners(Collection<ListenerObject> listenerObjects, Object... parameters) {
37
38 log.debug("Executing ListenerObjects in sequential order");
39 return listenerObjects
40 .stream()
41 .map(listenerObject -> this.executeSingleListenerObject(listenerObject, parameters))
42 .collect(Collectors.toList());
43 }
44 }