I have a web application that works with many different configurations of Spring Security. However, these inter configurations are all setup in my application context configuration file. Therefore, to tweak them on a customer site, they have to be modified inside the war file. If the customer manually modifies the war file, then they will lose their changes after the deployment of a new war.
Is there a way to externate this configuration? Is there any way that I can load the configuration using JNDI in any way?
This is an interesting question as the spring security should be configured in the root webpop context, The configuration can not be externally in other contexts. Apart from this, you can not change the set of conference resources from within the context. Therefore, you should do it from the outside:
-
You can use a well-known file system location:
& lt; Context-param & gt; & Lt; Ultimate Name & gt; ContextConfigLocation & lt; / Lastname & gt; & Lt; Ultimate Price & gt; /WEB-INF/applicationContext.xml File: ///.c: \ config.xml & lt; / Param-value & gt; & Lt; / Reference param & gt;
-
System properties are resolved in
contextConfigLocation
, so you can use it:< Code> & lt; Context param & gt; & Lt; Ultimate Name & gt; ContextConfigLocation & lt; / Lastname & gt; & Lt; Ultimate Price & gt; /WEB-INF/applicationContext.xml file: /// $ {configPath} & lt; / Ultimate-value & gt; & Lt; / Reference param & gt;
and
-DconfigPath = ...
-
You can override
XmlWebApplicationContext.getResource ()
and apply whatever you want:Public class MyXmlWebApplicationContext XmlWebApplicationContext Extended {Personal Static Last String JNDI_PREFIX = "jndi: /"; @override public resource resource resource (string location) {if (location.startsWith (JNDI_PREFIX)) getJndiResource (location); And in turn super.getResource (location); } Protected resource getJndiResource (string location) {...}}
and
& lt; Context-param & gt; & Lt; Ultimate Name & gt; ContextConfigLocation & lt; / Lastname & gt; & Lt; Ultimate Price & gt; /WEB-INF/applicationContext.xml jndi: / ... & lt; / Ultimate-value & gt; & Lt; / Reference param & gt; & Lt; Context param & gt; & Lt; Ultimate Name & gt; ContextClass & lt; / Lastname & gt; & Lt; Ultimate Price & gt; Com.example.MyXmlWebApplicationContext & lt; / Super-valued & gt; & Lt; / Reference param & gt;
Comments
Post a Comment