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

hazendaz / scriptable-dataset / #19

27 Aug 2023 02:10AM UTC coverage: 90.291%. Remained the same
#19

push

github

hazendaz
[pom] Override dbunit usage of ojdbc8 with latest 19.20.0.0

old one has a lot of extra junk

93 of 103 relevant lines covered (90.29%)

0.9 hits per line

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

77.27
/src/main/java/de/gmorling/scriptabledataset/handlers/StandardHandlerConfig.java
1
/*
2
 * scriptable-dataset (https://github.com/hazendaz/scriptable-dataset)
3
 *
4
 * Copyright 2011-2023 Hazendaz.
5
 *
6
 * All rights reserved. This program and the accompanying materials
7
 * are made available under the terms of The Apache Software License,
8
 * Version 2.0 which accompanies this distribution, and is available at
9
 * https://www.apache.org/licenses/LICENSE-2.0.txt
10
 *
11
 * Contributors:
12
 *     Gunnar Morling
13
 *     Hazendaz (Jeremy Landis).
14
 */
15
package de.gmorling.scriptabledataset.handlers;
16

17
import java.util.ArrayList;
18
import java.util.Collections;
19
import java.util.HashMap;
20
import java.util.Iterator;
21
import java.util.List;
22
import java.util.Map;
23
import java.util.ServiceConfigurationError;
24
import java.util.ServiceLoader;
25

26
import org.slf4j.Logger;
27
import org.slf4j.LoggerFactory;
28

29
/**
30
 * Manages handlers, that shall always executed for scripts in a given language. These standard handlers will be called
31
 * <b>before</b> any custom handlers in the pre invocation and <b>after</b> any custom handlers in the post invocation.
32
 *
33
 * @author Gunnar Morling
34
 */
35
public class StandardHandlerConfig {
36

37
    /** The standard handlers. */
38
    private static Map<String, List<ScriptInvocationHandler>> standardHandlers;
39

40
    /**
41
     * Instantiates a new standard handler config.
42
     */
43
    private StandardHandlerConfig() {
44
        // Prevent Instantiation
45
    }
46

47
    static {
48

49
        standardHandlers = new HashMap<>();
1✔
50

51
        ServiceLoader<ScriptInvocationHandler> serviceLoader = ServiceLoader.load(ScriptInvocationHandler.class);
1✔
52
        Iterator<ScriptInvocationHandler> iterator = serviceLoader.iterator();
1✔
53

54
        try {
55
            while (iterator.hasNext()) {
1✔
56

57
                ScriptInvocationHandler scriptInvocationHandler = iterator.next();
1✔
58

59
                List<ScriptInvocationHandler> handlersForLanguage = standardHandlers
1✔
60
                        .get(scriptInvocationHandler.getLanguageName());
1✔
61

62
                if (handlersForLanguage == null) {
1✔
63
                    handlersForLanguage = new ArrayList<>();
1✔
64
                    standardHandlers.put(scriptInvocationHandler.getLanguageName(), handlersForLanguage);
1✔
65
                }
66

67
                handlersForLanguage.add(scriptInvocationHandler);
1✔
68
            }
1✔
69
        } catch (ServiceConfigurationError error) {
×
70
            Logger logger = LoggerFactory.getLogger(StandardHandlerConfig.class);
×
71
            logger.error(
×
72
                    "Loading of standard script invocation handlers failed, most likely due to an unknown handler implementation given in META-INF/services {}",
73
                    ScriptInvocationHandler.class.getName());
×
74
            standardHandlers = Collections.emptyMap();
×
75
        }
1✔
76
    }
1✔
77

78
    /**
79
     * Gets the standard handlers by language.
80
     *
81
     * @param language
82
     *            the language
83
     *
84
     * @return the standard handlers by language
85
     */
86
    public static List<ScriptInvocationHandler> getStandardHandlersByLanguage(String language) {
87
        if (standardHandlers.containsKey(language)) {
1✔
88
            return Collections.unmodifiableList(standardHandlers.get(language));
1✔
89
        } else {
90
            return Collections.emptyList();
1✔
91
        }
92
    }
93
}
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