Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util.resource

public Class URLResourceFactory

extends Object
implements ResourceFactory
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.resource.ResourceFactory
Imports
java.io.IOException, .InputStream, java.lang.ref.Cleaner, java.net.MalformedURLException, .URI, .URL, .URLConnection, java.nio.channels.Channels, .ReadableByteChannel, java.nio.file.Path, java.time.Instant, java.util.concurrent.atomic.AtomicReference, java.util.function.Consumer, org.eclipse.jetty.util.FileID, .IO, .URIUtil, org.eclipse.jetty.util.thread.AutoLock, org.slf4j.Logger, .LoggerFactory

ResourceFactory for java.net.URL based resources.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private int
pack-priv static Consumer<InputStream>
private int
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the connect timeout
getConnectTimeout
()

URL Connection Connect Timeout

public int

Returns:

the read timeout
getReadTimeout
()

URL Connection Read Timeout.

public boolean
public Resource
newResource(final URI
A URI.
uri
)

Implements org.eclipse.jetty.util.resource.ResourceFactory.newResource.

Construct a resource from a uri.

public void
setConnectTimeout(int connectTimeout)

public void
setReadTimeout(int readTimeout)

public void
setUseCaches(boolean useCaches)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectTimeoutback to summary
private int connectTimeout
ON_SWEEP_LISTENERback to summary
pack-priv static Consumer<InputStream> ON_SWEEP_LISTENER
readTimeoutback to summary
private int readTimeout
useCachesback to summary
private boolean useCaches

Constructor Detail

URLResourceFactoryback to summary
public URLResourceFactory()

Method Detail

getConnectTimeoutback to summary
public int getConnectTimeout()

URL Connection Connect Timeout

Returns:int

the connect timeout

See Also
URLConnection#getConnectTimeout()
getReadTimeoutback to summary
public int getReadTimeout()

URL Connection Read Timeout.

Returns:int

the read timeout

See Also
URLConnection#getReadTimeout()
isUseCachesback to summary
public boolean isUseCaches()
newResourceback to summary
public Resource newResource(final URI uri)

Implements org.eclipse.jetty.util.resource.ResourceFactory.newResource.

Doc from org.eclipse.jetty.util.resource.ResourceFactory.newResource.

Construct a resource from a uri.

Parameters
uri:URI

A URI.

Returns:Resource

A Resource object, or null if uri points to a location that does not exist.

Annotations
@Override
setConnectTimeoutback to summary
public void setConnectTimeout(int connectTimeout)
setReadTimeoutback to summary
public void setReadTimeout(int readTimeout)
setUseCachesback to summary
public void setUseCaches(boolean useCaches)
org.eclipse.jetty.util.resource back to summary

private Class URLResourceFactory.URLResource

extends Resource
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final Cleaner
private URLConnection
private final int
private URLResourceFactory.URLResource.InputStreamReference
private final AutoLock
private static final Logger
private final int
private final URI
private final URL
private final boolean

Constructor Summary

AccessConstructor and Description
public
URLResource(URI uri, int connectTimeout, int readTimeout, boolean useCaches)

Method Summary

Modifier and TypeMethod and Description
protected boolean
public boolean
public String
getFileName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getFileName.

The file name of the resource.

public String
getName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getName.

The full name of the resource.

public Path
getPath()

Implements abstract org.eclipse.jetty.util.resource.Resource.getPath.

Return the Path corresponding to this resource.

public URI
getRealURI()

Overrides org.eclipse.jetty.util.resource.Resource.getRealURI.

The real URI of the resource.

public URI
getURI()

Implements abstract org.eclipse.jetty.util.resource.Resource.getURI.

URI representing the resource.

public boolean
isContainedIn(Resource
the containing resource
container
)

Overrides org.eclipse.jetty.util.resource.Resource.isContainedIn.

Return true if this resource is contained in the Resource r, either because r is a folder or a jar file or any form of resource capable of containing other resources.

public boolean
isDirectory()

Implements abstract org.eclipse.jetty.util.resource.Resource.isDirectory.

Return true if resource represents a directory of potential resources.

public boolean
isReadable()

Implements abstract org.eclipse.jetty.util.resource.Resource.isReadable.

True if the resource is readable.

public Instant
lastModified()

Overrides org.eclipse.jetty.util.resource.Resource.lastModified.

The time the resource was last modified.

public long
length()

Overrides org.eclipse.jetty.util.resource.Resource.length.

Length of the resource.

public InputStream
newInputStream()

Overrides org.eclipse.jetty.util.resource.Resource.newInputStream.

Creates a new input stream to the resource.

public ReadableByteChannel
public Resource
resolve(String
the encoded subUriPath
subUriPath
)

Implements abstract org.eclipse.jetty.util.resource.Resource.resolve.

Resolve an existing Resource.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jetty.util.resource.Resource:
containscopyTodumpensureDirExistsgetAllResourcesgetPathToisAliasiteratorlistresolveDifferentFileSystem

Field Detail

CLEANERback to summary
private static final Cleaner CLEANER
connectionback to summary
private URLConnection connection
connectTimeoutback to summary
private final int connectTimeout
inputStreamReferenceback to summary
private URLResourceFactory.URLResource.InputStreamReference inputStreamReference
lockback to summary
private final AutoLock lock
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.util.resource.Resource.LOG.

readTimeoutback to summary
private final int readTimeout
uriback to summary
private final URI uri
urlback to summary
private final URL url
useCachesback to summary
private final boolean useCaches

