|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.click.service.XmlConfigService
public class XmlConfigService
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 seeConfigService for more details.
| Nested Class Summary | |
|---|---|
static class |
XmlConfigService.ExcludePage
Provide an Excluded Page class. |
| Nested classes/interfaces inherited from interface org.apache.click.service.ConfigService |
|---|
ConfigService.AutoBinding |
| Field Summary |
|---|
| Fields inherited from interface org.apache.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"]. |
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. |
protected Class<? extends Page> |
getPageClass(String pagePath,
String pagesPackage)
Find and return the page class for the specified pagePath and pagesPackage. |
List |
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. |
protected boolean |
isResourcesDeployable()
Returns true if Click resources (JavaScript, CSS, images etc) packaged in jars can be deployed to the root directory of the webapp, false otherwise. |
boolean |
isTemplate(String path)
Return true if the given path 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. |
InputSource |
resolveEntity(String publicId,
String systemId)
This method resolves the click.dtd for the XML parser using the classpath resource: /org/apache/click/click.dtd. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XmlConfigService()
| Method Detail |
|---|
public void onInit(ServletContext servletContext)
throws Exception
ConfigService
onInit in interface ConfigServiceservletContext - the application servlet context
Exception - if an error occurs initializing the applicationConfigService.onInit(ServletContext)public void onDestroy()
ConfigService
onDestroy in interface ConfigServiceConfigService.onDestroy()public String getApplicationMode()
getApplicationMode in interface ConfigServicepublic String getCharset()
ConfigService
getCharset in interface ConfigServiceConfigService.getCharset()public FileUploadService getFileUploadService()
ConfigService
getFileUploadService in interface ConfigServiceConfigService.getFileUploadService()public LogService getLogService()
ConfigService
getLogService in interface ConfigServiceConfigService.getLogService()public ResourceService getResourceService()
ConfigService
getResourceService in interface ConfigServiceConfigService.getResourceService()public TemplateService getTemplateService()
ConfigService
getTemplateService in interface ConfigServiceConfigService.getTemplateService()public MessagesMapService getMessagesMapService()
ConfigService
getMessagesMapService in interface ConfigServiceConfigService.getMessagesMapService()public Format createFormat()
ConfigService
createFormat in interface ConfigServiceConfigService.createFormat()public Locale getLocale()
ConfigService
getLocale in interface ConfigServiceConfigService.getLocale()public ConfigService.AutoBinding getAutoBindingMode()
ConfigService
getAutoBindingMode in interface ConfigServiceConfigService.getAutoBindingMode()public boolean isProductionMode()
ConfigService
isProductionMode in interface ConfigServiceConfigService.isProductionMode()public boolean isProfileMode()
ConfigService
isProfileMode in interface ConfigServiceConfigService.isProfileMode()public boolean isJspPage(String path)
ConfigService
isJspPage in interface ConfigServicepath - the Page ".htm" path
ConfigService.isJspPage(String)public boolean isTemplate(String path)
public class MyConfigService extends XmlConfigService {
protected boolean isTemplate(String path) {
// invoke default implementation
boolean isTemplate = super.isTemplate(path);
if (!isTemplate) {
// If path has an .xml extension, mark it as a template
isTemplate = path.endsWith(".xml");
}
return isTemplate;
}
}
Here is an example web.xml showing how to configure a custom
ConfigService through the context parameter config-service-class.
We also map *.xml requests to be routed through ClickServlet:
<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">
<!-- Specify a custom ConfigService through the context param 'config-service-class' -->
<context-param>
<param-name>config-service-class</param-name>
<param-value>com.mycorp.service.MyConfigSerivce</param-value>
</context-param>
<servlet>
<servlet-name>ClickServlet</servlet-name>
<servlet-class>org.apache.click.ClickServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- NOTE: we still map the .htm extension -->
<servlet-mapping>
<servlet-name>ClickServlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<!-- NOTE: we also map .xml extension in order to route xml requests to the ClickServlet -->
<servlet-mapping>
<servlet-name>ClickServlet</servlet-name>
<url-pattern>*.xml</url-pattern>
</servlet-mapping>
...
</web-app>
Please note: even though you can add extra template mappings by
overriding this method, it is still recommended to keep the default
.htm mapping by invoking super.isTemplate(String).
The reason being that Click ships with some default templates such as
ConfigService.ERROR_PATH and ConfigService.NOT_FOUND_PATH
that must be mapped as .htm.
Please see the ConfigService javadoc for details
on how to configure a custom ConfigService implementation.
isTemplate in interface ConfigServicepath - the path to check if it is a Page class template or not
ConfigService.isTemplate(String)public Class<? extends Page> getPageClass(String path)
ConfigService
getPageClass in interface ConfigServicepath - the page path
ConfigService.getPageClass(String)public String getPagePath(Class<? extends Page> pageClass)
ConfigService
getPagePath in interface ConfigServicepageClass - the page class
IllegalArgumentException - if the Page Class is not configured
with a unique pathConfigService.getPagePath(Class)public List getPageClassList()
ConfigService
getPageClassList in interface ConfigServiceConfigService.getPageClassList()public Map<String,Object> getPageHeaders(String path)
ConfigService
getPageHeaders in interface ConfigServicepath - the path of the page
ConfigService.getPageHeaders(String)public Class<? extends Page> getNotFoundPageClass()
ConfigService
getNotFoundPageClass in interface ConfigServiceConfigService.getNotFoundPageClass()public Class<? extends Page> getErrorPageClass()
ConfigService
getErrorPageClass in interface ConfigServiceConfigService.getErrorPageClass()
public Field getPageField(Class<? extends Page> pageClass,
String fieldName)
ConfigService
getPageField in interface ConfigServicepageClass - the page classfieldName - the name of the field
ConfigService.getPageField(Class, String)public Field[] getPageFieldArray(Class<? extends Page> pageClass)
ConfigService
getPageFieldArray in interface ConfigServicepageClass - the page class
ConfigService.getPageFieldArray(Class)public Map<String,Field> getPageFields(Class<? extends Page> pageClass)
ConfigService
getPageFields in interface ConfigServicepageClass - the page class
ConfigService.getPageFields(Class)public List<PageInterceptor> getPageInterceptors()
ConfigService
getPageInterceptors in interface ConfigServiceConfigService.getPageInterceptors()public ServletContext getServletContext()
ConfigService
getServletContext in interface ConfigServiceConfigService.getServletContext()
public InputSource resolveEntity(String publicId,
String systemId)
throws SAXException,
IOException
resolveEntity in interface EntityResolverpublicId - the DTD public idsystemId - the DTD system id
SAXException - if an error occurs parsing the document
IOException - if an error occurs reading the documentEntityResolver.resolveEntity(String, String)
protected Class<? extends Page> getPageClass(String pagePath,
String pagesPackage)
pagePath - the path used for matching against a page class namepagesPackage - the package of the page class
protected boolean isResourcesDeployable()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||