Class BaseFactory
- java.lang.Object
-
- com.opensymphony.module.sitemesh.Factory
-
- com.opensymphony.module.sitemesh.factory.BaseFactory
-
- All Implemented Interfaces:
PageParserSelector
- Direct Known Subclasses:
DefaultFactory
public abstract class BaseFactory extends Factory
Base Factory implementation. Provides utility methods for implementation.- Version:
- $Revision: 1.9 $
- Author:
- Joe Walnes
-
-
Field Summary
Fields Modifier and Type Field Description protected ConfigconfigServletConfig or FilterConfig.protected DecoratorMapperdecoratorMapperInstance ofDecoratorMapper.protected PathMapperexcludeUrlsA map of paths that are excluded from decorationprotected MappageParsersMap that associates content-types with PageParser instances.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseFactory(Config config)Constructor for default implementation of Factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddExcludeUrl(String path)protected voidclearDecoratorMappers()Clear all current DecoratorMappers.protected voidclearExcludeUrls()Clears all exclude URLs.protected voidclearParserMappings()Clear all PageParser mappings.DecoratorMappergetDecoratorMapper()Return instance of DecoratorMapper.protected DecoratorMappergetDecoratorMapper(Class decoratorMapperClass)PageParsergetPageParser(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 voidmapParser(String contentType, String className)Map 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 Detail
-
config
protected Config config
ServletConfig or FilterConfig.
-
decoratorMapper
protected DecoratorMapper 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
protected Map pageParsers
Map that associates content-types with PageParser instances.
-
excludeUrls
protected PathMapper excludeUrls
A map of paths that are excluded from decoration
-
-
Constructor Detail
-
BaseFactory
protected BaseFactory(Config config)
Constructor for default implementation of Factory. Should never be called by client. Singleton instance should be obtained instead.
-
-
Method Detail
-
getDecoratorMapper
public DecoratorMapper getDecoratorMapper()
Return instance of DecoratorMapper.- Specified by:
getDecoratorMapperin classFactory
-
getPageParser
public PageParser getPageParser(String contentType)
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.- Specified by:
getPageParserin interfacePageParserSelector- Specified by:
getPageParserin classFactory- Parameters:
contentType- The MIME content-type of the data to be parsed- Returns:
- Appropriate
PageParserfor reading data, ornullif no suitable parser was found.
-
shouldParsePage
public boolean shouldParsePage(String contentType)
Determine whether a Page of given content-type should be parsed or not.- Specified by:
shouldParsePagein interfacePageParserSelector- Specified by:
shouldParsePagein classFactory
-
isPathExcluded
public boolean isPathExcluded(String path)
Returnstrueif the supplied path matches one of the exclude URLs specified in sitemesh.xml, otherwise returnsfalse.- Specified by:
isPathExcludedin classFactory- Parameters:
path-- Returns:
- whether the path is excluded
-
clearDecoratorMappers
protected void clearDecoratorMappers()
Clear all current DecoratorMappers.
-
pushDecoratorMapper
protected void pushDecoratorMapper(String className, Properties properties)
Push new DecoratorMapper onto end of chain.
-
getDecoratorMapper
protected DecoratorMapper getDecoratorMapper(Class decoratorMapperClass) throws InstantiationException, IllegalAccessException
-
clearParserMappings
protected void clearParserMappings()
Clear all PageParser mappings.
-
mapParser
protected void mapParser(String contentType, String className)
Map new PageParser to given content-type. contentType = null signifies default PageParser for unknown content-types.
-
addExcludeUrl
protected void addExcludeUrl(String path)
-
clearExcludeUrls
protected void clearExcludeUrls()
Clears all exclude URLs.
-
-