JooseX.Namespace.Depended.Resource - Abstract resource class
//mostly for subclassing only
Class("JooseX.Namespace.Depended.Resource.JavaScript", {
isa : JooseX.Namespace.Depended.Resource,
...
})
JooseX.Namespace.Depended.Resource
is an abstract resource class. Its not supposed to be used directly, instead you should use
one of its subclasses.
Object attachedTo
An arbitrary object to which this resource is attached (its a corresponding class in JooseX.Namespace.Depended)
String type
A type of resource - plain string.
JooseX.Namespace.Depended.Manager
maintain a collection of resource types, accessible
String token
A token of resource - plain string with arbitrary semantic. Each subclass should provide this semantic along with
token -> url
conertion method (locator)
String id
An id of resource - is computed as `type + '://' + token'
Boolean loading
A sign whether this resource is currently loading
Boolean loaded
A sign whether this resource is already loaded
Boolean ready
A sign whether this resource is considered ready. Resource is ready, when its loaded, and all its dependencies are ready.
String loadedFromURL
An url, from which the resource was loaded.
Array[Function] readyListeners
An array of functions, which will be called after this resource becomes ready. Functions will be called sequentially.
Object dependencies
An object containing the dependencies of this resource. Keys are the
id
s of resources and the values - the resource instances itself.
Function onBeforeReady
A function, which will be called, right after the all dependencies of the resource became ready, but before its own
readyListeners
will be called. It supposed to perform any needed additional actions to post-process the loaded resource.Function will receive two arguments - the 1st is the callback, which should be called when
onBeforeReady
will finish its work. 2nd is the resource instance.
r/w Number version
A version of this resource. Currently is handled as Number, this may change in future releases.
r/w Number requiredVersion
A requiredVersion version of this resource. Required here means the maximum version from all references to this resource.
void addDescriptor(Object|String descriptor)
Add the resource, described with passed descriptor as the dependency for this resource.
String|Array[String] getUrls()
Abstract method, will throw an exception if not overriden. It should return the array of urls (or a single url) from which this resource can be potentially loaded. This method should take into account the
use.paths
setting
void load(String url, Function onsuccess, Function onerror)
Abstract method, will throw an exception if not overriden. It should load the content of the resource from the passed
url
. If there was an error during loading (for example file not found) should not throw the exception. Instead, should call theonerror
continuation with it (exception instance).After successfull loading, should call the
onsuccess
continuation with the resource content as 1st argument, andurl
as 2nd:onsuccess(text, url)
void materialize(String resourceBlob, String url)
Abstract method, will throw an exception if not overriden. It should "materialize" the resource. The concrete semantic of this action is determined by resource nature. For example this method can create some tag in the DOM tree, or execute the code or something else.
Currently this method is supposed to operate synchronously, this may change in future releases.
Web page of this package: http://github.com/SamuraiJack/JooseX-Namespace-Depended-Resource/
General documentation for Joose: http://joose.github.com/Joose/
All complex software has bugs lurking in it, and this module is no exception.
Please report any bugs through the web interface at http://github.com/SamuraiJack/JooseX-Namespace-Depended-Resource/issues
Nickolay Platonov nplatonov@cpan.org
Copyright (c) 2009-2010, Nickolay Platonov
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.