/** * Returns the context path. * * @param rootFile * @return context path */ private String getContextPath(Resource rootFile) { String contextPath = null; if (rootFile instanceof ServletContextResource) { ServletContextResource servletResource = (ServletContextResource) rootFile; contextPath = servletResource.getServletContext().getContextPath(); if ("/".equals(contextPath)) { contextPath = "/root"; } } else if (resources instanceof IScope) { contextPath = ((IScope) resources).getContextPath(); if (contextPath == null) { contextPath = "/root"; } } log.debug("Persistence context path: {}", contextPath); return contextPath; }
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
/** * Overridden version which checks for ServletContextResource * and uses <code>ServletContext.getResourcePaths</code> to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ protected Set doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); if (sc.getMajorVersion() > 2 || (sc.getMajorVersion() == 2 && sc.getMinorVersion() > 2)) { // Only try the following on Servlet containers >= 2.3: // ServletContext.getResourcePaths() is not available before that version. String fullPattern = scResource.getPath() + subPattern; Set result = CollectionFactory.createLinkedSetIfPossible(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } } return super.doFindPathMatchingFileResources(rootDirResource, subPattern); }