Changeset 3916
- Timestamp:
- 10/10/08 18:37:36 (4 years ago)
- Location:
- trunk/pfixcore
- Files:
-
- 13 added
- 12 modified
-
ChangeLog (modified) (1 diff)
-
projects/core/build/create_serverxml.xsl (modified) (3 diffs)
-
projects/core/schema/context-xml-service-config.xsd (modified) (1 diff)
-
projects/sample1/conf/config.conf.xml (modified) (1 diff)
-
projects/sample1/conf/spring.xml (modified) (1 diff)
-
refresh.sh (added)
-
reload.sh (added)
-
res/META-INF/org/pustefixframework/config/project/parser/project-config.xml (modified) (3 diffs)
-
skel/build-skel.xml (modified) (7 diffs)
-
skel/refresh.sh (added)
-
skel/reload.sh (added)
-
skel/startTomcat.sh (modified) (3 diffs)
-
skel/startup.properties.sample (added)
-
src/de/schlund/pfixcore/example/ContextAdultInfo.java (modified) (2 diffs)
-
src/de/schlund/pfixcore/example/TestData.java (added)
-
src/org/pustefixframework/admin/WebappAdminClient.java (added)
-
src/org/pustefixframework/admin/mbeans/WebappAdmin.java (added)
-
src/org/pustefixframework/admin/mbeans/WebappAdminMBean.java (added)
-
src/org/pustefixframework/config/project/parser/PustefixContextXMLRequestHandlerParsingHandler.java (modified) (2 diffs)
-
src/org/pustefixframework/config/project/parser/WebappAdminParsingHandler.java (added)
-
src/org/pustefixframework/http/AbstractPustefixRequestHandler.java (modified) (4 diffs)
-
src/org/pustefixframework/tools (added)
-
src/org/pustefixframework/tools/TomcatStartupConfigurator.java (added)
-
startTomcat.sh (modified) (2 diffs)
-
startup.properties.sample (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pfixcore/ChangeLog
r3915 r3916 1 2008-10-08 Martin Leidig <mleidig@schlund.de> 2 3 Added support for Webapp reloading and Spring application context 4 refreshing. Reloading/refreshing can be done via JMX. You can either 5 use a JMX client of your choice, like jconsole, or you can use the 6 reload.sh and refresh.sh scripts. 7 8 Added new build mode, which doesn't configure the classes and libraries 9 to be loaded with Tomcat's shared classloader, but with the respective 10 WebappClassLoader. This is simply done by making symbolic links from the 11 WEB-INF directories. Building in this mode also activates Tomcat's session 12 serialization mechanism, i.e. if data stored in the session (like 13 ContextResources or session beans) is serializable, you can reload 14 your application without losing state (limited by the known boundaries 15 of the Java serialization mechanism). This build mode can be enabled by 16 adding 'webappmode=true' to the build.properties file. 17 18 Added support for configuring Tomcat at startup time. Thus you can 19 determine which projects/hosts should be started without having to 20 call ant. Therefor you have to create the property file 21 "startup.properties" in the Pustefix root directory and add the 22 property "projects". The property expects a space-separated list of 23 projectnames as value. 24 25 Added: 26 * src/org/pustefixframework/admin/mbeans/WebappAdmin.java: implements 27 webapp reloading using Tomcat's WebModule JMX bean and Spring- 28 ApplicationContext reloading using the injected PustefixWebApplicationContext 29 * src/org/pustefixframework/admin/mbeans/WebappAdminMBean.java: 30 exposes reload and refresh method for JMX usage 31 * src/org/pustefixframework/config/project/parser/WebappAdminParsingHandler.java: 32 register WebappAdmin bean 33 * src/org/pustefixframework/admin/WebappAdminClient.java: commandline 34 client for reloading/refreshing, which uses local JMX 35 * src/org/pustefixframework/tools/TomcatStartupConfigurator.java: 36 creates server-runtime.xml from server.xml and removes inactive hosts 37 * reload.sh: script that triggers webapp reloading 38 * skel/reload.sh 39 * refresh.sh: script that triggers ApplicationContext refreshing 40 * skel/refresh.sh 41 * startup.properties: example TomcatStartupConfigurator properties 42 file 43 * skel/startup.properties 44 * src/de/schlund/pfixcore/example/TestData.java: added bean for 45 testing DI and reloading/refreshing in the sample application 46 47 Modified: 48 * src/org/pustefixframework/http/AbstractPustefixRequestHandler.java: 49 add property for injected WebappAdmin bean and call ApplicationContext refreshing 50 * src/org/pustefixframework/config/project/parser/PustefixContextXMLRequestHandlerParsingHandler.java: 51 inject WebappAdmin bean into PustefixContextXmlRequestHandler 52 * src/de/schlund/pfixcore/example/ContextAdultInfo.java: made class 53 Serializable to test webapp reloading 54 * res/META-INF/org/pustefixframework/config/project/parser/project-config.xml: 55 added ParsingHandler for WebappAdmin, added customization support for 56 further elements 57 * projects/core/build/create_serverxml.xsl: added webappmode and 58 webapps parameters. If webapps is set, only Hosts for these webapps 59 are created. If webappmode is true, session management and symbolic 60 linking support is enabled. 61 * projects/core/schema/context-xml-service-config.xsd: added 62 definition for optional bean-ref attribute (at output resources) 63 * skel/build-skel.xml: create links to shared classes/lib in webapp 64 mode to webapp-classes/webapp-lib instead of classes/lib and link 65 from WEB-INF/classes WEB-INF/lib of every webapp 66 * projects/sample1/conf/spring.xml: added test beans 67 * projects/sample1/conf/config.conf.xml: added test bean to output 68 * startTomcat.sh: increase -mx and MaxPermSize 69 1 70 2008-10-06 Tobias Fehrenbach <tobias.fehrenbach@1und1.de> 2 71 -
trunk/pfixcore/projects/core/build/create_serverxml.xsl
r3900 r3916 13 13 <xsl:param name="commonprojectsfile"/> 14 14 <xsl:param name="customizationinfo"/> 15 <xsl:param name="webappmode">false</xsl:param> 16 <xsl:param name="webapps"/> 15 17 16 18 <xsl:include href="create_lib.xsl"/> … … 139 141 </xsl:choose> 140 142 </xsl:variable> 141 <xsl:if test="$active = 'true'"> 142 <Host xmlValidation="false" unpackWARs="false" autoDeploy="false"> 143 <xsl:variable name="applist" select="concat(' ',translate($webapps,',',' '),' ')"/> 144 <xsl:if test="$active = 'true' and ( $webapps = '' or contains($applist,p:project/p:name/text()) )"> 145 <Host xmlValidation="false" unpackWARs="false" deployOnStartup="false" autoDeploy="false"> 143 146 <xsl:attribute name="debug"><xsl:value-of select="$debug"/></xsl:attribute> 144 147 <xsl:attribute name="name"> … … 226 229 <xsl:attribute name="docBase"><xsl:if test="$hostbased='true'">../</xsl:if><xsl:value-of select="$docBase"/></xsl:attribute> 227 230 <xsl:attribute name="debug"><xsl:value-of select="$debug"/></xsl:attribute> 231 <xsl:if test="$webappmode='true'"> 232 <xsl:attribute name="allowLinking">true</xsl:attribute> 233 </xsl:if> 228 234 <!-- switch off session serialization --> 229 <Manager pathname=""/> 235 <xsl:choose> 236 <xsl:when test="$webappmode='true'"> 237 <Manager/> 238 </xsl:when> 239 <xsl:otherwise> 240 <Manager pathname=""/> 241 </xsl:otherwise> 242 </xsl:choose> 230 243 <xsl:if test="$staticDocBase and not($staticDocBase = '')"> 231 244 <Parameter name="staticDocBase" value="{$staticDocBase}"/> -
trunk/pfixcore/projects/core/schema/context-xml-service-config.xsd
r3876 r3916 616 616 <xs:element name="resource" minOccurs="0" maxOccurs="unbounded"> 617 617 <xs:complexType> 618 <xs:attribute name="class" use=" required"/>618 <xs:attribute name="class" use="optional"/> 619 619 <xs:attribute name="node" use="required"/> 620 <xs:attribute name="bean-ref" use="optional"/> 620 621 </xs:complexType> 621 622 </xs:element> -
trunk/pfixcore/projects/sample1/conf/config.conf.xml
r3873 r3916 115 115 <wrapper prefix="prefix" class="de.schlund.pfixcore.example.iwrapper.IndexedTest" /> 116 116 </input> 117 <output> 118 <resource node="adultinfo" class="de.schlund.pfixcore.example.ContextAdultInfo" /> 119 <resource node="testdata" bean-ref="testdata"/> 120 </output> 117 121 </default> 118 122 <variant name="foo:bar:baz"> -
trunk/pfixcore/projects/sample1/conf/spring.xml
r3868 r3916 4 4 xmlns:aop="http://www.springframework.org/schema/aop" 5 5 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> 6 7 <bean id="testdata" class="de.schlund.pfixcore.example.TestData" scope="session"> 8 <property name="text" value="foo"/> 9 <aop:scoped-proxy/> 10 <property name="data" ref="global_testdata"/> 11 </bean> 12 13 <bean id="global_testdata" class="de.schlund.pfixcore.example.TestData"> 14 <property name="text" value="bar"/> 15 <!-- <property name="foo" value="xxx"/>--> 16 </bean> 6 17 7 18 <!-- -
trunk/pfixcore/res/META-INF/org/pustefixframework/config/project/parser/project-config.xml
r3901 r3916 20 20 </handler> 21 21 22 <!-- Adds handler mappingbean -->22 <!-- Adds SessionAdmin bean --> 23 23 <handler class="org.pustefixframework.config.project.parser.SessionAdminParsingHandler"> 24 24 <match>/p:project-config/p:application</match> 25 25 </handler> 26 26 27 <!-- Adds WebappAdmin bean --> 28 <handler class="org.pustefixframework.config.project.parser.WebappAdminParsingHandler"> 29 <match>/p:project-config//p:application</match> 30 </handler> 31 27 32 <!-- Creates PerfLogging bean --> 28 33 <handler class="org.pustefixframework.config.project.parser.PerfLoggingParsingHandler"> 29 <match>/p:project-config/ p:perflogging</match>34 <match>/p:project-config//p:perflogging</match> 30 35 </handler> 31 36 32 37 <!-- Creates AuthAdmin bean --> 33 38 <handler class="org.pustefixframework.config.project.parser.AuthAdminParsingHandler"> 34 <match>/p:project-config/ p:authadmin</match>39 <match>/p:project-config//p:authadmin</match> 35 40 </handler> 36 41 37 42 <!-- Creates TestRecording bean --> 38 43 <handler class="org.pustefixframework.config.project.parser.TestRecordingParsingHandler"> 39 <match>/p:project-config/ p:testrecording</match>44 <match>/p:project-config//p:testrecording</match> 40 45 </handler> 41 46 … … 57 62 58 63 <handler id="org.pustefixframework.config.customization.WhenParsingHandler" class="org.pustefixframework.config.customization.CustomizationWhenParsingHandler"> 64 <match>/p:project-config/p:choose/p:when</match> 59 65 <match>/p:project-config/p:application/p:choose/p:when</match> 60 66 <match>/p:project-config/p:xml-generator/p:choose/p:when</match> … … 62 68 63 69 <handler id="org.pustefixframework.config.customization.OtherwiseParsingHandler" class="org.pustefixframework.config.customization.CustomizationOtherwiseParsingHandler"> 70 <match>/p:project-config/p:choose/p:otherwise</match> 64 71 <match>/p:project-config/p:application/p:choose/p:otherwise</match> 65 72 <match>/p:project-config/p:xml-generator/p:choose/p:otherwise</match> -
trunk/pfixcore/skel/build-skel.xml
r3915 r3916 40 40 <property name="standalone.tomcat" value="false"/> 41 41 <property name="portbase.tomcat" value="8000"/> 42 <property name="webappmode" value="false"/> 43 <property name="webapps" value=""/> 42 44 43 45 <property name="pat.pfixcore_jar" value="pfixcore-*.jar"/> … … 105 107 <condition property="fqdn" value="${machine}"> 106 108 <not><isset property="dnsdomainname"/></not> 109 </condition> 110 <condition property="in.webapp.mode"> 111 <equals arg1="${webappmode}" arg2="true"/> 107 112 </condition> 108 113 </target> … … 228 233 229 234 <target name="compile-xml" 230 depends="buildtime-props, scgenerate, web_xml, autodeploy, pfixlog_xml, apache_conf, jk_conf, ajp_conf, workers_prop, server_xml, webservice"235 depends="buildtime-props, scgenerate, web_xml, webapp-setup, autodeploy, pfixlog_xml, apache_conf, jk_conf, ajp_conf, workers_prop, server_xml, webservice" 231 236 description="performs xslt transformations in dir.projects" 232 237 /> … … 289 294 290 295 <target name="installjars" depends="tomcat.dir.opt"> 296 <condition property="shared_lib_dirname" value="webapp-lib" else="lib"> 297 <isset property="in.webapp.mode"/> 298 </condition> 299 <condition property="shared_classes_dirname" value="webapp-classes" else="classes"> 300 <isset property="in.webapp.mode"/> 301 </condition> 302 <condition property="old_shared_lib_dirname" value="lib" else="webapp-lib"> 303 <isset property="in.webapp.mode"/> 304 </condition> 305 <condition property="old_shared_classes_dirname" value="classes" else="webapp-classes"> 306 <isset property="in.webapp.mode"/> 307 </condition> 308 <exec executable="sh"> 309 <arg line="-c "[ -L ${dir.tomcat}/shared/${old_shared_classes_dirname} ] && rm -rf ${dir.tomcat}/shared/${old_shared_classes_dirname}; [ -e ${dir.tomcat}/shared/${old_shared_lib_dirname} ] && rm -rf ${dir.tomcat}/shared/${old_shared_lib_dirname}""/> 310 </exec> 291 311 <!-- Setting absolute links instead of relative to avoid extra property for dir.build 292 312 as ${dir.build} is specified as location it always resolves to an absolute path; 293 313 does not work for filenames containing spaces --> 294 <echo level="verbose" message="Setting symlink to ${dir.build} as ${dir.projects}/servletconf/tomcat/shared/ classes"/>314 <echo level="verbose" message="Setting symlink to ${dir.build} as ${dir.projects}/servletconf/tomcat/shared/${shared_classes_dirname}"/> 295 315 <exec executable="sh"> 296 <arg line="-c "[ -e ${dir.projects}/servletconf/tomcat/shared/ classes ] && rm -fr ${dir.projects}/servletconf/tomcat/shared/classes ; ln -s ${dir.build} ${dir.projects}/servletconf/tomcat/shared/classes""/>316 <arg line="-c "[ -e ${dir.projects}/servletconf/tomcat/shared/${shared_classes_dirname} ] && rm -fr ${dir.projects}/servletconf/tomcat/shared/${shared_classes_dirname} ; ln -s ${dir.build} ${dir.projects}/servletconf/tomcat/shared/${shared_classes_dirname}""/> 297 317 </exec> 298 318 <!-- As task delete does not delete symbolic links, deleting symlinks using native tools. --> 299 319 <!-- Deleting symlinks pointing to non existent files, assuming jar files --> 300 320 <!-- replaced by new versions (with new filenames) do not exist anymore --> 321 <mkdir dir="${dir.projects}/servletconf/tomcat/shared/${shared_lib_dirname}"/> 301 322 <exec executable="find" os="Linux, Mac OS X"> 302 <arg file="${dir.projects}/servletconf/tomcat/shared/ lib"/>323 <arg file="${dir.projects}/servletconf/tomcat/shared/${shared_lib_dirname}"/> 303 324 <arg line="-iname *.jar -a -type l -exec rm -v {} ;"/> 304 325 </exec> 305 326 <echo level="verbose">Creating symlinks in tomcat's lib directory</echo> 306 327 <pathconvert property="cp.property" refid="cp.libs" pathsep=","/> 307 <apply executable="ln" dir="${dir.projects}/servletconf/tomcat/shared/ lib" failonerror="true" verbose="true"328 <apply executable="ln" dir="${dir.projects}/servletconf/tomcat/shared/${shared_lib_dirname}" failonerror="true" verbose="true" 308 329 type="file"> <!-- type file: to make sure that directories that might be added to cp.libs by accident are not passed to ln --> 309 330 <arg value="-s"/> … … 538 559 <antcall target="scmerge-modules"/> 539 560 </target> 540 561 562 <target name="webapp-setup" depends="webapp-removelinks, webapp-createlinks"/> 563 564 <target name="webapp-createlinks" depends="ant-tasks" if="in.webapp.mode"> 565 <exec executable="sh"> 566 <arg line="-c "for f in `find ${dir.projects}/servletconf/tomcat/webapps -maxdepth 2 -type d -name 'WEB-INF'`; do [ ! -e $f/classes ] && ln -s ${dir.projects}/servletconf/tomcat/shared/webapp-classes $f/classes; [ ! -e $f/lib ] && ln -s ${dir.projects}/servletconf/tomcat/shared/webapp-lib $f/lib; done""/> 567 </exec> 568 </target> 569 570 <target name="webapp-removelinks" depends="ant-tasks" unless="in.webapp.mode"> 571 <exec executable="sh"> 572 <arg line="-c "for f in `find ${dir.projects}/servletconf/tomcat/webapps -maxdepth 2 -type d -name 'WEB-INF'`; do [ -L $f/classes ] && rm $f/classes; [ -L $f/lib ] && rm $f/lib; done""/> 573 </exec> 574 </target> 575 541 576 <target name="-extract-jar-modules" depends="ant-tasks" description="Extracts resource data from JAR libraries"> 542 577 <!-- This target should only be called by extract-modules --> … … 829 864 </target> 830 865 831 <target name="server_xml" depends="ant-tasks" description="creates servletconf/tomcat/conf/server.xml from servletconf/projects.xml with core/build/create_serverxml.xsl"> 866 <target name="server_xml-check"> 867 <condition property="server_xml.outdated"> 868 <and> 869 <available file="build.properties"/> 870 <available file="${dir.tomcat}/conf/server.xml"/> 871 <uptodate targetfile="build.properties" srcfile="${dir.tomcat}/conf/server.xml"/> 872 </and> 873 </condition> 874 </target> 875 876 <target name="server_xml-force" if="server_xml.outdated"> 877 <delete file="${dir.tomcat}/conf/server.xml"/> 878 </target> 879 880 <target name="server_xml" depends="ant-tasks,server_xml-check,server_xml-force" description="creates servletconf/tomcat/conf/server.xml from servletconf/projects.xml with core/build/create_serverxml.xsl"> 832 881 <pfx-server-config 833 882 basedir="${dir.projects}" … … 840 889 <param name="standalone" expression="${standalone.tomcat}"/> 841 890 <param name="portbase" expression="${portbase.tomcat}"/> 891 <param name="webappmode" expression="${webappmode}"/> 892 <param name="webapps" expression="${webapps}"/> 842 893 </pfx-server-config> 843 894 </target> -
trunk/pfixcore/skel/startTomcat.sh
r1405 r3916 1 1 #!/bin/sh 2 2 3 if [ " $1" == "-d" ] ; then3 if [ "x$1" = "x-d" ] ; then 4 4 cmd="jpda run" 5 5 else … … 7 7 fi 8 8 9 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib/jni/build 10 export JAVA_OPTS="-mx200M" 9 export JAVA_OPTS="-Dcom.sun.management.jmxremote -mx300M -XX:MaxPermSize=128m" 11 10 echo "---------------------------" 12 11 echo "catalina.sh $cmd" … … 17 16 echo "---------------------------" 18 17 18 if [ -e startup.properties ]; then 19 java -cp build:`find lib -name "*pfixcore*.jar" -printf "%p:"` org.pustefixframework.tools.TomcatStartupConfigurator startup.properties projects/servletconf/tomcat/conf/server.xml projects/servletconf/tomcat/conf/server-runtime.xml 20 fi 21 if [ -e projects/servletconf/tomcat/conf/server-runtime.xml ]; then 22 echo "Use configuration created at startup from 'projects/servletconf/tomcat/conf/server-runtime.xml'" 23 cmd="$cmd -config conf/server-runtime.xml" 24 fi 19 25 cd ./projects/servletconf/tomcat/ 20 LANG=C ./bin/catalina.sh $cmd 21 22 23 26 LANG=C ./bin/catalina.sh $cmd -
trunk/pfixcore/src/de/schlund/pfixcore/example/ContextAdultInfo.java
r3738 r3916 20 20 package de.schlund.pfixcore.example; 21 21 22 import java.io.Serializable; 22 23 import java.util.Date; 23 24 import java.util.HashMap; … … 38 39 */ 39 40 40 public class ContextAdultInfo { 41 public class ContextAdultInfo implements Serializable { 42 43 private static final long serialVersionUID = -7113285838799932518L; 44 45 private transient Logger LOG = Logger.getLogger(ContextAdultInfo.class); 46 41 47 private Boolean adult = null; 42 48 private Date date = null; 43 49 private HashMap<String, String> test = new HashMap<String, String>(); 44 private final static Logger LOG = Logger.getLogger(ContextAdultInfo.class);45 50 46 51 public void setIndexedTest(HashMap<String, String> inmap) { -
trunk/pfixcore/src/org/pustefixframework/config/project/parser/PustefixContextXMLRequestHandlerParsingHandler.java
r3908 r3916 25 25 import java.util.Properties; 26 26 27 import org.pustefixframework.admin.mbeans.WebappAdmin; 27 28 import org.pustefixframework.config.Constants; 28 29 import org.pustefixframework.config.contextxmlservice.ContextXMLServletConfig; … … 126 127 beanBuilder.addPropertyValue("testRecording", new RuntimeBeanReference(TestRecording.class.getName())); 127 128 } 129 beanBuilder.addPropertyValue("webappAdmin", new RuntimeBeanReference(WebappAdmin.class.getName())); 128 130 BeanDefinition beanDefinition = beanBuilder.getBeanDefinition(); 129 131 BeanDefinitionHolder beanHolder = new BeanDefinitionHolder(beanDefinition, PustefixContextXMLRequestHandler.class.getName() + "#" + path); -
trunk/pfixcore/src/org/pustefixframework/http/AbstractPustefixRequestHandler.java
r3899 r3916 41 41 42 42 import org.apache.log4j.Logger; 43 import org.pustefixframework.admin.mbeans.WebappAdmin; 43 44 import org.pustefixframework.config.contextxmlservice.ServletManagerConfig; 44 45 import org.pustefixframework.container.spring.http.UriProvidingHttpRequestHandler; … … 103 104 private String handlerURI; 104 105 private SessionAdmin sessionAdmin; 106 private WebappAdmin webappAdmin; 105 107 106 108 protected abstract ServletManagerConfig getServletManagerConfig(); … … 145 147 146 148 public void handleRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { 149 150 if(webappAdmin!=null) webappAdmin.refreshIfTriggered(); 151 147 152 req.setCharacterEncoding(servletEncoding); 148 153 res.setCharacterEncoding(servletEncoding); … … 1127 1132 } 1128 1133 1134 public void setWebappAdmin(WebappAdmin webappAdmin) { 1135 this.webappAdmin = webappAdmin; 1136 } 1137 1129 1138 } -
trunk/pfixcore/startTomcat.sh
r3469 r3916 7 7 fi 8 8 9 export JAVA_OPTS="- mx200M"9 export JAVA_OPTS="-Dcom.sun.management.jmxremote -mx300M -XX:MaxPermSize=128m" 10 10 echo "---------------------------" 11 11 echo "catalina.sh $cmd" … … 16 16 echo "---------------------------" 17 17 18 if [ -e startup.properties ]; then 19 java -cp build:`find lib -name "*pfixcore*.jar" -printf "%p:"` org.pustefixframework.tools.TomcatStartupConfigurator startup.properties projects/servletconf/tomcat/conf/server.xml projects/servletconf/tomcat/conf/server-runtime.xml 20 fi 21 if [ -e projects/servletconf/tomcat/conf/server-runtime.xml ]; then 22 echo "Use configuration created at startup from 'projects/servletconf/tomcat/conf/server-runtime.xml'" 23 cmd="$cmd -config conf/server-runtime.xml" 24 fi 18 25 cd ./projects/servletconf/tomcat/ 19 LANG=C ./bin/catalina.sh $cmd 26 LANG=C ./bin/catalina.sh $cmd
