public String determineRootDir(String location) {
        int prefixEnd = location.indexOf(':') + 1;
        int rootDirEnd = location.length();
        while (rootDirEnd > prefixEnd && isPattern(location.substring(prefixEnd, rootDirEnd))) {
            rootDirEnd = location.lastIndexOf('/', rootDirEnd - 2) + 1;
        }
        if (rootDirEnd == 0) {
            rootDirEnd = prefixEnd;
        }
        return location.substring(0, rootDirEnd);
    }
@Test
    public void testDetermineRoot() {
        AntPathMatcher matcher = new AntPathMatcher();
        assertEquals("org/apache/camel", matcher.determineRootDir("org/apache/camel"));
        assertEquals("org/apache/camel/", matcher.determineRootDir("org/apache/camel/"));
        assertEquals("org/apache/camel/", matcher.determineRootDir("org/apache/camel/*.xml"));
        assertEquals("WEB-INF/", matcher.determineRootDir("WEB-INF/*.xml"));

        // this is not a pattern
        assertEquals("org/apache/camel/mycamel.xml", matcher.determineRootDir("org/apache/camel/mycamel.xml"));
    }