public class WSClientUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BACKWARD_SLASH |
static String |
CLASSPATH_PROTOCOL
Protocol prefix for a URL that describes a resource on the classpath
|
static char |
DOT_CHAR |
static String |
FILE_PROTOCOL
Protocol prefix for a URL that describes a resource on the filesystem
|
static String |
FORWARD_SLASH |
static char |
FORWARD_SLASH_CHAR |
static Map<Object,String> |
s_classloaderTempMap
Map of ClassLoaders and their temp directories
NOTE: not intended for external use, please use the
WsClientUtil.getClassloadTempDir() |
static String |
s_processTempDir |
static Map<String,String> |
s_resourceMap
Map of extracted resources and their filenames
NOTE: not intended for external use
|
static String |
TEMP_DIR_PREFIX
Prefix for temp directories created by WSClient
|
static String |
TEMP_FILENAME_PREFIX
Prefix for temp filenames created by WSClient
|
Constructor and Description |
---|
WSClientUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
appendPath(String dirName,
String filePath)
Append an file/directory to an existing directory path, ensuring that a single
path separator character is placed between directory elements.
|
static String |
concat(String s1,
String s2)
Concatenate two strings
|
static Map |
constructClientAPI(Class clazz,
String packageName,
String operationName) |
static boolean |
copyResource(Class<?> portTypeClass,
String targetFile,
String resource)
Copy a resource from the classpath to a temp file.
|
static int |
copyStream(InputStream inputStream,
OutputStream outputStream)
Copy the contents from an
InputStream to a OutputStream |
static String |
createTempDir(String baseTempDir,
String prefix)
Create a unique temp subdirectory in the given base subdirectory
|
static String |
ensureForwardSlashes(String path)
Ensure that a path (as string) uses slash as a path separator.
|
static String |
ensureTrailingSlash(String path)
Ensure that a path has a trailing path separator character.
|
static String |
extractHostURL(String endpointURL)
Extract the host portion of a web service endpoint url.
|
static String |
getBaseName(String filePath)
Extract the base filename (no path info) from a file/path string
|
static String |
getClassloaderTempDir(ClassLoader classLoader)
Create a temp subdirectory for a specific classloader
NOTE: this is to ensure different components have different temp subdirectories
|
static String |
getOsTempDir()
Get the temp directory specified by the OS
|
static String |
getProcessTempDir()
Get or create a temp directory unique to this process
NOTE: necessary for generated a unique temp directory where multiple processes are
using the WSClient library
|
protected static String |
getResourceMapKey(String url,
Class<?> portType) |
static String |
processURL(String url,
Class<?> portTypeClass)
Process a resource URL.
|
static String[] |
processURLs(String[] mapURLs,
Class<?> portTypeClass)
Process an array of resource URLs.
|
static void |
reloadResource(Class<?> portTypeClass) |
static String |
removeStartingSlash(String path)
Remove the trailing forward slash path separator character from a path string
|
static boolean |
removeWsdlFromCache(String wsdlURL,
Class<?> portTypeClass)
Remove a WSDL from the Glue cache and extracted resource cache
|
static String |
stripClasspathProtocol(String url)
Strip the 'classpath:' protocol prefix from a URL string
|
static String |
stripLastSegment(String path)
Extract the last segments of a path string (using the forward slash as a path separator)
For example, the path c:/folder1/folder2 will return the value 'folder2'.
|
static String |
translateSlashToDot(String str)
For a given path as string, convert any slash path separators into dot characters.
|
public static final String FORWARD_SLASH
public static final char FORWARD_SLASH_CHAR
public static final char DOT_CHAR
public static final String BACKWARD_SLASH
public static final String TEMP_DIR_PREFIX
public static final String TEMP_FILENAME_PREFIX
public static final String CLASSPATH_PROTOCOL
public static final String FILE_PROTOCOL
public static Map<String,String> s_resourceMap
public static String s_processTempDir
public static String getBaseName(String filePath)
filePath
- the file/path URL to extract from as a stringpublic static String appendPath(String dirName, String filePath)
dirName
- the directory path to append to (as string)filePath
- the file or directory name to append to the directory pathpublic static String ensureTrailingSlash(String path)
path
- the path to ensure has a trailing path separatorpublic static String ensureForwardSlashes(String path)
path
- the path to ensure contains only slashes as the path separator, a null path will be ignoredpublic static String translateSlashToDot(String str)
str
- the path as a stringpublic static String concat(String s1, String s2)
s1
- base string to appear firsts2
- second string to be appended to the firstpublic static String removeStartingSlash(String path)
path
- the path to be processedpublic static String stripLastSegment(String path)
path
- the path extract frompublic static int copyStream(InputStream inputStream, OutputStream outputStream) throws IOException
InputStream
to a OutputStream
inputStream
- The source input stream to copy fromoutputStream
- the target output stream to copy toIOException
public static boolean copyResource(Class<?> portTypeClass, String targetFile, String resource) throws IOException
portTypeClass
- A Class in the same package as the resource to be loaded. This is
usually a web service interface class and a .wsdl or .map file is
expected to be in the same package.targetFile
- The name of the file to created in a temp subdirectoryresource
- URL of the resource to be copied to a temp directory, not included the
URL protocol.IOException
public static boolean removeWsdlFromCache(String wsdlURL, Class<?> portTypeClass)
wsdlURL
- the URL of the .wsdl resource to remove from the resource cacheportTypeClass
- the web service interface classpublic static String stripClasspathProtocol(String url)
url
- the URL string to processpublic static String processURL(String url, Class<?> portTypeClass)
url
- the resource URLportTypeClass
- the web service interface class associated with this resource URL (for caching purposes)public static String[] processURLs(String[] mapURLs, Class<?> portTypeClass)
#processURLs( String, Class )
mapURLs
- an array of resource URL stringsportTypeClass
- public static String getProcessTempDir() throws IOException
IOException
public static String getOsTempDir() throws IOException
IOException
public static String createTempDir(String baseTempDir, String prefix) throws IOException
baseTempDir
- the base temp subdirectoryprefix
- the prefix to use when generating a unique subdirectory nameIOException
public static String getClassloaderTempDir(ClassLoader classLoader) throws IOException
classLoader
- the classloader to generate a unique temp subdirectory forIOException
public static String extractHostURL(String endpointURL) throws WSClientException
endpointURL
- the web service endpoint URL as stringWSClientException
public static void reloadResource(Class<?> portTypeClass)