|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfnug.resource.AbstractResource
fnug.resource.DefaultResource
public class DefaultResource
Default file resource implementation. Relies on Class.getResource(String)
to do its
magic. The class also handles the case where the class loader resolved resource is inside a
jar-file. That jar file is then unpacked into a temporary directory and the file last modified is
read from there.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class fnug.resource.AbstractResource |
---|
AbstractResource.Entry |
Field Summary | |
---|---|
static int |
DEFAULT_CHECK_MODIFIED_INTERVAL
Default interval for checking the modified time. |
Fields inherited from class fnug.resource.AbstractResource |
---|
CONTENT_TYPE_TEXT_CSS, CONTENT_TYPE_TEXT_JAVASCRIPT |
Constructor Summary | |
---|---|
DefaultResource(String basePath,
String path)
Creates a new resource setting the base path and path. |
|
DefaultResource(String basePath,
String path,
int checkModifiedInterval)
Constructs setting base path path and interval for checking. |
Method Summary | |
---|---|
protected String |
decode(String url)
The URLClassLoader.getResource() encodes the returned URL as UTF-8, but it will not encode the '+' sign (encoding done via internal sun.net.www.ParseUtil). |
protected URL |
doGetResourceURL(String fullPath)
Returns the URL of the resource. |
protected File |
extractJarFile(URL url)
|
List<String> |
findRequiresTags()
Scans the resource for the sequence " * @requires " which makes this resource depend on others. |
static URL |
getResourceURL(String fullPath)
Returns the URL of the resource. |
protected AbstractResource.Entry |
readEntry()
Reads the entry from the class loader using Class.getResource(String) . |
protected long |
readLastModified()
Returns the last modified date of the file. |
protected boolean |
readLastModifiedAllowed()
Tells if we are allowed to check the last modified date. |
Methods inherited from class fnug.resource.AbstractResource |
---|
checkModified, ensureReadEntry, getBasePath, getBytes, getContentType, getFullPath, getLastModified, getPath, isCss, isJs, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_CHECK_MODIFIED_INTERVAL
Constructor Detail |
---|
public DefaultResource(String basePath, String path, int checkModifiedInterval)
basePath
- The base path of the resource. See AbstractResource.getBasePath()
.path
- The path of the resource. See AbstractResource.getPath()
.checkModifiedInterval
- the interval in millisecond that we are to check the resource last modified date.
Any sooner checks will just returned the previously read value. A value of 0 will
disable modified checks.public DefaultResource(String basePath, String path)
DEFAULT_CHECK_MODIFIED_INTERVAL
for checking modified times.
basePath
- The base path of the resource. See AbstractResource.getBasePath()
.path
- The path of the resource. See AbstractResource.getPath()
.Method Detail |
---|
protected AbstractResource.Entry readEntry()
Class.getResource(String)
. Also handles
the case where that resource is in a jar file.
readEntry
in class AbstractResource
protected URL doGetResourceURL(String fullPath)
public static URL getResourceURL(String fullPath)
protected long readLastModified()
readLastModified
in class AbstractResource
protected boolean readLastModifiedAllowed()
protected String decode(String url)
url
- url to decode
protected File extractJarFile(URL url) throws IOException
IOException
public List<String> findRequiresTags()
* @requires
" which makes this resource depend on others. This
will only happen if the resource is found to be text, that is Resource.getContentType()
must be
text/xxx
, such as text/javascript
.
Example:
/**
* @requires some/other/javascript.js
* @requires some/other/styles.css
*/
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |