@Override
public void createWebResourceSet(ResourceSetType type, String webAppMount,
String base, String archivePath, String internalPath) {
ArrayList<WebResourceSet> resourceList;
WebResourceSet resourceSet;
switch (type) {
case PRE:
resourceList = preResources;
break;
case CLASSES_JAR:
resourceList = classResources;
break;
case RESOURCE_JAR:
resourceList = jarResources;
break;
case POST:
resourceList = postResources;
break;
default:
throw new IllegalArgumentException(
sm.getString("standardRoot.createUnknownType", type));
}
// This implementation assumes that the base for all resources will be a
// file.
File file = new File(base);
if (file.isFile()) {
if (archivePath != null) {
// Must be a JAR nested inside a WAR if archivePath is non-null
resourceSet = new JarWarResourceSet(this, webAppMount, base,
archivePath, internalPath);
} else if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
resourceSet = new JarResourceSet(this, webAppMount, base,
internalPath);
} else {
resourceSet = new FileResourceSet(this, webAppMount, base,
internalPath);
}
} else if (file.isDirectory()) {
resourceSet =
new DirResourceSet(this, webAppMount, base, internalPath);
} else {
throw new IllegalArgumentException(
sm.getString("standardRoot.createInvalidFile", file));
}
if (type.equals(ResourceSetType.CLASSES_JAR)) {
resourceSet.setClassLoaderOnly(true);
}
resourceList.add(resourceSet);
}