org.apache.tapestry.spec
Class LibrarySpecification

java.lang.Object
  extended by org.apache.tapestry.util.BasePropertyHolder
      extended by org.apache.tapestry.spec.LocatablePropertyHolder
          extended by org.apache.tapestry.spec.LibrarySpecification
All Implemented Interfaces:
org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder, ILibrarySpecification, IPropertyHolder
Direct Known Subclasses:
ApplicationSpecification

public class LibrarySpecification
extends LocatablePropertyHolder
implements ILibrarySpecification

Specification for a library. ApplicationSpecificationis a specialized kind of library.

Since:
2.2bv
Author:
Howard Lewis Ship

Constructor Summary
LibrarySpecification()
           
 
Method Summary
 void addExtensionSpecification(java.lang.String name, IExtensionSpecification extension)
          Adds another extension specification.
protected  void applyTypeConstraint(java.lang.String name, java.lang.Object extension, java.lang.Class typeConstraint, org.apache.hivemind.Location location)
          Checks that an extension conforms to the supplied type constraint.
 boolean checkExtension(java.lang.String name)
          Returns true if this library specification has a specification for the named extension.
protected  void extendDescription(org.apache.hivemind.util.ToStringBuilder builder)
          Does nothing, subclasses may override to add additional description.
protected  java.util.Map getComponents()
          Returns the components map.
 java.lang.String getComponentSpecificationPath(java.lang.String alias)
           
 java.util.List getComponentTypes()
          Returns the simple types of all components defined in this library.
 java.lang.String getDescription()
          Returns the documentation for this library..
 java.lang.Object getExtension(java.lang.String name)
          Returns an instantiated extension.
 java.lang.Object getExtension(java.lang.String name, java.lang.Class typeConstraint)
          Returns an instantiated extension, performing a check to ensure that the extension is a subtype of the given class (or extends the given interface).
 java.util.List getExtensionNames()
          Returns a sorted List of the names of all extensions.
protected  java.util.Map getExtensions()
          Returns the extensions map.
 IExtensionSpecification getExtensionSpecification(java.lang.String name)
          Returns the named IExtensionSpecification, or null if it doesn't exist.
 java.util.Map getExtensionSpecifications()
          Returns a Map of extensions; key is extension name, value is IExtensionSpecification.
protected  java.util.Map getLibraries()
          Returns the libraries map.
 java.util.List getLibraryIds()
          Returns a sorted list of library ids (or the empty list, but not null).
 java.lang.String getLibrarySpecificationPath(java.lang.String id)
          Returns the specification path (within the classpath) for an embedded library, or null if no such library has been defined.
 java.util.List getPageNames()
          Returns a sorted list of page names explicitly defined by this library, or an empty list (but not null).
protected  java.util.Map getPages()
          Returns the pages map.
 java.lang.String getPageSpecificationPath(java.lang.String name)
           
 java.lang.String getPublicId()
          Returns the XML Public Id for the library file, or null if not applicable.
 java.lang.String getServiceClassName(java.lang.String name)
           
 java.util.List getServiceNames()
          Returns a sorted list of service names (or an empty list, but not null).
protected  java.util.Map getServices()
          Deprecated. To be removed in release 4.1.
 org.apache.hivemind.Resource getSpecificationLocation()
          Returns the location from which the specification was read.
 void instantiateImmediateExtensions()
          Invoked after the entire specification has been constructed to instantiate any extensions marked immediate.
protected  void setComponents(java.util.Map components)
          Updates the components map.
 void setComponentSpecificationPath(java.lang.String alias, java.lang.String path)
           
 void setDescription(java.lang.String description)
          Sets the documentation for this library.
protected  void setExtensions(java.util.Map extension)
          Updates the extension map.
protected  void setLibraries(java.util.Map libraries)
          Updates the library map.
 void setLibrarySpecificationPath(java.lang.String id, java.lang.String path)
          Sets the specification path for an embedded library.
protected  void setPages(java.util.Map pages)
          Updates the page map.
 void setPageSpecificationPath(java.lang.String name, java.lang.String path)
           
 void setPublicId(java.lang.String publicId)
           
 void setServiceClassName(java.lang.String name, java.lang.String className)
           
