Thanks Levi, I hadn't thought of that. I went down the road of subclassing the
classes (action resolver, action bean context factory, etc) but this didn't
feel right, too much code for such a small thing. Your approach worked a
little better, thank you. In a few months were going to get to using the new
ObjectFactory for everything. So these types of problems should work
themselves out and most of this glue/bootstrap code will be gone once
everything is in the spring container.
+++ Configuration.java (working copy)
+ @Override
+ public void
setBootstrapPropertyResolver(BootstrapPropertyResolver resolver) {
+ BootstrapPropertiesResolver wrappedResolver =
SpringUtil.getInstance()
+
.getBean(BootstrapPropertiesResolver.class); // bean lookup
might go away after the ObjectFactory changes
+ wrappedResolver.setResolver(resolver);
+
super.setBootstrapPropertyResolver(wrappedResolver);
+ }
+++ BootstrapPropertiesResolver.java (revision 0)
+public class BootstrapPropertiesResolver extends BootstrapPropertyResolver {
+
+ private ResourceBundle appProperties;
+ public void setAppProperties(ResourceBundle appProperties) {
+ this.appProperties = appProperties;
+ }
+
+ private Map<String, String> stripesPropertiesInBundle;
+ public void setStripesPropertiesInBundle(
+ Map<String, String>
stripesPropertiesInBundle) {
+ this.stripesPropertiesInBundle =
stripesPropertiesInBundle;
+ }
+
+ private BootstrapPropertyResolver resolver;
+ public void setResolver(BootstrapPropertyResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ public BootstrapPropertiesResolver() {
+ super(null);
+ }
+
+ @Override
+ public String getProperty(String key) {
+ String defaultValue = resolver.getProperty(key);
+ if ((defaultValue == null ||
"".equals(defaultValue))
+ &&
stripesPropertiesInBundle.containsKey(key)) {
+ return
appProperties.getString(stripesPropertiesInBundle.get(key));
+ }
+ return defaultValue;
+ }
+
+ @Override
+ public FilterConfig getFilterConfig() {
+ return resolver.getFilterConfig();
+ }
+
+}
+++ web.xml (working copy)
-
<param-name>ActionResolver.Packages</param-name>
- <param-value>
- ${actionPackages}
- </param-value>
- </init-param>
- <init-param>
-
<param-name>ActionBeanContext.Class</param-name>
-
<param-value>${actionBeanContextClass}</param-value>
- </init-param>
- <init-param>
-
<param-name>Interceptor.Classes</param-name>
- <param-value>
-
${interceptorClasses}
- </param-value>
- </init-param>
+++Spring-Web.xml (working copy)
+ <bean id="bootstrapPropertyResolver"
class="x.BootstrapPropertiesResolver">
+ <property name="appProperties"
ref="appProperties" />
+ <property name="stripesPropertiesInBundle">
+ <util:map
key-type="java.lang.String" value-type="java.lang.String">
+ <entry
key="ActionResolver.Packages" value="stripesConfig.actionPackages" />
+ <entry
key="ActionBeanContext.Class" value=" stripesConfig.actionBeanContextClass" />
+ <entry
key="Interceptor.Classes" value=" stripesConfig.interceptorClasses" />
+ </util:map>
+ </property>
+ </bean>
From: Levi Hoogenberg [mailto:[email protected]]
Sent: Tuesday, April 07, 2009 2:47 PM
To: Stripes Users List
Subject: Re: [Stripes-users] Can I get <init-params> out of web.xml?
(BootstrapPropertyResolver)
Hi John,
when looking at DefaultConfiguration, wouldn't it be possible to wrap the
BootstrapPropertyResolver passed to setBootstrapPropertyResolver in your
RuntimeConfiguration subclass? So you'd have something like
@Override
public void setBootstrapPropertyResolver(BootstrapPropertyResolver
resolver) {
super.setBootstrapPropertyResolver(DecoratedBootstrapPropertyResolver(resolver));
}
That way, you could override certain properties, whereas you can fall back to
the default bootstrap property resolver when needed.
Regards,
Levi
On Tue, Apr 7, 2009 at 4:47 PM, Newman, John W
<[email protected]<mailto:[email protected]>> wrote:
Hello,
We are currently revisiting all this property file/filtering mess in our app.
One thing we had setup was to put all config settings in a master property
file, and use maven resource filtering in web.xml.
<init-param>
<param-name>ActionResolver.Packages</param-name>
<param-value>
${stripes.actionPackages}
</param-value>
</init-param>
<init-param>
<param-name>ActionBeanContext.Class</param-name>
<param-value>${stripes.actionBeanContextClass}</param-value>
</init-param>
<init-param>
<param-name>Interceptor.Classes</param-name>
<param-value>
${stripes.interceptorClasses}
</param-value>
</init-param>
We used to have these hard coded, but they started changing from env to env so
we moved them into our filter files. Now we are experimenting with some
cleaner spring classes for this, but we're not able to get web.xml filtered
like that. So I'm looking to remove these settings from here, and set them in
the code of our Configuration subclass with
appProperties.getString("stripes.actionPackages")
However digging through the stripes code a bit it appears this is not possible?
Configuration just grabs the BootstrapPropertyResolver and goes through
web-xml etc. It doesn't appear there is a way to customize this behavior? It
looks like they must be specified in web.xml. Can I just put dummy values in
there and change them at a later point?
Also if anyone knows of a simple easy best practice solution for international,
multi env app property management please share. We haven't really run across a
tried and true best practice approach for this, it seems like everyone does
something different and it ends up getting tricky in the end.
Thanks
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Stripes-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users