public abstract class XmlDocConfigurationProvider extends Object implements ConfigurationProvider
ConfigurationProvider
for loading configuration from a parsed
XML document
. By extending this class, configuration can be loaded from any source that an XML
document can be parsed from. Note that this class does not validate the document against any provided DTDs. For
loading configuration from an XML file with DTD validation, please see
StrutsXmlConfigurationProvider
.Modifier and Type | Field and Description |
---|---|
protected Set<Class<?>> |
allowlistClasses |
protected Configuration |
configuration |
protected Map<String,Element> |
declaredPackages |
protected List<Document> |
documents |
protected Map<String,String> |
dtdMappings |
protected ObjectFactory |
objectFactory |
protected ProviderAllowlist |
providerAllowlist |
protected boolean |
throwExceptionOnDuplicateBeans |
protected ValueSubstitutor |
valueSubstitutor |
Constructor and Description |
---|
XmlDocConfigurationProvider(Document... documents) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAction(Element actionElement,
PackageConfig.Builder packageContext) |
protected static void |
addAllowedMethodsToSet(Node allowedMethodsNode,
Set<String> allowedMethodsSet) |
protected PackageConfig |
addPackage(Element packageElement)
Create a PackageConfig from an XML element representing it.
|
protected void |
addResultTypes(PackageConfig.Builder packageContext,
Element element) |
protected Class<?> |
allowAndLoadClass(String className) |
protected ActionConfig |
buildActionConfig(Element actionElement,
Location location,
PackageConfig.Builder packageContext,
Map<String,ResultConfig> results) |
protected Set<String> |
buildAllowedMethods(Element element,
PackageConfig.Builder packageContext) |
protected List<ExceptionMappingConfig> |
buildExceptionMappings(Element element)
Build a list of exception mapping objects from below a given XML element.
|
protected List<ExceptionMappingConfig> |
buildExceptionMappings(Element element,
PackageConfig.Builder packageContext)
Deprecated.
since 6.2.0, use
buildExceptionMappings(Element) |
protected InterceptorConfig |
buildInterceptorConfig(Element interceptorElement) |
protected List<InterceptorMapping> |
buildInterceptorList(Element element,
PackageConfig.Builder context) |
protected PackageConfig.Builder |
buildPackageContext(Element packageElement)
This method builds a package context by looking for the parents of this new package.
|
protected ResultConfig |
buildResultConfig(String name,
ResultTypeConfig config,
Location location,
Map<String,String> params) |
protected Map<String,String> |
buildResultParams(Element resultElement,
ResultTypeConfig config) |
protected Map<String,ResultConfig> |
buildResults(Element element,
PackageConfig.Builder packageContext)
Build a map of ResultConfig objects from below a given XML element.
|
protected ResultTypeConfig |
buildResultTypeConfig(Element resultTypeElement,
Location location,
String paramName) |
void |
destroy()
Called before removed from the configuration manager
|
Map<String,String> |
getDtdMappings()
Returns an unmodifiable map of DTD mappings
|
protected static String |
guessResultType(String type) |
void |
init(Configuration configuration)
Initializes with the configuration
|
static void |
iterateChildren(Node node,
Consumer<Node> function) |
static void |
iterateChildrenByTagName(Element el,
String tagName,
Consumer<Element> function) |
static void |
iterateElementChildren(Document doc,
Consumer<Element> function) |
static void |
iterateElementChildren(Node node,
Consumer<Element> function) |
protected Class<?> |
loadClass(String className) |
protected void |
loadDefaultActionRef(PackageConfig.Builder packageContext,
Element element) |
protected void |
loadDefaultClassRef(PackageConfig.Builder packageContext,
Element element) |
protected void |
loadDefaultInterceptorRef(PackageConfig.Builder packageContext,
Element element) |
protected void |
loadExtraConfiguration(Document doc)
Allows subclasses to load extra information from the document
|
protected void |
loadGlobalAllowedMethods(PackageConfig.Builder packageContext,
Element packageElement) |
protected void |
loadGlobalExceptionMappings(PackageConfig.Builder packageContext,
Element packageElement)
Load all the global results for this package from the XML element.
|
protected void |
loadGlobalResults(PackageConfig.Builder packageContext,
Element packageElement)
Load all the global results for this package from the XML element.
|
protected void |
loadInterceptors(PackageConfig.Builder context,
Element element) |
protected InterceptorStackConfig |
loadInterceptorStack(Element element,
PackageConfig.Builder context) |
protected void |
loadInterceptorStacks(Element element,
PackageConfig.Builder context) |
void |
loadPackages()
Loads the packages for the configuration.
|
protected List<InterceptorMapping> |
lookupInterceptorReference(PackageConfig.Builder context,
Element interceptorRefElement)
Looks up the Interceptor Class from the interceptor-ref name and creates an instance, which is added to the
provided List, or, if this is a ref to a stack, it adds the Interceptor instances from the List to this stack.
|
boolean |
needsReload()
Tells whether the ContainerProvider should reload its configuration
|
void |
register(ContainerBuilder containerBuilder,
LocatableProperties props)
Registers beans and properties for the Container
|
protected void |
registerBean(Element child,
Map<String,Node> loadedBeans,
ContainerBuilder containerBuilder) |
protected void |
registerBeanSelection(Element child,
ContainerBuilder containerBuilder,
LocatableProperties props) |
protected void |
registerConstant(Element child,
LocatableProperties props) |
protected void |
registerUnknownHandlerStack(Element child) |
void |
setDtdMappings(Map<String,String> mappings) |
void |
setObjectFactory(ObjectFactory objectFactory) |
void |
setProviderAllowlist(ProviderAllowlist providerAllowlist) |
void |
setThrowExceptionOnDuplicateBeans(boolean val) |
void |
setValueSubstitutor(ValueSubstitutor valueSubstitutor) |
protected void |
verifyAction(String className,
Location loc) |
protected boolean |
verifyAction(String className,
String name,
Location loc)
Deprecated.
since 6.2.0, use
verifyAction(String, Location) |
protected void |
verifyInterceptor(String className,
Location loc) |
protected Class<?> |
verifyResultType(String className,
Location loc) |
protected ObjectFactory objectFactory
protected Configuration configuration
protected ProviderAllowlist providerAllowlist
protected boolean throwExceptionOnDuplicateBeans
protected ValueSubstitutor valueSubstitutor
public XmlDocConfigurationProvider(Document... documents)
public void setObjectFactory(ObjectFactory objectFactory)
public void setValueSubstitutor(ValueSubstitutor valueSubstitutor)
public void setProviderAllowlist(ProviderAllowlist providerAllowlist)
public void setThrowExceptionOnDuplicateBeans(boolean val)
public Map<String,String> getDtdMappings()
public void init(Configuration configuration)
ContainerProvider
init
in interface ContainerProvider
init
in interface PackageProvider
configuration
- The configurationpublic void destroy()
ContainerProvider
destroy
in interface ContainerProvider
protected Class<?> allowAndLoadClass(String className) throws ClassNotFoundException
ClassNotFoundException
protected Class<?> loadClass(String className) throws ClassNotFoundException
ClassNotFoundException
public static void iterateElementChildren(Document doc, Consumer<Element> function)
public static void iterateElementChildren(Node node, Consumer<Element> function)
public static void iterateChildrenByTagName(Element el, String tagName, Consumer<Element> function)
public void register(ContainerBuilder containerBuilder, LocatableProperties props) throws ConfigurationException
ContainerProvider
register
in interface ContainerProvider
containerBuilder
- The builder to register beans withprops
- The properties to register constants withConfigurationException
- If anything goes wrongprotected void registerBeanSelection(Element child, ContainerBuilder containerBuilder, LocatableProperties props)
protected void registerBean(Element child, Map<String,Node> loadedBeans, ContainerBuilder containerBuilder)
protected void registerConstant(Element child, LocatableProperties props)
protected void registerUnknownHandlerStack(Element child)
public boolean needsReload()
ContainerProvider
needsReload
in interface ContainerProvider
needsReload
in interface PackageProvider
public void loadPackages() throws ConfigurationException
PackageProvider
loadPackages
in interface PackageProvider
ConfigurationException
- in case of configuration errorsprotected void loadExtraConfiguration(Document doc)
doc
- The configuration documentprotected PackageConfig addPackage(Element packageElement) throws ConfigurationException
packageElement
- the given XML elementConfigurationException
- in case of configuration errorsprotected void addAction(Element actionElement, PackageConfig.Builder packageContext) throws ConfigurationException
ConfigurationException
protected ActionConfig buildActionConfig(Element actionElement, Location location, PackageConfig.Builder packageContext, Map<String,ResultConfig> results)
@Deprecated protected boolean verifyAction(String className, String name, Location loc)
verifyAction(String, Location)
protected void addResultTypes(PackageConfig.Builder packageContext, Element element)
protected ResultTypeConfig buildResultTypeConfig(Element resultTypeElement, Location location, String paramName)
protected PackageConfig.Builder buildPackageContext(Element packageElement)
This method builds a package context by looking for the parents of this new package.
If no parents are found, it will return a root package.
packageElement
- the package elementprotected Map<String,ResultConfig> buildResults(Element element, PackageConfig.Builder packageContext)
element
- the given XML elementpackageContext
- the package contextprotected ResultConfig buildResultConfig(String name, ResultTypeConfig config, Location location, Map<String,String> params)
protected Map<String,String> buildResultParams(Element resultElement, ResultTypeConfig config)
@Deprecated protected List<ExceptionMappingConfig> buildExceptionMappings(Element element, PackageConfig.Builder packageContext)
buildExceptionMappings(Element)
protected List<ExceptionMappingConfig> buildExceptionMappings(Element element)
element
- the given XML elementprotected Set<String> buildAllowedMethods(Element element, PackageConfig.Builder packageContext)
protected void loadDefaultActionRef(PackageConfig.Builder packageContext, Element element)
protected void loadGlobalResults(PackageConfig.Builder packageContext, Element packageElement)
packageContext
- the package contextpackageElement
- the given XML elementprotected void loadGlobalAllowedMethods(PackageConfig.Builder packageContext, Element packageElement)
protected static void addAllowedMethodsToSet(Node allowedMethodsNode, Set<String> allowedMethodsSet)
protected void loadDefaultClassRef(PackageConfig.Builder packageContext, Element element)
protected void loadGlobalExceptionMappings(PackageConfig.Builder packageContext, Element packageElement)
packageContext
- the package contextpackageElement
- the given XML elementprotected List<InterceptorMapping> buildInterceptorList(Element element, PackageConfig.Builder context) throws ConfigurationException
ConfigurationException
protected void loadInterceptors(PackageConfig.Builder context, Element element) throws ConfigurationException
ConfigurationException
protected InterceptorConfig buildInterceptorConfig(Element interceptorElement)
protected void loadInterceptorStacks(Element element, PackageConfig.Builder context) throws ConfigurationException
ConfigurationException
protected InterceptorStackConfig loadInterceptorStack(Element element, PackageConfig.Builder context) throws ConfigurationException
ConfigurationException
protected List<InterceptorMapping> lookupInterceptorReference(PackageConfig.Builder context, Element interceptorRefElement) throws ConfigurationException
context
- The PackageConfig to look up the interceptor frominterceptorRefElement
- Element to pull interceptor ref data fromConfigurationException
- in case of configuration errorsprotected void loadDefaultInterceptorRef(PackageConfig.Builder packageContext, Element element)
Copyright © 2000–2024 Apache Software Foundation. All rights reserved.