Conditional Logic around context element
I have been looking around and have not found much on conditional logic I can place into the context xml that would optionally add load-time-weaver.
For example, in WebSphere I want the line commented out
<!-- uncomment the following line to run in Tomcat locally
<context:load-time-weaver/>
-->
Yet, in Tomcat (i.e. our local development), I want the line active
<context:load-time-weaver/>
Is there a means to write something like
<if condition=${tomcatServer}>
<context:load-time-weaver/>
</if>
This is the ONLY line change in the entire config. Note: Please assume I would write something that would set the ${tomcatServer} variable
Any suggestions?
Using profiles for conditional configurations
My original problem was how to configure Spring to use the
<context:load-time-weaver/>
directive when using Tomcat and not to use it when running in say WebSphere or Jetty or WebLogic.
Here is the best solution I found. Please comment
1. Create two spring configurations.
projectname-config-weaver.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
</beans:beans>
projectname-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
Note: NO PROFILE, so this is active on all servers
In my case the web.xml has
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application-security.xml, /WEB-INF/projectname-config.xml, /WEB-INF/projectname-config-weaver.xml</param-value>
</context-param>
In the tomcat VM args I add
-Dspring.profiles.active=tomcat