org.jpublish
Class SiteContext

java.lang.Object
  |
  +--org.jpublish.SiteContext
All Implemented Interfaces:
com.anthonyeden.lib.Reloadable, XMLConstants

public class SiteContext
extends java.lang.Object
implements XMLConstants, com.anthonyeden.lib.Reloadable

This class contains configuration information for a particular site. Pages are loaded and actions are executed within the context of the site and have access to all of the methods within this class.

Instances of the SiteContext class will also reload themselves automatically when the underlying configuration file changes.

Author:
Anthony Eden

Fields inherited from interface org.jpublish.XMLConstants
NS, NS_PREFIX, NS_URL
 
Constructor Summary
SiteContext(java.io.File configurationFile)
          Construct a new SiteContext using the given File to load the context's configuration.
 
Method Summary
 java.lang.String getActionIdentifier()
          Get the action identifier which is used to trigger parameter actions.
 ActionManager getActionManager()
          Get the site's ActionManager.
 java.io.File getActionRoot()
          Get the directory where action scripts are stored.
 java.lang.String getDefaultMimeType()
          Get the default mime type.
 java.lang.String getDefaultPage()
          Get the default page.
 java.lang.String getDefaultTemplate()
          Get the default template.
 java.util.Map getEJBs()
          Get a Map of EJBHome interfaces.
 java.util.Map getExposedEJBs()
          Get a Map of EJB Session beans which are exposed on the page directly.
 org.formproc.FormManager getFormManager()
          Get the site's FormManager.
 MimeTypeMap getMimeTypeMap()
          Get the site's MimeType map.
 PageManager getPageManager()
          Get the site's PageManager.
 java.io.File getPageRoot()
          Get the directory where page configuration files are stored.
 java.util.List getRepositories()
          Get a list of all registered repositories.
 Repository getRepository(java.lang.String name)
          Get a Repository by name.
 StaticResourceLoader getStaticResourceLoader()
          Get the static resource loader.
 java.io.File getStaticRoot()
          Get the directory where static files are stored.
 java.io.File getTemplateRoot()
          Get the directory where templates are stored.
 java.io.File getWebInfPath()
          Get the File for the WEB-INF directory.
 void load(java.io.InputStream in)
          Load the site configuration from the given InputStream.
 void reload()
          Reload the site configuration.
 void setActionIdentifier(java.lang.String actionIdentifier)
          Set the action identifier.
 void setActionRoot(java.io.File actionRoot)
          Set the directory where action scripts are stored.
 void setActionRoot(java.lang.String actionRoot)
          Set the directory where action scripts are stored.
 void setDefaultMimeType(java.lang.String defaultMimeType)
          Set the default mime type.
 void setDefaultPage(java.lang.String defaultPage)
          Set the default page.
 void setDefaultTemplate(java.lang.String defaultTemplate)
          Set the default template.
 void setPageRoot(java.io.File pageRoot)
          Set the directory where page configuration files are stored.
 void setPageRoot(java.lang.String pageRoot)
          Set the directory where page configuration files are stored.
 void setStaticRoot(java.io.File staticRoot)
          Set the directory where static files are stored.
 void setStaticRoot(java.lang.String staticRoot)
          Set the directory where static files are stored.
 void setTemplateRoot(java.io.File templateRoot)
          Set the directory where templates are stored.
 void setTemplateRoot(java.lang.String templateRoot)
          Set the directory where templates are stored.
 void setWebInfPath(java.io.File webInfPath)
          Set the File for the WEB-INF directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SiteContext

public SiteContext(java.io.File configurationFile)
Construct a new SiteContext using the given File to load the context's configuration.
Parameters:
configurationFile - The configuration File
Method Detail

getPageRoot

public java.io.File getPageRoot()
Get the directory where page configuration files are stored. Page configurations are stored as XML files and are cached to improve performance. The page will automatically be reloaded if it is modified.
Returns:
The page root

setPageRoot

public void setPageRoot(java.io.File pageRoot)
Set the directory where page configuration files are stored. Page configurations are stored as XML files and are cached to improve performance. The page will automatically be reloaded if it is modified.
Parameters:
pageRoot - The new page root

setPageRoot

public void setPageRoot(java.lang.String pageRoot)
Set the directory where page configuration files are stored. Page configurations are stored as XML files and are cached to improve performance. The page will automatically be reloaded if it is modified.
Parameters:
pageRoot - The new page root

getTemplateRoot

public java.io.File getTemplateRoot()
Get the directory where templates are stored. Templates are merged with the runtime context to produce a final document.
Returns:
The template root

setTemplateRoot

public void setTemplateRoot(java.io.File templateRoot)
Set the directory where templates are stored. Templates are merged with the runtime context to produce a final document.
Parameters:
templateRoot - The template root

setTemplateRoot

public void setTemplateRoot(java.lang.String templateRoot)
Set the directory where templates are stored. Templates are merged with the runtime context to produce a final document.
Parameters:
templateRoot - The template root

getActionRoot