Constructor Detail

URLResourceback to summary
public URLResource(URI uri, int connectTimeout, int readTimeout, boolean useCaches) throws MalformedURLException

Method Detail

checkConnectionback to summary
protected boolean checkConnection() throws IOException
existsback to summary
public boolean exists()

Overrides org.eclipse.jetty.util.resource.Resource.exists.

Doc from org.eclipse.jetty.util.resource.Resource.exists.

Equivalent to Files#exists(Path, LinkOption...) with the following parameters: getPath() and LinkOption#NOFOLLOW_LINKS.

Returns:boolean

true if the represented resource exists.

Annotations
@Override
getFileNameback to summary
public String getFileName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getFileName.

Doc from org.eclipse.jetty.util.resource.Resource.getFileName.

The file name of the resource.

This is the last segment of the path.

Returns:String

the filename of the resource, or "" if there are no path segments (eg: path of "/"), or null if resource cannot determine a filename.

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getName.

Doc from org.eclipse.jetty.util.resource.Resource.getName.

The full name of the resource.

Returns:String

the full name of the resource, or null if there is no name for the resource.

Annotations
@Override
getPathback to summary
public Path getPath()

Implements abstract org.eclipse.jetty.util.resource.Resource.getPath.

Doc from org.eclipse.jetty.util.resource.Resource.getPath.

Return the Path corresponding to this resource.

Returns:Path

the path or null if there is no Path representation.

Annotations
@Override
getRealURIback to summary
public URI getRealURI()

Overrides org.eclipse.jetty.util.resource.Resource.getRealURI.

Doc from org.eclipse.jetty.util.resource.Resource.getRealURI.

The real URI of the resource.

If this Resource is an alias, (isAlias()), this URI will be different from getURI(), and will point to the real name/location of the Resource.

Returns:URI

The real URI location of this resource.

Annotations
@Override
getURIback to summary
public URI getURI()

Implements abstract org.eclipse.jetty.util.resource.Resource.getURI.

Doc from org.eclipse.jetty.util.resource.Resource.getURI.

URI representing the resource.

Returns:URI

a URI representing the given resource, or null if there is no URI representation of the resource.

Annotations
@Override
isContainedInback to summary
public boolean isContainedIn(Resource container)

Overrides org.eclipse.jetty.util.resource.Resource.isContainedIn.

Doc from org.eclipse.jetty.util.resource.Resource.isContainedIn.

Return true if this resource is contained in the Resource r, either because r is a folder or a jar file or any form of resource capable of containing other resources.

Parameters
container:Resource

the containing resource

Returns:boolean

true if this Resource is contained, false otherwise

Annotations
@Override
isDirectoryback to summary
public boolean isDirectory()

Implements abstract org.eclipse.jetty.util.resource.Resource.isDirectory.

Doc from org.eclipse.jetty.util.resource.Resource.isDirectory.

Return true if resource represents a directory of potential resources.

Returns:boolean

true if the represented resource is a container/directory.

Annotations
@Override
isReadableback to summary
public boolean isReadable()

Implements abstract org.eclipse.jetty.util.resource.Resource.isReadable.

Doc from org.eclipse.jetty.util.resource.Resource.isReadable.

True if the resource is readable.

Returns:boolean

true if the represented resource exists, and can read from.

Annotations
@Override
lastModifiedback to summary
public Instant lastModified()

Overrides org.eclipse.jetty.util.resource.Resource.lastModified.

Doc from org.eclipse.jetty.util.resource.Resource.lastModified.

The time the resource was last modified.

Returns:Instant

the last modified time instant, or Instant#EPOCH if unable to obtain last modified.

Annotations
@Override
lengthback to summary
public long length()

Overrides org.eclipse.jetty.util.resource.Resource.length.

Doc from org.eclipse.jetty.util.resource.Resource.length.

Length of the resource.

Returns:long

the length of the resource in bytes, or -1L if unable to provide a size (such as a directory resource).

Annotations
@Override
newInputStreamback to summary
public InputStream newInputStream() throws IOException

Overrides org.eclipse.jetty.util.resource.Resource.newInputStream.

Doc from org.eclipse.jetty.util.resource.Resource.newInputStream.

Creates a new input stream to the resource.

Returns:InputStream

an input stream to the resource or null if one is not available.

Annotations
@Override
Exceptions
IOException:
if there is a problem opening the input stream
newReadableByteChannelback to summary
public ReadableByteChannel newReadableByteChannel() throws IOException

Overrides org.eclipse.jetty.util.resource.Resource.newReadableByteChannel.

Doc from org.eclipse.jetty.util.resource.Resource.newReadableByteChannel.

Readable ByteChannel for the resource.

Returns:ReadableByteChannel

a readable java.nio.channels.ByteChannel to the resource or null if one is not available.

Annotations
@Override
Exceptions
IOException:
if unable to open the readable bytechannel for the resource.
resolveback to summary
public Resource resolve(String subUriPath)

Implements abstract org.eclipse.jetty.util.resource.Resource.resolve.

Doc from org.eclipse.jetty.util.resource.Resource.resolve.

Resolve an existing Resource.

Parameters
subUriPath:String

the encoded subUriPath

Returns:Resource

an existing Resource representing the requested subUriPath, or null if resource does not exist.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jetty.util.resource back to summary

private Class URLResourceFactory.URLResource.InputStreamReference

extends AtomicReference<InputStream>
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

InputStreamReferenceback to summary
public InputStreamReference(InputStream initialValue)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override