see http://javahash.com/difference-between-servlet-init-and-context-parameter/ for background. Gist:
context-param variables are global and accessible through the ServletContext. init-param variables are configured per servlet.
E.g. the org.springframework.web.servlet.DispatcherServlet can be explicitely set to use a particular application context file via init-param, i.e. setting the contextConfigLocation variable (which overrides the default <servlet-name>-context.xml)
Conversely, to register a Spring Security application context, Spring can make use of a contextConfigLocation global context-param variable which it reads via a listener: org.springframework.web.context.ContextLoaderListener -- which is also a handy way to bootstrap a Spring application on Tomcat startup. Note that the Spring Security bootstrap mechanism also relies on adding a filter: org.springframework.web.filter.DelegatingFilterProxy.
Showing posts with label Spring. Show all posts
Showing posts with label Spring. Show all posts
Thursday, June 2, 2016
Wednesday, December 16, 2015
12/16/2015
Learned
-about using joda time's DateTime to parse a UTC date.
-about using Apache Commons XMLConfiguration to drive strategy
-about one pattern for using strategies in a Java Spring Application:
in beans file add:
<bean id="byWhichMeansStrategyFactory" class="com.awgtek.byWhichMeansStrategyFactory" factory-method="createStrategy">
<constructor-arg index="0" ref="myXmlConfig" />
<constructor-arg index="1" type="java.lang.String">
<value>this_means</value>
</constructor-arg>
</bean>
<bean id="MyImpl" class="com.awgtek.DoesSomethingImpl">
<constructor-arg index="0" ref="byWhichMeansStrategyFactory" />
</bean>
-about using Guava, e.g. to import static com.google.common.base.Preconditions.checkNotNull to do checkNotNull statements where needed.
-about using joda time's DateTime to parse a UTC date.
-about using Apache Commons XMLConfiguration to drive strategy
-about one pattern for using strategies in a Java Spring Application:
in beans file add:
<bean id="byWhichMeansStrategyFactory" class="com.awgtek.byWhichMeansStrategyFactory" factory-method="createStrategy">
<constructor-arg index="0" ref="myXmlConfig" />
<constructor-arg index="1" type="java.lang.String">
<value>this_means</value>
</constructor-arg>
</bean>
<bean id="MyImpl" class="com.awgtek.DoesSomethingImpl">
<constructor-arg index="0" ref="byWhichMeansStrategyFactory" />
</bean>
The createStrategy method would instantiate the correct strategy class basd on the "this_means" value. The injected strategy would then be used to e.g. pick a consultant either through "cheapness" defined by some parameters in the strategy or skill, etc. see http://blog.lowendahl.net/design-patterns/strategy-pattern/
Subscribe to:
Posts (Atom)