protected  void setServices(java.util.Map services)
          Deprecated. To be removed in release 4.1.
 void setSpecificationLocation(org.apache.hivemind.Resource specificationLocation)
           
 java.lang.String toString()
           
 
Methods inherited from class org.apache.tapestry.spec.LocatablePropertyHolder
getLocation, setLocation
 
Methods inherited from class org.apache.tapestry.util.BasePropertyHolder
getProperty, getPropertyNames, removeProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.util.IPropertyHolder
getProperty, getPropertyNames, removeProperty, setProperty
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Constructor Detail

LibrarySpecification

public LibrarySpecification()
Method Detail

getLibrarySpecificationPath

public java.lang.String getLibrarySpecificationPath(java.lang.String id)
Description copied from interface: ILibrarySpecification
Returns the specification path (within the classpath) for an embedded library, or null if no such library has been defined.

Specified by:
getLibrarySpecificationPath in interface ILibrarySpecification

setLibrarySpecificationPath

public void setLibrarySpecificationPath(java.lang.String id,
                                        java.lang.String path)
Sets the specification path for an embedded library.

Specified by:
setLibrarySpecificationPath in interface ILibrarySpecification
Throws:
java.lang.IllegalArgumentException - if a library with the given id already exists

getLibraryIds

public java.util.List getLibraryIds()
Description copied from interface: ILibrarySpecification
Returns a sorted list of library ids (or the empty list, but not null).

Specified by:
getLibraryIds in interface ILibrarySpecification

getPageSpecificationPath

public java.lang.String getPageSpecificationPath(java.lang.String name)
Specified by:
getPageSpecificationPath in interface ILibrarySpecification

setPageSpecificationPath

public void setPageSpecificationPath(java.lang.String name,
                                     java.lang.String path)
Specified by:
setPageSpecificationPath in interface ILibrarySpecification

getPageNames

public java.util.List getPageNames()
Description copied from interface: ILibrarySpecification
Returns a sorted list of page names explicitly defined by this library, or an empty list (but not null).

Specified by:
getPageNames in interface ILibrarySpecification

setComponentSpecificationPath

public void setComponentSpecificationPath(java.lang.String alias,
                                          java.lang.String path)
Specified by:
setComponentSpecificationPath in interface ILibrarySpecification

getComponentSpecificationPath

public java.lang.String getComponentSpecificationPath(java.lang.String alias)
Specified by:
getComponentSpecificationPath in interface ILibrarySpecification

getComponentTypes

public java.util.List getComponentTypes()
Description copied from interface: ILibrarySpecification
Returns the simple types of all components defined in this library. Returns a list of strings in sorted order, or an empty list (but not null).

Specified by:
getComponentTypes in interface ILibrarySpecification
Since:
3.0

getServiceClassName

public java.lang.String getServiceClassName(java.lang.String name)
Specified by:
getServiceClassName in interface ILibrarySpecification

getServiceNames

public java.util.List getServiceNames()
Description copied from interface: ILibrarySpecification
Returns a sorted list of service names (or an empty list, but not null).

Specified by:
getServiceNames in interface ILibrarySpecification

setServiceClassName

public void setServiceClassName(java.lang.String name,
                                java.lang.String className)
Specified by:
setServiceClassName in interface ILibrarySpecification

getDescription

public java.lang.String getDescription()
Returns the documentation for this library..

Specified by:
getDescription in interface ILibrarySpecification

setDescription

public void setDescription(java.lang.String description)
Sets the documentation for this library.

Specified by:
setDescription in interface ILibrarySpecification

getExtensionSpecifications

public java.util.Map getExtensionSpecifications()
Returns a Map of extensions; key is extension name, value is IExtensionSpecification. May return null. The returned Map is immutable.

Specified by:
getExtensionSpecifications in interface ILibrarySpecification

addExtensionSpecification

public void addExtensionSpecification(java.lang.String name,
                                      IExtensionSpecification extension)
Adds another extension specification.

Specified by:
addExtensionSpecification in interface ILibrarySpecification
Throws:
java.lang.IllegalArgumentException - if an extension with the given name already exists.

getExtensionNames

public java.util.List getExtensionNames()
Returns a sorted List of the names of all extensions. May return the empty list, but won't return null.

Specified by:
getExtensionNames in interface ILibrarySpecification

getExtensionSpecification

public IExtensionSpecification getExtensionSpecification(java.lang.String name)
Returns the named IExtensionSpecification, or null if it doesn't exist.

Specified by:
getExtensionSpecification in interface ILibrarySpecification

checkExtension

public boolean checkExtension(java.lang.String name)
Returns true if this library specification has a specification for the named extension.

Specified by:
checkExtension in interface ILibrarySpecification

getExtension

public java.lang.Object getExtension(java.lang.String name)
Returns an instantiated extension. Extensions are created as needed and cached for later use.

Specified by:
getExtension in interface ILibrarySpecification
Throws:
java.lang.IllegalArgumentException - if no extension specification exists for the given name.

getExtension

public java.lang.Object getExtension(java.lang.String name,
                                     java.lang.Class typeConstraint)
Description copied from interface: ILibrarySpecification
Returns an instantiated extension, performing a check to ensure that the extension is a subtype of the given class (or extends the given interface).

Specified by:
getExtension in interface ILibrarySpecification
Since:
3.0 *

applyTypeConstraint

protected void applyTypeConstraint(java.lang.String name,
                                   java.lang.Object extension,
                                   java.lang.Class typeConstraint,
                                   org.apache.hivemind.Location location)
Checks that an extension conforms to the supplied type constraint.

Throws:
java.lang.IllegalArgumentException - if the extension fails the check.
Since:
3.0

instantiateImmediateExtensions

public void instantiateImmediateExtensions()
Invoked after the entire specification has been constructed to instantiate any extensions marked immediate.

Specified by:
instantiateImmediateExtensions in interface ILibrarySpecification

getExtensions

protected java.util.Map getExtensions()
Returns the extensions map.

Returns:
Map of objects.

setExtensions

protected void setExtensions(java.util.Map extension)
Updates the extension map.

Parameters:
extension - A Map of extension specification paths keyed on extension id.

The map is retained, not copied.


getLibraries

protected java.util.Map getLibraries()
Returns the libraries map.

Returns:
Map of LibrarySpecification.

setLibraries

protected void setLibraries(java.util.Map libraries)
Updates the library map.

Parameters:
libraries - A Map of library specification paths keyed on library id.

The map is retained, not copied.


getPages

protected java.util.Map getPages()
Returns the pages map.

Returns:
Map of IComponentSpecification.

setPages

protected void setPages(java.util.Map pages)
Updates the page map.

Parameters:
pages - A Map of page specification paths keyed on page id.

The map is retained, not copied.


getServices

protected java.util.Map getServices()
Deprecated. To be removed in release 4.1.

Returns the services.

Returns:
Map of service class names.

setServices

protected void setServices(java.util.Map services)
Deprecated. To be removed in release 4.1.

Updates the services map.

Parameters:
services - A Map of the fully qualified names of classes which implement IEngineServicekeyed on service id.

The map is retained, not copied.


getComponents

protected java.util.Map getComponents()
Returns the components map.

Returns:
Map of IContainedComponent.

setComponents

protected void setComponents(java.util.Map components)
Updates the components map.

Parameters:
components - A Map of IContainedComponentkeyed on component id. The map is retained, not copied.

getPublicId

public java.lang.String getPublicId()
Returns the XML Public Id for the library file, or null if not applicable.

This method exists as a convienience for the Spindle plugin. A previous method used an arbitrary version string, the public id is more useful and less ambiguous.

Specified by:
getPublicId in interface ILibrarySpecification

setPublicId

public void setPublicId(java.lang.String publicId)
Specified by:
setPublicId in interface ILibrarySpecification

getSpecificationLocation

public org.apache.hivemind.Resource getSpecificationLocation()
Description copied from interface: ILibrarySpecification
Returns the location from which the specification was read.

Specified by:
getSpecificationLocation in interface ILibrarySpecification
Since:
3.0 *

setSpecificationLocation

public void setSpecificationLocation(org.apache.hivemind.Resource specificationLocation)
Specified by:
setSpecificationLocation in interface ILibrarySpecification
Since:
3.0 *

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Since:
3.0 *

extendDescription

protected void extendDescription(org.apache.hivemind.util.ToStringBuilder builder)
Does nothing, subclasses may override to add additional description.

Since:
3.0
See Also:
toString()