|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConfigService
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 "org.apache.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.CustomConfigService:
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>
Nested Class Summary | |
---|---|
static class |
ConfigService.AutoBinding
The page auto binding mode. |
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"]. |
ConfigService.AutoBinding |
getAutoBindingMode()
Return the page auto binding mode. |
String |
getCharset()
Return the Click application charset or null if not defined. |
Class<? extends Page> |
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 application log service. |
MessagesMapService |
getMessagesMapService()
Return the application messages map service. |
Class<? extends Page> |
getNotFoundPageClass()
Return the page not found Page Class. |
Class<? extends Page> |
getPageClass(String path)
Return the page Class for the given path. |
List<Class<? extends Page>> |
getPageClassList()
Return the list of configured page classes. |
Field |
getPageField(Class<? extends Page> pageClass,
String fieldName)
Return the bindable field of the given name for the pageClass, or null if not defined. |
Field[] |
getPageFieldArray(Class<? extends Page> pageClass)
Return an array bindable for the given page class. |
Map<String,Field> |
getPageFields(Class<? extends Page> pageClass)
Return Map of bindable fields for the given page class. |
Map<String,Object> |
getPageHeaders(String path)
Return the headers of the page for the given path. |
List<PageInterceptor> |
getPageInterceptors()
Return the list of configured PageInterceptors instances. |
String |
getPagePath(Class<? extends Page> pageClass)
Return the path for the given page Class. |
ResourceService |
getResourceService()
Return the application resource service. |
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 |
isProductionMode()
Return true if the application is in "production" mode. |
boolean |
isProfileMode()
Return true if the application is in "profile" mode. |
boolean |
isTemplate(String path)
Return true if the given resource is a Page class template, false otherwise. |
void |
onDestroy()
Destroy the ConfigurationService. |
void |
onInit(ServletContext servletContext)
Initialize the ConfigurationService with the given application servlet context. |
Field Detail |
---|
static final String MODE_TRACE
static final String MODE_DEBUG
static final String MODE_DEVELOPMENT
static final String MODE_PROFILE
static final String MODE_PRODUCTION
static final String ERROR_PATH
static final String NOT_FOUND_PATH
static final String CONTEXT_NAME
Method Detail |
---|
void onInit(ServletContext servletContext) throws Exception
servletContext
- the application servlet context
Exception
- if an error occurs initializing the ConfigurationServicevoid onDestroy()
FileUploadService getFileUploadService()
LogService getLogService()
ResourceService getResourceService()
TemplateService getTemplateService()
MessagesMapService getMessagesMapService()
String getApplicationMode()
String getCharset()
Class<? extends Page> getErrorPageClass()
Format createFormat()
boolean isJspPage(String path)
path
- the Page ".htm" path
boolean isTemplate(String path)
public class XmlConfigService implements ConfigService { ... public boolean isTemplate(String path) { if (path.endsWith(".htm") || path.endsWith(".jsp")) { return true; } return false; } ... }
path
- the path to check if it is a Page class template or not
ConfigService.AutoBinding getAutoBindingMode()
boolean isProductionMode()
boolean isProfileMode()
Locale getLocale()
String getPagePath(Class<? extends Page> pageClass)
pageClass
- the class of the Page to lookup the path for
IllegalArgumentException
- if the Page Class is not configured
with a unique pathClass<? extends Page> getPageClass(String path)
path
- the page path
IllegalArgumentException
- if the Page Class for the path is not
foundList<Class<? extends Page>> getPageClassList()
Map<String,Field> getPageFields(Class<? extends Page> pageClass)
pageClass
- the page class
Field getPageField(Class<? extends Page> pageClass, String fieldName)
pageClass
- the page classfieldName
- the name of the field
Map<String,Object> getPageHeaders(String path)
path
- the path of the page
Field[] getPageFieldArray(Class<? extends Page> pageClass)
pageClass
- the page class
List<PageInterceptor> getPageInterceptors()
Class<? extends Page> getNotFoundPageClass()
ServletContext getServletContext()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |