net.sf.click.service
Class XmlConfigService

java.lang.Object
  extended bynet.sf.click.service.XmlConfigService
All Implemented Interfaces:
ConfigService, EntityResolver

public class XmlConfigService
extends Object
implements ConfigService, EntityResolver

Provides a Click XML configuration service class.

This class reads Click configuration information from a file named click.xml. The service will first lookup the click.xml under the applications WEB-INF directory, and if not found attempt to load the configuration file from the classpath root.

Configuring Click through the click.xml file is the most common technique.

However you can instruct Click to use a different service implementation. Please see ConfigService for more details.

Author:
Malcolm Edgar

Nested Class Summary
static class XmlConfigService.ExcludePage
          Provide an Excluded Page class.
 
Field Summary
 
Fields inherited from interface net.sf.click.service.ConfigService
CONTEXT_NAME, ERROR_PATH, MODE_DEBUG, MODE_DEVELOPMENT, MODE_PRODUCTION, MODE_PROFILE, MODE_TRACE, NOT_FOUND_PATH
 
Constructor Summary
XmlConfigService()
           
 
Method Summary
 Format createFormat()
          Create and return a new format object instance.
 String getApplicationMode()
          Return the application mode String value:   ["production", "profile", "development", "debug"].
 String getCharset()
          Return the Click application charset or null if not defined.
 Class getErrorPageClass()
          Return the error handling page Page Class.
 FileUploadService getFileUploadService()
          Return the application file upload service, which is used to parse multi-part file upload post requests.
 Locale getLocale()
          Return the Click application locale or null if not defined.
 LogService getLogService()
          Return the Click application log service.
 Class getNotFoundPageClass()
          Return the page not found Page Class.
 Class getPageClass(String path)
          Return the page Class for the given path.
 List getPageClassList()
          Return the list of configured page classes.
 Field getPageField(Class pageClass, String fieldName)
          Return the public field of the given name for the pageClass, or null if not defined.
 Field[] getPageFieldArray(Class pageClass)
          Return an array public fields for the given page class.
 Map getPageFields(Class pageClass)
          Return Map of public fields for the given page class.
 Map getPageHeaders(String path)
          Return the headers of the page for the given path.
 String getPagePath(Class pageClass)
          Return the path for the given page Class.
 ServletContext getServletContext()
          Return the application servlet context.
 TemplateService getTemplateService()
          Return the application templating service.
 boolean isJspPage(String path)
          Return true if JSP exists for the given ".htm" path.
 boolean isPagesAutoBinding()
          Return true if auto binding is enabled.
 boolean isProductionMode()
          Return true if the application is in "production" mode.
 boolean isProfileMode()
          Return true if the application is in "profile" mode.
 void onDestroy()
          Destroy the ConfigurationService.
 void onInit(ServletContext servletContext)
          Initialize the ConfigurationService with the given application servlet context.
 InputSource resolveEntity(String publicId, String systemId)
          This method resolves the click.dtd for the XML parser using the classpath resource: /net/sf/click/click.dtd.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlConfigService

public XmlConfigService()
Method Detail

onInit

public void onInit(ServletContext servletContext)
            throws Exception
Description copied from interface: ConfigService
Initialize the ConfigurationService with the given application servlet context.

This method is invoked after the ConfigurationService has been constructed.

Specified by:
onInit in interface ConfigService
Parameters:
servletContext - the application servlet context
Throws:
Exception - if an error occurs initializing the application
See Also:
ConfigService.onInit(ServletContext)

onDestroy

public void onDestroy()
Description copied from interface: ConfigService
Destroy the ConfigurationService. This method will also invoke the onDestory() methods on the FileUploadService and the TemplateService.

Specified by:
onDestroy in interface ConfigService
See Also:
ConfigService.onDestroy()

getApplicationMode

public String getApplicationMode()
Return the application mode String value:   ["production", "profile", "development", "debug"].

Specified by:
getApplicationMode in interface ConfigService
Returns:
the application mode String value

getCharset

public String getCharset()
Description copied from interface: ConfigService
Return the Click application charset or null if not defined.

Specified by:
getCharset in interface ConfigService
Returns:
the application character encoding
See Also:
ConfigService.getCharset()

getFileUploadService

public FileUploadService getFileUploadService()
Description copied from interface: ConfigService
Return the application file upload service, which is used to parse multi-part file upload post requests.

Specified by:
getFileUploadService in interface ConfigService
Returns:
the FileUpload service
See Also:
ConfigService.getFileUploadService()

getTemplateService

public TemplateService getTemplateService()
Description copied from interface: ConfigService
Return the application templating service.

Specified by:
getTemplateService in interface ConfigService
Returns:
the FileUpload service
See Also:
ConfigService.getTemplateService()

createFormat

public Format createFormat()
Description copied from interface: ConfigService
Create and return a new format object instance.

Specified by:
createFormat in interface ConfigService
Returns:
a new format object
See Also:
ConfigService.createFormat()

getLocale

public Locale getLocale()
Description copied from interface: ConfigService
Return the Click application locale or null if not defined.

