com.sun.xml.ws.transport.local.FileSystemResourceLoader Maven / Gradle / Ivy
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at https://glassfish.dev.java.net/public/CDDLv1.0.html.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2006 Sun Microsystems Inc. All Rights Reserved
*/
package com.sun.xml.ws.transport.local;
import com.sun.xml.ws.transport.http.ResourceLoader;
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Set;
import java.util.HashSet;
/**
* {@link ResourceLoader} that deals with the expanded image of a war file
* on a file system.
*/
public final class FileSystemResourceLoader implements ResourceLoader {
/**
* The root of the exploded war file.
*/
private final File root;
public FileSystemResourceLoader(File root) {
this.root = root;
}
public URL getResource(String path) throws MalformedURLException {
return new File(root+path).toURL();
}
public URL getCatalogFile() throws MalformedURLException {
return getResource("/WEB-INF/jax-ws-catalog.xml");
}
public Set getResourcePaths(String path) {
Set r = new HashSet();
File[] files = new File(root+path).listFiles();
if (files == null) {
return null;
}
for( File f : files) {
if(f.isDirectory()) {
r.add(path+f.getName()+'/');
} else {
r.add(path+f.getName());
}
}
return r;
}
}