@Test public void testFindDelegateType() throws Exception { Map<DelegateType, List<String>> delegateConfig = new LinkedHashMap<>(); delegateConfig.put(PARENT_ONLY, Arrays.asList( "foo.p2.*", "foo.p3.**")); delegateConfig.put(CHILD_ONLY, Arrays.asList( "foo.p2.p.*", "foo.p2.q.**", "foo.p3.**", "foo.p4.*")); assertEquals(PARENT_CHILD, LandClassLoader.findDelegateTypeInDelegateConfigs("A", delegateConfig, matcher)); assertEquals(PARENT_ONLY, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p2.A", delegateConfig, matcher)); assertEquals(CHILD_ONLY, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p2.p.A", delegateConfig, matcher)); assertEquals(PARENT_CHILD, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p2.p.pp.A", delegateConfig, matcher)); assertEquals(CHILD_ONLY, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p2.q.A", delegateConfig, matcher)); assertEquals(CHILD_ONLY, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p2.q.qq.A", delegateConfig, matcher)); assertEquals(PARENT_ONLY, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p3.A", delegateConfig, matcher)); assertEquals(PARENT_ONLY, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p3.p.A", delegateConfig, matcher)); assertEquals(CHILD_ONLY, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p4.A", delegateConfig, matcher)); assertEquals(PARENT_CHILD, LandClassLoader.findDelegateTypeInDelegateConfigs("foo.p4.p.A", delegateConfig, matcher)); }
static DelegateType findDelegateTypeInDelegateConfigs(String className, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher) { for (Map.Entry<DelegateType, List<String>> entry : delegateConfig.entrySet()) { if (matchPatterns(className, entry.getValue(), matcher)) { return entry.getKey(); } } return DelegateType.PARENT_CHILD; }
LandClassLoader extends URLClassLoader { static DelegateType findDelegateTypeInDelegateConfigs(String className, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher) { for (Map.Entry<DelegateType, List<String>> entry : delegateConfig.entrySet()) { if (matchPatterns(className, entry.getValue(), matcher)) { return entry.getKey(); } } return DelegateType.PARENT_CHILD; } }
LandClassLoader extends URLClassLoader { static DelegateType findDelegateTypeInDelegateConfigs(String className, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher) { for (Map.Entry<DelegateType, List<String>> entry : delegateConfig.entrySet()) { if (matchPatterns(className, entry.getValue(), matcher)) { return entry.getKey(); } } return DelegateType.PARENT_CHILD; } LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, ClassLoader parent);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher, ClassLoader parent); }
LandClassLoader extends URLClassLoader { static DelegateType findDelegateTypeInDelegateConfigs(String className, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher) { for (Map.Entry<DelegateType, List<String>> entry : delegateConfig.entrySet()) { if (matchPatterns(className, entry.getValue(), matcher)) { return entry.getKey(); } } return DelegateType.PARENT_CHILD; } LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, ClassLoader parent);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher, ClassLoader parent); @Override String toString(); }
LandClassLoader extends URLClassLoader { static DelegateType findDelegateTypeInDelegateConfigs(String className, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher) { for (Map.Entry<DelegateType, List<String>> entry : delegateConfig.entrySet()) { if (matchPatterns(className, entry.getValue(), matcher)) { return entry.getKey(); } } return DelegateType.PARENT_CHILD; } LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, ClassLoader parent);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher);  LandClassLoader(URL[] urls, Map<DelegateType, List<String>> delegateConfig, LandMatcher matcher, ClassLoader parent); @Override String toString(); static final String CLASS; }