Specified by:
getLocale in interface ConfigService
Returns:
the application locale
See Also:
ConfigService.getLocale()

getLogService

public LogService getLogService()
Description copied from interface: ConfigService
Return the Click application log service.

Specified by:
getLogService in interface ConfigService
Returns:
the application log service.
See Also:
ConfigService.getLogService()

isPagesAutoBinding

public boolean isPagesAutoBinding()
Description copied from interface: ConfigService
Return true if auto binding is enabled. Autobinding will automatically bind any request parameters to public fields, add any public controls to the page and add public fields to the page model.

Specified by:
isPagesAutoBinding in interface ConfigService
Returns:
true if request parameters should be automatically bound to public page fields
See Also:
ConfigService.isPagesAutoBinding()

isProductionMode

public boolean isProductionMode()
Description copied from interface: ConfigService
Return true if the application is in "production" mode.

Specified by:
isProductionMode in interface ConfigService
Returns:
true if the application is in "production" mode
See Also:
ConfigService.isProductionMode()

isProfileMode

public boolean isProfileMode()
Description copied from interface: ConfigService
Return true if the application is in "profile" mode.

Specified by:
isProfileMode in interface ConfigService
Returns:
true if the application is in "profile" mode
See Also:
ConfigService.isProfileMode()

isJspPage

public boolean isJspPage(String path)
Description copied from interface: ConfigService
Return true if JSP exists for the given ".htm" path.

Specified by:
isJspPage in interface ConfigService
Parameters:
path - the Page ".htm" path
Returns:
true if JSP exists for the given ".htm" path
See Also:
ConfigService.isJspPage(String)

getPageClass

public Class getPageClass(String path)
Description copied from interface: ConfigService
Return the page Class for the given path.

Specified by:
getPageClass in interface ConfigService
Parameters:
path - the page path
Returns:
the page class for the given path or null if no class is found
See Also:
ConfigService.getPageClass(String)

getPagePath

public String getPagePath(Class pageClass)
Description copied from interface: ConfigService
Return the path for the given page Class.

Specified by:
getPagePath in interface ConfigService
Parameters:
pageClass - the page class
Returns:
path the page path or null if no path is found
Throws:
IllegalArgumentException - if the Page Class is not configured with a unique path
See Also:
ConfigService.getPagePath(Class)

getPageClassList

public List getPageClassList()
Description copied from interface: ConfigService
Return the list of configured page classes.

Specified by:
getPageClassList in interface ConfigService
Returns:
the list of configured page classes
See Also:
ConfigService.getPageClassList()

getPageHeaders

public Map getPageHeaders(String path)
Description copied from interface: ConfigService
Return the headers of the page for the given path.

Specified by:
getPageHeaders in interface ConfigService
Parameters:
path - the path of the page
Returns:
a Map of headers for the given page path
See Also:
ConfigService.getPageHeaders(String)

getNotFoundPageClass

public Class getNotFoundPageClass()
Description copied from interface: ConfigService
Return the page not found Page Class.

Specified by:
getNotFoundPageClass in interface ConfigService
Returns:
the page not found Page Class
See Also:
ConfigService.getNotFoundPageClass()

getErrorPageClass

public Class getErrorPageClass()
Description copied from interface: ConfigService
Return the error handling page Page Class.

Specified by:
getErrorPageClass in interface ConfigService
Returns:
the error handling page Page Class
See Also:
ConfigService.getErrorPageClass()

getPageField

public Field getPageField(Class pageClass,
                          String fieldName)
Description copied from interface: ConfigService
Return the public field of the given name for the pageClass, or null if not defined.

Specified by:
getPageField in interface ConfigService
Parameters:
pageClass - the page class
fieldName - the name of the field
Returns:
the public field of the pageClass with the given name or null
See Also:
ConfigService.getPageField(Class, String)

getPageFieldArray

public Field[] getPageFieldArray(Class pageClass)
Description copied from interface: ConfigService
Return an array public fields for the given page class.

Specified by:
getPageFieldArray in interface ConfigService
Parameters:
pageClass - the page class
Returns:
an array public fields for the given page class
See Also:
ConfigService.getPageFieldArray(Class)

getPageFields

public Map getPageFields(Class pageClass)
Description copied from interface: ConfigService
Return Map of public fields for the given page class.

Specified by:
getPageFields in interface ConfigService
Parameters:
pageClass - the page class
Returns:
a Map of public fields for the given page class
See Also:
ConfigService.getPageFields(Class)

getServletContext

public ServletContext getServletContext()
Description copied from interface: ConfigService
Return the application servlet context.

Specified by:
getServletContext in interface ConfigService
Returns:
the application servlet context
See Also:
ConfigService.getServletContext()

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
This method resolves the click.dtd for the XML parser using the classpath resource: /net/sf/click/click.dtd.

Specified by:
resolveEntity in interface EntityResolver
Parameters:
publicId - the DTD public id
systemId - the DTD system id
Returns:
resolved entity DTD input stream
Throws:
SAXException - if an error occurs parsing the document
IOException - if an error occurs reading the document
See Also:
EntityResolver.resolveEntity(String, String)