|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.freecompany.brimstone.module.Module
public class Module
A module is a collection of components and dependencies as well as relevant meta data. A module is serialized as an XML document instance of the schema http://www.freecompany.org/namespace/brimstone/module which contains this information.
A component consists of a URI describing a resource, either as a URL or a Brimstone specific URI that can be resolved to a particular resource, and an optional component name. The component name can be used to reference a discrete component and defaults to the file name as interpreted from the URI or URL specification. Components are exposed by name in order to decouple the particular implementation version from it's final use. A component URI may reference another module definition. In this case, the module behaves as if the component module's component and dependency (as well as other) entries existed within the local module. Therefore accessing the component or dependency lists will return a superset of the components of both this module and it's component modules. Furthermore, alias lookups will resolve within both the current module and any component modules. A dependency consists of a URI matching the convention of a component declaration and has no associated name. All operations within this class assume that the provided descriptor has been validated against the schema. If this is not the case and the document is not valid, the behavior is undefined. In particularClassCastException
s
might be thrown from various methods that attempt to manipulate the document.
Field Summary | |
---|---|
protected java.net.URL |
base
|
protected static java.util.Map<java.lang.String,Module> |
cache
|
static java.lang.String |
CONTENT_TYPE
|
protected org.freecompany.util.xml.editor.XmlEditor |
editor
|
static java.lang.String[] |
EXTRACT_NAME
|
static java.lang.String |
NAMESPACE
|
protected static org.freecompany.util.multicaster.Notification |
notifier
|
protected java.util.List<Module> |
resolved
|
Constructor Summary | |
---|---|
Module(java.net.URL url)
Creates a new module from the given URL without resolving modules. |
|
Module(java.net.URL url,
boolean resolve)
Creates a new module from the given URL, optionally resolving component modules. |
|
Module(java.net.URLConnection connection)
Creates a {$link Module} by loading the XML content referenced by the provided connection. |
|
Module(java.net.URLConnection connection,
boolean resolve)
Creates a {$link Module} by loading the XML content referenced by the provided connection and optionally resolves all references. |
Method Summary | |
---|---|
static java.lang.String |
alias(java.lang.String uri)
Determines the proper alias name for a given fully qualified versioned artifact. |
java.net.URL |
getBase()
Retrieves the {$link URL} of this module descriptor. |
java.net.URL |
getComponent(java.lang.String alias)
Loads a component URL by alias. |
java.util.Collection<java.net.URL> |
getComponents()
Returns an Iterable collection of URL instances that refer to each
of the components of this module. |
java.util.Collection<java.net.URL> |
getDependencies()
Returns an Iterable collection of URL instances that refer to each
of the dependencies of this module. |
java.lang.String |
getExtension(java.lang.String namespace,
java.lang.String prefix,
java.lang.String path)
Returns a node containing the content of the extensions section of the descriptor for this module. |
org.w3c.dom.Element |
getExtensions()
Returns a node containing the content of the extensions section of the descriptor for this module. |
java.lang.String |
getJavadoc()
Retrieves a {$link String} containing the path to the Javadoc documentation for the code this module packages. |
java.lang.String |
getName()
Retrieves the name of this module. |
protected java.util.Collection<java.net.URL> |
getUrls(java.lang.String path)
|
java.lang.String |
getVersion()
Retrieves the version of this module. |
static java.lang.Object |
load(java.net.URL url)
Loads a module URL and any fragment part it may contain. |
void |
resolve()
Resolves component and dependent modules to enable fallthrough on alias lookups. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String NAMESPACE
public static final java.lang.String CONTENT_TYPE
public static final java.lang.String[] EXTRACT_NAME
protected static final org.freecompany.util.multicaster.Notification notifier
protected static java.util.Map<java.lang.String,Module> cache
protected final org.freecompany.util.xml.editor.XmlEditor editor
protected java.util.List<Module> resolved
protected java.net.URL base
Constructor Detail |
---|
public Module(java.net.URLConnection connection) throws java.io.IOException, org.xml.sax.SAXException
false
.
connection
- the connection from which to load the descriptor.
java.io.IOException
- if the content cannot be loaded.
org.xml.sax.SAXException
- if the content is not a valid XML document.public Module(java.net.URLConnection connection, boolean resolve) throws java.io.IOException, org.xml.sax.SAXException
connection
- the connection from which to load the descriptor.resolve
- flag indicating whether references should be initially resolved.
java.io.IOException
- if the content cannot be loaded.
org.xml.sax.SAXException
- if the content is not a valid XML document.public Module(java.net.URL url) throws java.io.IOException, org.xml.sax.SAXException
URL
without resolving modules. This constructor
behaves the same as calling {$link #Module( URL, boolean)} with the second parameter false
.
url
- URL
the url of the module definition to load.
java.io.IOException
- if the content cannot be loaded.
org.xml.sax.SAXException
- if the content is not a valid XML document.public Module(java.net.URL url, boolean resolve) throws java.io.IOException, org.xml.sax.SAXException
true
, any component URI
that points to a module definition will be preloaded and indexed
for use in resolving aliases. When resolved in this fashion, calls to getComponent( String alias)
will
automatically fallthrough to included component modules as well.
Note that this constructor does not simply pass the resolve flag to the next constructor. This is because the
base URL
must be set before attempting to resolve the module.
url
- URL
of the module definition to load.resolve
- flag indicating whether to resolve component modules.
java.io.IOException
org.xml.sax.SAXException
Method Detail |
---|
public java.net.URL getBase()
public java.lang.String getName()
public java.lang.String getVersion()
public java.lang.String getJavadoc()
public java.lang.String getExtension(java.lang.String namespace, java.lang.String prefix, java.lang.String path)
namespace
- the namespace of the extension.prefix
- the prefix within the document of this extension.path
- the prefixed path to the setting relative to the extensions element.
String
representing the extension setting at the given path.public org.w3c.dom.Element getExtensions()
Element
containing the extensions element.public java.net.URL getComponent(java.lang.String alias) throws java.net.MalformedURLException
URL
by alias. If this module has been resolved via the resolve()
method, this
call will fall through to component modules in the event that this module has no associated alias.
alias
- component alias to dereference.
URL
corresponding to the alias.
java.net.MalformedURLException
public java.util.Collection<java.net.URL> getComponents() throws java.net.MalformedURLException
Iterable
collection of URL
instances that refer to each
of the components of this module.
java.net.MalformedURLException
- if any of the module components is an invalid reference.public java.util.Collection<java.net.URL> getDependencies() throws java.net.MalformedURLException
Iterable
collection of URL
instances that refer to each
of the dependencies of this module.
java.net.MalformedURLException
- if any of the module dependencies is an invalid reference.public void resolve() throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
- if any of the module components or dependencies is an invalid reference.
java.io.IOException
- if an error occurs while caching the artifact.protected java.util.Collection<java.net.URL> getUrls(java.lang.String path) throws java.net.MalformedURLException
java.net.MalformedURLException
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String alias(java.lang.String uri)
public static java.lang.Object load(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException
URL
and any fragment part it may contain. If this URL
references
a module definition it will be loaded and, if it has no fragment, returned as is. If a fragment is
present it will be resolved to a URI
and returned. If the provided URL
does not
reference a module definition, null
is returned.
url
- URL
describing the module definition to load.
Module
if the URL
references a module, a URL
if it has a fragment that
points to a particular component of the module, or null
if it does not reference a module.
java.net.MalformedURLException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |