Class BaseFactory
java.lang.Object
com.opensymphony.module.sitemesh.Factory
com.opensymphony.module.sitemesh.factory.BaseFactory
- All Implemented Interfaces:
PageParserSelector
- Direct Known Subclasses:
DefaultFactory
Base Factory implementation. Provides utility methods for implementation.
- Author:
- Joe Walnes
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConfigThe config is of type ServletConfig or FilterConfig.protected DecoratorMapperInstance ofDecoratorMapper.protected PathMapperA map of paths that are excluded from decoration.Map that associates content-types with PageParser instances. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseFactory(Config config) Constructor for default implementation of Factory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddExcludeUrl(String path) Adds the exclude url.protected voidClear all current DecoratorMappers.protected voidClears all exclude URLs.protected voidClear all PageParser mappings.Return instance of DecoratorMapper.protected DecoratorMappergetDecoratorMapper(Class<?> decoratorMapperClass) Gets the decorator mapper.getPageParser(String contentType) Create a PageParser suitable for the given content-type.booleanisPathExcluded(String path) Returnstrueif the supplied path matches one of the exclude URLs specified in sitemesh.xml, otherwise returnsfalse.protected voidMap new PageParser to given content-type.protected voidpushDecoratorMapper(String className, Properties properties) Push new DecoratorMapper onto end of chain.booleanshouldParsePage(String contentType) Determine whether a Page of given content-type should be parsed or not.Methods inherited from class com.opensymphony.module.sitemesh.Factory
getInstance, refresh
-
Field Details
-
config
The config is of type ServletConfig or FilterConfig. -
decoratorMapper
Instance ofDecoratorMapper. Because it is thread-safe, it can be shared by multiple clients. This is only the last DecoratorMapper in the chain, and all parents will be automatically delegated to it. -
pageParsers
Map that associates content-types with PageParser instances. -
excludeUrls
A map of paths that are excluded from decoration.
-
-
Constructor Details
-
BaseFactory
Constructor for default implementation of Factory. Should never be called by client. Singleton instance should be obtained instead.- Parameters:
config- the config- See Also:
-
-
Method Details
-
getDecoratorMapper
Return instance of DecoratorMapper.- Specified by:
getDecoratorMapperin classFactory- Returns:
- the decorator mapper
-
getPageParser
Create a PageParser suitable for the given content-type.For example, if the supplied parameter is
text/htmla parser shall be returned that can parse HTML accordingly. Returns null if no parser can be found for the supplied content type.- Parameters:
contentType- The MIME content-type of the data to be parsed- Returns:
- Appropriate
PageParserfor reading data, ornullif no suitable parser was found.
-
shouldParsePage
Determine whether a Page of given content-type should be parsed or not.- Parameters:
contentType- the content type- Returns:
- true, if successful
-
isPathExcluded
Returnstrueif the supplied path matches one of the exclude URLs specified in sitemesh.xml, otherwise returnsfalse.- Specified by:
isPathExcludedin classFactory- Parameters:
path- The path.- Returns:
- whether the path is excluded
-
clearDecoratorMappers
protected void clearDecoratorMappers()Clear all current DecoratorMappers. -
pushDecoratorMapper
Push new DecoratorMapper onto end of chain.- Parameters:
className- the class nameproperties- the properties
-
getDecoratorMapper
protected DecoratorMapper getDecoratorMapper(Class<?> decoratorMapperClass) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException Gets the decorator mapper.- Parameters:
decoratorMapperClass- the decorator mapper class- Returns:
- the decorator mapper
- Throws:
InstantiationException- the instantiation exceptionIllegalAccessException- the illegal access exceptionInvocationTargetException- the invocation target exceptionNoSuchMethodException- the no such method exception
-
clearParserMappings
protected void clearParserMappings()Clear all PageParser mappings. -
mapParser
Map new PageParser to given content-type. contentType = null signifies default PageParser for unknown content-types.- Parameters:
contentType- the content typeclassName- the class name
-
addExcludeUrl
Adds the exclude url.- Parameters:
path- the path
-
clearExcludeUrls
protected void clearExcludeUrls()Clears all exclude URLs.
-