fnug.resource
Interface Bundle

All Known Implementing Classes:
DefaultBundle

public interface Bundle

Bundles are entities responsible for resolving and building Resource. A bundle can be though of as a package where several resources that logically form a unit are contained. It is envisages that bundles are typically shipped as jars with the bundle configuration as part of the jar.

Author:
Martin Algesten

Field Summary
static Pattern BUNDLE_ALLOWED_CHARS
          Chars allowed in a bundle name [a-zA-Z0-9_]+.
 
Method Summary
 boolean checkModified()
          Checks whether this bundle is modified by calling checkModified() on the getResourceCollections().
 BundleConfig getConfig()
          Returns the config that this bundle was built from.
 JSLintWrapper getJsLinter()
          Returns the configured JSLint instance for the bundle.
 long getLastModified()
          Returns the last modified date of this bundle which comprises the most recent date of the getConfig() and all the getResourceCollections() resources last modified dates.
 String getName()
          The name of this bundle.
 ResourceCollection[] getResourceCollections()
          Each bundle configures up a number of resources (files) that comprises the bundle, see BundleConfig.files().
 Resource resolve(String path)
          Resolves a resource under this bundle's base path (see BundleConfig.basePath() Resource.getBasePath().
 

Field Detail

BUNDLE_ALLOWED_CHARS

static final Pattern BUNDLE_ALLOWED_CHARS
Chars allowed in a bundle name [a-zA-Z0-9_]+.

Method Detail

getConfig

BundleConfig getConfig()
Returns the config that this bundle was built from.

Returns:
the config of the bundle.

getName

String getName()
The name of this bundle.

Returns:
the name

resolve

Resource resolve(String path)
Resolves a resource under this bundle's base path (see BundleConfig.basePath() Resource.getBasePath(). The bundle returns the corresponding Resource regardless of whether it exists or not (never return null). If the underlying file does not exist, the resource returned have an empty array of bytes in Resource.getBytes() and a Resource.getLastModified() of -1.

Parameters:
path - The path to resolve under this bundle. This must never start with /. See Resource.getPath().
Returns:
the resolved resource, never null.

getResourceCollections

ResourceCollection[] getResourceCollections()
Each bundle configures up a number of resources (files) that comprises the bundle, see BundleConfig.files(). Each of these resources may in turn have dependencies on other resources, potentially from other bundles. This method returns an array where each element holds resolved dependent resources for a bundle, the order is important, since that's the resolved order in which the resources/bundles must be loaded to satisfy the dependency chains.

Returns:
An ordered array of a resource collection per bundle for resolved file dependencies.

getLastModified

long getLastModified()
Returns the last modified date of this bundle which comprises the most recent date of the getConfig() and all the getResourceCollections() resources last modified dates.

Returns:
when the bundle was last modified.

checkModified

boolean checkModified()
Checks whether this bundle is modified by calling checkModified() on the getResourceCollections(). This does not call checkModified() on the BundleConfig.configResource() since that is being checked by the Resolver. If any resource is found to have changed, the built getResourceCollections() are dropped and (lazily) rebuilt.

Returns:
true if any resource has changed.

getJsLinter

JSLintWrapper getJsLinter()
Returns the configured JSLint instance for the bundle. Only returns a value if BundleConfig.jsLintArgs() is an non-empty array.



Copyright © 2012. All Rights Reserved.