public class MuleArtifactUrlConnection extends URLConnection
The syntax of a Mule Artifact URL is (current support for protocols under URL are described in SUPPORTED_PROTOCOLS):
muleartifact:<url>!/{entry}
Where "url" is targeting a ZIP type of file to be decompressed, and the subsequent N-1 elements in "{entry}" are zips
as well and the N element is the file to look for. That means the getInputStream() will open as many zips as
needed to look for the file.
valid samples:
muleartifact:file:/folder/mule-plugin.zip!/classes!/org/foo/echo/aResource.txt
muleartifact:file:/folder/mule-plugin.zip!/lib/test-jar-with-resources.jar!/test-resource-2.txt
invalid samples:
muleartifact:file:/folder/mule-plugin.zip
muleartifact:file:/folder/mule-plugin.zip!/
muleartifact:http:/folder/mule-plugin.zip!/classes/org/foo/echo/aResource.txt (protocol is 'http')
Notice that after the URL targeting the ZIP file, there must be several separators '!/' elements, due to the fact that this class is meant to open every ZIP until it finds out the expected file. TODO(fernandezlautaro): MULE-10892 at some moment this class should be strong enough to support any type of artifact.
| Modifier and Type | Field and Description |
|---|---|
static String |
CLASSES_FOLDER |
static String |
SEPARATOR |
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches| Constructor and Description |
|---|
MuleArtifactUrlConnection(URL url)
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
Given the
URL that was feed in the MuleArtifactUrlConnection(URL) constructor, it will validate
its format through the parseSpecs() method. |
InputStream |
getInputStream()
Returns an input stream that represents the element in the
url from the farthest SEPARATOR mark. |
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toStringpublic static final String SEPARATOR
public static final String CLASSES_FOLDER
public MuleArtifactUrlConnection(URL url)
public void connect()
throws IOException
URL that was feed in the MuleArtifactUrlConnection(URL) constructor, it will validate
its format through the parseSpecs() method.
If there aren't any problem during validation, it will store a ZIP file in artifactZip and all the
subsequent files that are accessible from that starting point.
connect in class URLConnectionIOException - if the first element is not a ZIP file, or if the protocol is not supported, or if it's
impossible to create a ZipFile from the parsed url, or if there's not at least a SEPARATOR
in the url.public InputStream getInputStream() throws IOException
url from the farthest SEPARATOR mark.
For the following URL samples:
muleartifact:file:/folder/mule-plugin.zip!/classes!/org/foo/echo/aResource.txt
muleartifact:file:/folder/mule-plugin.zip!/lib/test-jar-with-resources.jar!/test-resource-2.txt
The expected input streams will be the content of "org/foo/echo/aResource.txt" and "test-resource-2.txt"
respectively.
getInputStream in class URLConnectionurl from the farthest SEPARATOR mark.IOExceptionCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.