Package helma.framework.core
Class Prototype
- java.lang.Object
-
- helma.framework.core.Prototype
-
public final class Prototype extends java.lang.Object
The Prototype class represents Script prototypes/type defined in a Helma application. This class manages a prototypes templates, functions and actions as well as optional information about the mapping of this type to a relational database table.
-
-
Constructor Summary
Constructors Constructor Description Prototype(java.lang.String name, Repository repository, Application app, java.util.Map typeProps)
Creates a new Prototype object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRepository(Repository repository, boolean update)
Adds an repository to the list of repositoriesvoid
checkForUpdates()
Check a prototype for new or updated resources.Application
getApplication()
Return the application this prototype is a part ofjava.util.Iterator
getCodeResources()
Return an iterator over this prototype's code resoruces.DbMapping
getDbMapping()
Get the DbMapping associated with this prototypejava.lang.String
getLowerCaseName()
Return this prototype's name in lower case lettersjava.lang.String
getName()
Return this prototype's namePrototype
getParentPrototype()
Get the parent prototype from which we inherit, or null if we are top of the line.Repository[]
getRepositories()
Returns an array of repositories containing code for this prototype.Resource[]
getResources()
Returns the list of resources in this prototype's repositories.java.util.Map
getScriptableSkinMap()
Get a map containing this prototype's skins as stringsjava.util.Map
getScriptableSkinMap(java.lang.Object[] skinpath)
Get a map containing this prototype's skins as strings, overloaded by the skins found in the given skinpath.Skin
getSkin(Prototype proto, java.lang.String skinname, java.lang.String subskin, java.lang.Object[] skinpath)
Get a skin for this prototype.java.util.Iterator
getSkinResources()
Return an iterator over this prototype's skin resoruces.ResourceProperties
getTypeProperties()
Get the prototype's aggregated type.propertiesboolean
isInstanceOf(java.lang.String pname)
Check if the given prototype is within this prototype's parent chain.long
lastCodeUpdate()
Get the last time any script has been re-read for this prototype.void
markUpdated()
Signal that some script in this prototype has been re-read from disk and needs to be re-compiled by the evaluators.void
registerParents(java.util.Map handlers, java.lang.Object obj)
Register an object as handler for all our parent prototypes, but only if a handler by that prototype name isn't registered yet.void
setParentPrototype(Prototype parent)
Set the parent prototype of this prototype, i.e.void
setTypeProperties(java.util.Map map)
Set the custom type properties for this prototype and update the database mapping.java.lang.String
toString()
Return a string representing this prototype.
-
-
-
Constructor Detail
-
Prototype
public Prototype(java.lang.String name, Repository repository, Application app, java.util.Map typeProps)
Creates a new Prototype object.- Parameters:
name
- the prototype's namerepository
- the first prototype's repositoryapp
- the application this prototype is a part oftypeProps
- custom type mapping properties
-
-
Method Detail
-
getApplication
public Application getApplication()
Return the application this prototype is a part of
-
addRepository
public void addRepository(Repository repository, boolean update) throws java.io.IOException
Adds an repository to the list of repositories- Parameters:
repository
- repository to addupdate
- indicates whether to immediately update the prototype with the new code- Throws:
java.io.IOException
- if reading/updating from the repository fails
-
checkForUpdates
public void checkForUpdates()
Check a prototype for new or updated resources. After this has been called the code and skins collections of this prototype should be up-to-date and the lastCodeUpdate be set if there has been any changes.
-
getResources
public Resource[] getResources()
Returns the list of resources in this prototype's repositories. Used by checkForUpdates() to see whether there is anything new.
-
getRepositories
public Repository[] getRepositories()
Returns an array of repositories containing code for this prototype.
-
setParentPrototype
public void setParentPrototype(Prototype parent)
Set the parent prototype of this prototype, i.e. the prototype this prototype inherits from.
-
getParentPrototype
public Prototype getParentPrototype()
Get the parent prototype from which we inherit, or null if we are top of the line.
-
isInstanceOf
public final boolean isInstanceOf(java.lang.String pname)
Check if the given prototype is within this prototype's parent chain.
-
registerParents
public final void registerParents(java.util.Map handlers, java.lang.Object obj)
Register an object as handler for all our parent prototypes, but only if a handler by that prototype name isn't registered yet. This is used to implement direct over indirect prototype precedence and child over parent precedence.
-
getDbMapping
public DbMapping getDbMapping()
Get the DbMapping associated with this prototype
-
getSkin
public Skin getSkin(Prototype proto, java.lang.String skinname, java.lang.String subskin, java.lang.Object[] skinpath) throws java.io.IOException
Get a skin for this prototype. This only works for skins residing in the prototype directory, not for skins files in other locations or database stored skins. If parentName and subName are defined, the skin may be a subskin of another skin.- Throws:
java.io.IOException
-
getName
public java.lang.String getName()
Return this prototype's name- Returns:
- ...
-
getLowerCaseName
public java.lang.String getLowerCaseName()
Return this prototype's name in lower case letters- Returns:
- ...
-
lastCodeUpdate
public long lastCodeUpdate()
Get the last time any script has been re-read for this prototype.
-
markUpdated
public void markUpdated()
Signal that some script in this prototype has been re-read from disk and needs to be re-compiled by the evaluators.
-
setTypeProperties
public void setTypeProperties(java.util.Map map)
Set the custom type properties for this prototype and update the database mapping.- Parameters:
map
- the custom type mapping properties.
-
getTypeProperties
public ResourceProperties getTypeProperties()
Get the prototype's aggregated type.properties- Returns:
- type.properties
-
getCodeResources
public java.util.Iterator getCodeResources()
Return an iterator over this prototype's code resoruces. Synchronized to not return a collection in a transient state where it is just being updated by the type manager.- Returns:
- an iterator of this prototype's code resources
-
getSkinResources
public java.util.Iterator getSkinResources()
Return an iterator over this prototype's skin resoruces. Synchronized to not return a collection in a transient state where it is just being updated by the type manager.- Returns:
- an iterator over this prototype's skin resources
-
toString
public java.lang.String toString()
Return a string representing this prototype.- Overrides:
toString
in classjava.lang.Object
-
getScriptableSkinMap
public java.util.Map getScriptableSkinMap()
Get a map containing this prototype's skins as strings- Returns:
- a scriptable skin map
-
getScriptableSkinMap
public java.util.Map getScriptableSkinMap(java.lang.Object[] skinpath)
Get a map containing this prototype's skins as strings, overloaded by the skins found in the given skinpath.- Returns:
- a scriptable skin map
-
-