|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Provides a Click application configuration service interface.
A single application ConfigService instance is created by the ClickServlet at startup. Once the ConfigService has been initialized it is stored in the ServletContext using the key "net.sf.click.service.ConfigService".XmlConfigService
.
However it is possible to specify a different implementation.
For example you can subclass XmlConfigService and override methods such as
onInit(javax.servlet.ServletContext)
to alter initialization
behavior.
For Click to recognize your custom service class you must set the
context initialization parameter,
config-service-class
in your web.xml file.
Below is an example of a custom service class
com.mycorp.service.CustomConfigSerivce:
package com.mycorp.service; public class CustomConfigService extends XmlConfigService { public CustomConfigService() { } public void onInit(ServletContext servletContext) throws Exception { // Add your logic here ... // Call super to resume initialization super.onInit(servletContext); } }Please note that the custom ConfigService implementation must have a no-argument constructor so Click can instantiate the service. Also define the new service in your web.xml as follows:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> ... <context-param> <param-name>config-service-class</param-name> <param-value>com.mycorp.service.CustomConfigSerivce</param-value> </context-param> ... </web-app>
Field Summary | |
static String |
CONTEXT_NAME
The servlet context attribute name. |
static String |
ERROR_PATH
The error page file path: "/click/error.htm". |
static String |
MODE_DEBUG
The debug application mode. |
static String |
MODE_DEVELOPMENT
The development application mode. |
static String |
MODE_PRODUCTION
The profile application mode. |
static String |
MODE_PROFILE
The profile application mode. |
static String |
MODE_TRACE
The trace application mode. |
static String |
NOT_FOUND_PATH
The page not found file path: "/click/not-found.htm". |
Method Summary | |
Format |
createFormat()
Create and return a new format object instance. |
String |
getApplicationMode()
Return the Click application mode value: ["production", "profile", "development", "debug", "trace"]. |
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. |
Field Detail |
public static final String MODE_TRACE
public static final String MODE_DEBUG
public static final String MODE_DEVELOPMENT
public static final String MODE_PROFILE
public static final String MODE_PRODUCTION
public static final String ERROR_PATH
public static final String NOT_FOUND_PATH
public static final String CONTEXT_NAME
Method Detail |
public void onInit(ServletContext servletContext) throws Exception
servletContext
- the application servlet context
Exception
- if an error occurs initializing the ConfigurationServicepublic void onDestroy()
public FileUploadService getFileUploadService()
public TemplateService getTemplateService()
public String getApplicationMode()
public String getCharset()
public Class getErrorPageClass()
public Format createFormat()
public boolean isJspPage(String path)
path
- the Page ".htm" path
public boolean isPagesAutoBinding()
public boolean isProductionMode()
public boolean isProfileMode()
public Locale getLocale()
public LogService getLogService()
public String getPagePath(Class pageClass)
pageClass
- the class of the Page to lookup the path for
IllegalArgumentException
- if the Page Class is not configured
with a unique pathpublic Class getPageClass(String path)
path
- the page path
IllegalArgumentException
- if the Page Class for the path is not
foundpublic List getPageClassList()
public Map getPageFields(Class pageClass)
pageClass
- the page class
public Field getPageField(Class pageClass, String fieldName)
pageClass
- the page classfieldName
- the name of the field
public Field[] getPageFieldArray(Class pageClass)
pageClass
- the page class
public Map getPageHeaders(String path)
path
- the path of the page
public Class getNotFoundPageClass()
public ServletContext getServletContext()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |