context/src/main/java/org/netbeans/html/context/spi/Contexts.java
changeset 927 3eb54c43c5c3
parent 904 6505c38a43b3
child 1057 b547f8f663f5
     1.1 --- a/context/src/main/java/org/netbeans/html/context/spi/Contexts.java	Fri Dec 12 12:37:58 2014 +0100
     1.2 +++ b/context/src/main/java/org/netbeans/html/context/spi/Contexts.java	Mon Jan 26 19:28:18 2015 +0100
     1.3 @@ -46,7 +46,9 @@
     1.4  import java.lang.annotation.Retention;
     1.5  import java.lang.annotation.RetentionPolicy;
     1.6  import java.lang.annotation.Target;
     1.7 +import java.util.HashSet;
     1.8  import java.util.ServiceLoader;
     1.9 +import java.util.Set;
    1.10  import net.java.html.BrwsrCtx;
    1.11  import org.netbeans.html.context.impl.CtxImpl;
    1.12  
    1.13 @@ -112,12 +114,19 @@
    1.14          } catch (SecurityException ex) {
    1.15              l = null;
    1.16          }
    1.17 +        Set<Class<?>> classes = new HashSet<Class<?>>();
    1.18          for (Provider cp : ServiceLoader.load(Provider.class, l)) {
    1.19 +            if (!classes.add(cp.getClass())) {
    1.20 +                continue;
    1.21 +            }
    1.22              cp.fillContext(cb, requestor);
    1.23              found = true;
    1.24          }
    1.25          try {
    1.26              for (Provider cp : ServiceLoader.load(Provider.class, Provider.class.getClassLoader())) {
    1.27 +                if (!classes.add(cp.getClass())) {
    1.28 +                    continue;
    1.29 +                }
    1.30                  cp.fillContext(cb, requestor);
    1.31                  found = true;
    1.32              }
    1.33 @@ -128,6 +137,9 @@
    1.34          }
    1.35          if (!found) {
    1.36              for (Provider cp : ServiceLoader.load(Provider.class)) {
    1.37 +                if (!classes.add(cp.getClass())) {
    1.38 +                    continue;
    1.39 +                }
    1.40                  cp.fillContext(cb, requestor);
    1.41                  found = true;
    1.42              }