|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.AbstractResource org.springframework.osgi.io.OsgiBundleResource
public class OsgiBundleResource
Resource implementation for OSGi environments.
Lazy evaluation of the resource will be used. This implementation allows resource location inside:osgibundle:
/BUNDLE_URL_PREFIX
prefix is being used or none is specified. This space cotnains the bundle jar
and its attached fragments.osgibundlejar:
/BUNDLE_JAR_URL_PREFIX
is specified. This space contains just the bundle jar.ResourceUtils.CLASSPATH_URL_PREFIX
is
encountered. This space contains the bundle classpath, namely the bundle jar,
its attached fragments and imported packages.bundleentry:
and bundleresource:
under Equinox, bundle:
under Knopflefish and Felix, etc..) are supported. Resources outside the OSGi
space (file:
, http:
, etc..) are supported as
well as the path is being resolved to an URL
.
If no prefix is specified, the bundle space will be used for
locating a resource.
Note: When the bundle space (bundle jar and
its attached fragments) is being searched, multiple URLs can be found but
this implementation will return only the first one. Consider using
OsgiBundleResourcePatternResolver
to retrieve all entries.
Field Summary | |
---|---|
static String |
BUNDLE_JAR_URL_PREFIX
Prefix for searching only the bundle raw jar. |
static String |
BUNDLE_URL_PREFIX
Prefix for searching inside the owning bundle space. |
Constructor Summary | |
---|---|
OsgiBundleResource(Bundle bundle,
String path)
Constructs a new OsgiBundleResource instance. |
Method Summary | |
---|---|
Resource |
createRelative(String relativePath)
Returns a resource relative to this resource. |
boolean |
equals(Object obj)
This implementation compares the underlying bundle and path locations. |
String |
getDescription()
This implementation returns a description that includes the bundle location. |
File |
getFile()
Returns a File handle for this resource. |
String |
getFilename()
Returns the filename of this resources. |
InputStream |
getInputStream()
Returns an InputStream to this resource. |
URL |
getURL()
Locates the resource in the underlying bundle based on the prefix, if it exists. |
int |
hashCode()
This implementation returns the hash code of the underlying class path location. |
Methods inherited from class org.springframework.core.io.AbstractResource |
---|
exists, getURI, isOpen, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String BUNDLE_URL_PREFIX
public static final String BUNDLE_JAR_URL_PREFIX
Constructor Detail |
---|
public OsgiBundleResource(Bundle bundle, String path)
OsgiBundleResource
instance.
bundle
- OSGi bundle used by this resourcepath
- resource path inside the bundle.Method Detail |
---|
public InputStream getInputStream() throws IOException
InputStream
to this resource. This
implementation opens an
InputStream for the given URL
. It sets the
UseCaches flag to false
, mainly to avoid jar file
locking on Windows.
- Returns:
- input stream to the underlying resource
- Throws:
IOException
- if the stream could not be opened- See Also:
URL.openConnection()
,
URLConnection.setUseCaches(boolean)
,
URLConnection.getInputStream()
public URL getURL() throws IOException
getURL
in interface Resource
getURL
in class AbstractResource
IOException
- if the resource cannot be resolved as URL, i.e. if
the resource is not available as descriptorBundle.getEntry(String)
,
Bundle.getResource(String)
public Resource createRelative(String relativePath)
OsgiBundleResource
, applying the given path relative
to the path of the underlying resource of this descriptor.
createRelative
in interface Resource
createRelative
in class AbstractResource
relativePath
- the relative path (relative to this resource)
IOException
- if the relative resource cannot be determinedStringUtils.applyRelativePath(String,
String)
public String getFilename()
getFilename
in interface Resource
getFilename
in class AbstractResource
StringUtils.getFilename(String)
public File getFile() throws IOException
File
handle for this resource.
getFile
in interface Resource
getFile
in class AbstractResource
IOException
- if the resource cannot be resolved as absolute file
path, i.e. if the resource is not available in a file systempublic String getDescription()
public boolean equals(Object obj)
equals
in class AbstractResource
public int hashCode()
hashCode
in class AbstractResource
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |