com.sun.xml.ws.transport.local.FileSystemResourceLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaxws-local-transport Show documentation
Show all versions of jaxws-local-transport Show documentation
Implementation of Local-Transport for JAX-WS RI, used mainly in tests
/*
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package com.sun.xml.ws.transport.local;
import com.sun.xml.ws.transport.http.ResourceLoader;
import jakarta.xml.ws.WebServiceException;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
/**
* {@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 {
try {
return new File(root+path).getCanonicalFile().toURL();
} catch(IOException ioe) {
throw new WebServiceException(ioe);
}
}
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;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy