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:
ILocatable, ILocationHolder, ILibrarySpecification, IPropertyHolder
Direct Known Subclasses:
ApplicationSpecification

public class LibrarySpecification
extends LocatablePropertyHolder
implements ILibrarySpecification

Specification for a library. ApplicationSpecification is a specialized kind of library.

Since:
2.2
Version:
$Id: LibrarySpecification.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship

Constructor Summary
LibrarySpecification()
           
 
Method Summary
 void addExtensionSpecification(String name, IExtensionSpecification extension)
          Adds another extension specification.
protected  void applyTypeConstraint(String name, Object extension, Class typeConstraint, ILocation location)
          Checks that an extension conforms to the supplied type constraint.
 boolean checkExtension(String name)
          Returns true if this library specification has a specification for the named extension.
protected  void extendDescription(org.apache.commons.lang.builder.ToStringBuilder builder)
          Does nothing, subclasses may override to add additional description.
protected  Map getComponents()
          Returns the components map.
 String getComponentSpecificationPath(String alias)
           
 List getComponentTypes()
          Returns the simple types of all components defined in this library.
 String getDescription()
          Returns the documentation for this library..
 Object getExtension(String name)
          Returns an instantiated extension.
 Object getExtension(String name, 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).
 List getExtensionNames()
          Returns a sorted List of the names of all extensions.
protected  Map getExtensions()
          Returns the extensions map.
 IExtensionSpecification getExtensionSpecification(String name)
          Returns the named IExtensionSpecification, or null if it doesn't exist.
 Map getExtensionSpecifications()
          Returns a Map of extensions; key is extension name, value is IExtensionSpecification.
protected  Map getLibraries()
          Returns the libraries map.
 List getLibraryIds()
          Returns a sorted list of library ids (or the empty list, but not null).
 String getLibrarySpecificationPath(String id)
          Returns the specification path (within the classpath) for an embedded library, or null if no such library has been defined.
 List getPageNames()
          Returns a sorted list of page names explicitly defined by this library, or an empty list (but not null).
protected  Map getPages()
          Returns the pages map.
 String getPageSpecificationPath(String name)
           
 String getPublicId()
          Returns the XML Public Id for the library file, or null if not applicable.
 IResourceResolver getResourceResolver()
           
 String getServiceClassName(String name)
           
 List getServiceNames()
          Returns a sorted list of service names (or an empty list, but not null).
protected  Map getServices()
          Returns the services.
 IResourceLocation 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(Map components)
          Updates the components map.
 void setComponentSpecificationPath(String alias, String path)
           
 void setDescription(String description)
          Sets the documentation for this library.
protected  void setExtensions(Map extension)
          Updates the extension map.
protected  void setLibraries(Map libraries)
          Updates the library map.
 void setLibrarySpecificationPath(String id, String path)
          Sets the specification path for an embedded library.
protected  void setPages(Map pages)
          Updates the page map.
 void setPageSpecificationPath(String name, String path)
           
 void setPublicId(String publicId)
           
 void setResourceResolver(IResourceResolver resolver)
           
 void setServiceClassName(String name, String className)
           
protected  void setServices(Map services)
          Updates the services map.
 void setSpecificationLocation(IResourceLocation specificationLocation)
           
 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.tapestry.ILocationHolder
setLocation
 
Methods inherited from interface org.apache.tapestry.ILocatable
getLocation
 

Constructor Detail

LibrarySpecification

public LibrarySpecification()
Method Detail

getLibrarySpecificationPath

public String getLibrarySpecificationPath(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(String id,
                                        String path)
Sets the specification path for an embedded library.

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

getLibraryIds

public 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 String getPageSpecificationPath(String name)
Specified by:
getPageSpecificationPath in interface ILibrarySpecification

setPageSpecificationPath

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

getPageNames

public 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(String alias,
                                          String path)
Specified by:
setComponentSpecificationPath in interface ILibrarySpecification

getComponentSpecificationPath

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

getComponentTypes

public 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 String getServiceClassName(String name)
Specified by:
getServiceClassName in interface ILibrarySpecification

getServiceNames

public 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(String name,
                                String className)
Specified by:
setServiceClassName in interface ILibrarySpecification

getDescription

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

Specified by:
getDescription in interface ILibrarySpecification

setDescription

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

Specified by:
setDescription in interface ILibrarySpecification

getExtensionSpecifications

public 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(String name,
                                      IExtensionSpecification extension)
Adds another extension specification.

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

getExtensionNames

public 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(String name)
Returns the named IExtensionSpecification, or null if it doesn't exist.

Specified by:
getExtensionSpecification in interface ILibrarySpecification

checkExtension

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

Specified by:
checkExtension in interface ILibrarySpecification

getExtension

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

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

getExtension

public Object getExtension(String name,
                           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(String name,
                                   Object extension,
                                   Class typeConstraint,
                                   ILocation location)
Checks that an extension conforms to the supplied type constraint.

Throws:
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

getResourceResolver

public IResourceResolver getResourceResolver()
Specified by:
getResourceResolver in interface ILibrarySpecification

setResourceResolver

public void setResourceResolver(IResourceResolver resolver)
Specified by:
setResourceResolver in interface ILibrarySpecification

getExtensions

protected Map getExtensions()
Returns the extensions map.

Returns:
Map of objects.

setExtensions

protected void setExtensions(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 Map getLibraries()
Returns the libraries map.

Returns:
Map of LibrarySpecification.

setLibraries

protected void setLibraries(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 Map getPages()
Returns the pages map.

Returns:
Map of IComponentSpecification.

setPages

protected void setPages(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 Map getServices()
Returns the services.

Returns:
Map of service class names.

setServices

protected void setServices(Map services)
Updates the services map.

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

The map is retained, not copied.


getComponents

protected Map getComponents()
Returns the components map.

Returns:
Map of IContainedComponent.

setComponents

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

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

getPublicId

public 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(String publicId)
Specified by:
setPublicId in interface ILibrarySpecification

getSpecificationLocation

public IResourceLocation 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(IResourceLocation specificationLocation)
Specified by:
setSpecificationLocation in interface ILibrarySpecification
Since:
3.0

toString

public String toString()
Overrides:
toString in class Object
Since:
3.0

extendDescription

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

Since:
3.0
See Also:
toString()