public java.io.File getActionRoot()
Get the directory where action scripts are stored. Actions stored here are scripts written in a language supported by the BSF library. The language's Java implementation must be included in the classpath.
Returns:
The action root

setActionRoot

public void setActionRoot(java.io.File actionRoot)
Set the directory where action scripts are stored. Actions stored here are scripts written in a language supported by the BSF library. The language's Java implementation must be included in the classpath.
Parameters:
actionRoot - The new action root

setActionRoot

public void setActionRoot(java.lang.String actionRoot)
Set the directory where action scripts are stored. Actions stored here are scripts written in a language supported by the BSF library. The language's Java implementation must be included in the classpath.
Parameters:
actionRoot - The new action root

getStaticRoot

public java.io.File getStaticRoot()
Get the directory where static files are stored. Static files are files which are not processed by JPublish but are returned byte for byte.
Returns:
The root directory where static files are stored

setStaticRoot

public void setStaticRoot(java.io.File staticRoot)
Set the directory where static files are stored. Static files are files which are not processed by JPublish but are returned byte for byte.
Parameters:
staticRoot - The new root directory where static files are stored

setStaticRoot

public void setStaticRoot(java.lang.String staticRoot)
Set the directory where static files are stored. Static files are files which are not processed by JPublish but are returned byte for byte.
Parameters:
staticRoot - The path of the new root directory where static files are stored

getStaticResourceLoader

public StaticResourceLoader getStaticResourceLoader()
Get the static resource loader.
Returns:
The static resource loader
See Also:
StaticResourceLoader

getWebInfPath

public java.io.File getWebInfPath()
Get the File for the WEB-INF directory. This is used to locate the classes and JARs so they are accessible to scripting languages.
Returns:
The WEB-INF file

setWebInfPath

public void setWebInfPath(java.io.File webInfPath)
Set the File for the WEB-INF directory.
Parameters:
webInfPath - The WEB-INF file

getActionIdentifier

public java.lang.String getActionIdentifier()
Get the action identifier which is used to trigger parameter actions. The default value is 'action'.
Returns:
The action identifier

setActionIdentifier

public void setActionIdentifier(java.lang.String actionIdentifier)
Set the action identifier. If this method is invoked with a null argument then the action identifier will be reset to the default value.
Parameters:
actionIdentifier - The new action identifer or null to reset

getDefaultPage

public java.lang.String getDefaultPage()
Get the default page. This value will be used when directories are requested. By default this returns 'index.html'.
Returns:
The default page

setDefaultPage

public void setDefaultPage(java.lang.String defaultPage)
Set the default page. This value will be used when directories are requested.
Parameters:
defaultPage - The new default page

getDefaultTemplate

public java.lang.String getDefaultTemplate()
Get the default template. This method returns the name of the template which will be used when no template is specified in a page's configuration.
Returns:
The default template

setDefaultTemplate

public void setDefaultTemplate(java.lang.String defaultTemplate)
Set the default template. The default template will be used when no template is specified in a page's configuration.
Parameters:
defaultTemplate - The new default template

getDefaultMimeType

public java.lang.String getDefaultMimeType()
Get the default mime type. This method delegates to the current MimeTypeMap.
Returns:
The default mime type

setDefaultMimeType

public void setDefaultMimeType(java.lang.String defaultMimeType)
Set the default mime type. This method delegates to the current MimeTypeMap.
Parameters:
defaultMimeType - The new default mime type

getRepositories

public java.util.List getRepositories()
Get a list of all registered repositories.
Returns:
A list of all registered Repository objects

getEJBs

public java.util.Map getEJBs()
Get a Map of EJBHome interfaces.
Returns:
A Map of name/EJBHome pairs

getExposedEJBs

public java.util.Map getExposedEJBs()
Get a Map of EJB Session beans which are exposed on the page directly.
Returns:
A Map of name/session bean pairs

getRepository

public Repository getRepository(java.lang.String name)
Get a Repository by name. If the repository was not registered then this method will return null.
Parameters:
name - The name of the Repository
Returns:
The repository or null

getActionManager

public ActionManager getActionManager()
Get the site's ActionManager.
Returns:
The ActionManager
See Also:
ActionManager

getPageManager

public PageManager getPageManager()
Get the site's PageManager.
Returns:
The PageManager
See Also:
PageManager

getFormManager

public org.formproc.FormManager getFormManager()
Get the site's FormManager. If no FormManager is specified then this method will return null.
Returns:
The FormManager
See Also:
FormManager

getMimeTypeMap

public MimeTypeMap getMimeTypeMap()
Get the site's MimeType map. Mime types can be mapped to file suffixes.
Returns:
The MimeTypeMap

reload

public void reload()
Reload the site configuration.
Specified by:
reload in interface com.anthonyeden.lib.Reloadable

load

public void load(java.io.InputStream in)
          throws java.lang.Exception
Load the site configuration from the given InputStream. The InputStream must be attached to an XML document.
Parameters:
in - The InputStream
Throws:
java.lang.Exception -  


Copyright (C) 2001 Anthony Eden. All Rights Reserved.