• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / scriptable-dataset / 630

22 Mar 2026 02:24AM UTC coverage: 90.323%. Remained the same
630

push

github

hazendaz
[mvn] Update maven wrapper

23 of 26 branches covered (88.46%)

Branch coverage included in aggregate %.

89 of 98 relevant lines covered (90.82%)

0.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/src/main/java/de/gmorling/scriptabledataset/handlers/StandardHandlerConfig.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 * Copyright 2011-2026 Hazendaz
4
 */
5
package de.gmorling.scriptabledataset.handlers;
6

7
import java.util.ArrayList;
8
import java.util.Collections;
9
import java.util.HashMap;
10
import java.util.List;
11
import java.util.Map;
12
import java.util.ServiceConfigurationError;
13
import java.util.ServiceLoader;
14

15
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
17

18
/**
19
 * Manages handlers, that shall always executed for scripts in a given language. These standard handlers will be called
20
 * <b>before</b> any custom handlers in the pre invocation and <b>after</b> any custom handlers in the post invocation.
21
 */
22
public class StandardHandlerConfig {
23

24
    /** The standard handlers. */
25
    private static Map<String, List<ScriptInvocationHandler>> standardHandlers;
26

27
    /**
28
     * Instantiates a new standard handler config.
29
     */
30
    private StandardHandlerConfig() {
31
        // Prevent Instantiation
32
    }
33

34
    static {
35

36
        standardHandlers = new HashMap<>();
1✔
37

38
        ServiceLoader<ScriptInvocationHandler> serviceLoader = ServiceLoader.load(ScriptInvocationHandler.class);
1✔
39
        try {
40
            for (ScriptInvocationHandler scriptInvocationHandler : serviceLoader) {
1✔
41

42
                List<ScriptInvocationHandler> handlersForLanguage = standardHandlers
1✔
43
                        .get(scriptInvocationHandler.getLanguageName());
1✔
44

45
                if (handlersForLanguage == null) {
1!
46
                    handlersForLanguage = new ArrayList<>();
1✔
47
                    standardHandlers.put(scriptInvocationHandler.getLanguageName(), handlersForLanguage);
1✔
48
                }
49

50
                handlersForLanguage.add(scriptInvocationHandler);
1✔
51
            }
1✔
52
        } catch (ServiceConfigurationError error) {
×
53
            Logger logger = LoggerFactory.getLogger(StandardHandlerConfig.class);
×
54
            logger.error(
×
55
                    "Loading of standard script invocation handlers failed, most likely due to an unknown handler implementation given in META-INF/services {}",
56
                    ScriptInvocationHandler.class.getName());
×
57
            standardHandlers = Collections.emptyMap();
×
58
        }
1✔
59
    }
1✔
60

61
    /**
62
     * Gets the standard handlers by language.
63
     *
64
     * @param language
65
     *            the language
66
     *
67
     * @return the standard handlers by language
68
     */
69
    public static List<ScriptInvocationHandler> getStandardHandlersByLanguage(String language) {
70
        if (standardHandlers.containsKey(language)) {
1✔
71
            return Collections.unmodifiableList(standardHandlers.get(language));
1✔
72
        }
73
        return Collections.emptyList();
1✔
74
    }
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc