Author: ekoneil Date: Thu Jan 6 12:00:49 2005 New Revision: 124428 URL: http://svn.apache.org/viewcvs?view=rev&rev=124428 Log: Switch the NetUI webapp template off of Global.app and onto SharedFlow.jpfs.
In a new NetUI application, you'll get one with a WEB-INF/src/shared/SharedFlow.jpfs that's also wired into the default /Controller.jpf. Update the webapp template to reflect this. BB: self DRT: Beehive pass Added: incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/build.xml (contents, props changed) incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/shared/ incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/shared/SharedFlow.jpfs (contents, props changed) Modified: incubator/beehive/trunk/netui/ant/build.xml incubator/beehive/trunk/netui/ant/webappTemplate.xml incubator/beehive/trunk/netui/src/webapp-template/default/Controller.jpf incubator/beehive/trunk/test/ant/runTomcatCore.xml Modified: incubator/beehive/trunk/netui/ant/build.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/ant/build.xml?view=diff&rev=124428&p1=incubator/beehive/trunk/netui/ant/build.xml&r1=124427&p2=incubator/beehive/trunk/netui/ant/build.xml&r2=124428 ============================================================================== --- incubator/beehive/trunk/netui/ant/build.xml (original) +++ incubator/beehive/trunk/netui/ant/build.xml Thu Jan 6 12:00:49 2005 @@ -53,7 +53,13 @@ <echo message="| NetUI deploy starting |"/> <echo message="--------------------------------------------------"/> - <ant antfile="webappTemplate.xml" target="all.templates" inheritAll="false"/> + <ant antfile="webappTemplate.xml" target="create.netui.webapp" inheritAll="false"> + <property name="webapp.dir" location="${webapp.dist.dir}"/> + </ant> + + <!-- copy the NetUI compiler into its distribution directory --> + <mkdir dir="${compiler.dist.dir}"/> + <copy todir="${compiler.dist.dir}" file="${compiler.jar}"/> <echo message="--------------------------------------------------"/> <echo message="| NetUI deploy ending |"/> Modified: incubator/beehive/trunk/netui/ant/webappTemplate.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/ant/webappTemplate.xml?view=diff&rev=124428&p1=incubator/beehive/trunk/netui/ant/webappTemplate.xml&r1=124427&p2=incubator/beehive/trunk/netui/ant/webappTemplate.xml&r2=124428 ============================================================================== --- incubator/beehive/trunk/netui/ant/webappTemplate.xml (original) +++ incubator/beehive/trunk/netui/ant/webappTemplate.xml Thu Jan 6 12:00:49 2005 @@ -10,15 +10,13 @@ <property name="template.root.dir" location="${src.dir}/webapp-template/"/> <property name="struts11.dir" location="${struts.dir}/legacy/jakarta-struts-1.1-lib"/> - <target name="all.templates" description="Deploy the NetUI / generic webapp template"> - <echo>Build NetUI Webapp Template to Directory: ${webapp.dist.dir}</echo> + <target name="create.netui.webapp" description="Create a NetUI webapp"> + <echo>Create NetUI Webapp in: ${webapp.dir}</echo> - <property name="webapp.dir" location="${webapp.dist.dir}"/> <property name="webinf.dir" location="${webapp.dir}/WEB-INF"/> <property name="webinf.lib" location="${webapp.dir}/WEB-INF/lib"/> <property name="javascript.dir" location="${webapp.dir}/${resource.dir.name}/javascript"/> - <mkdir dir="${webapp.dist.dir}"/> <mkdir dir="${webapp.dir}"/> <mkdir dir="${webinf.dir}"/> <mkdir dir="${webinf.dir}/lib"/> @@ -44,12 +42,10 @@ <copy todir="${webapp.dir}"> <fileset dir="${template.root.dir}/default"> <include name="**/*"/> + <exclude name="WEB-INF/src/global/Global.app"/> + <exclude name="WEB-INF/netui-config.xml"/> </fileset> </copy> - - <!-- copy the NetUI compiler --> - <mkdir dir="${compiler.dist.dir}"/> - <copy todir="${compiler.dist.dir}" file="${compiler.jar}"/> </target> <target name="deploy.netui.runtime" description="Deploy the NetUI server runtime to a webapp root directory."> @@ -68,14 +64,9 @@ <antcall target="deploy.netui"/> <copy todir="${webapp.dir}/WEB-INF/lib"> - <fileset file="${commons-el.jar}"/> - <fileset file="${commons-codec.jar}"/> - <fileset file="${jstl.jar}"/> - <fileset file="${standard.jar}"/> - <fileset file="${xbean.jar}"/> - <fileset file="${jsr173.jar}"/> - <fileset file="${log4j.jar}"/> - <fileset file="${controls.jar}"/> + <fileset dir="${webapp.dist.dir}/WEB-INF/lib"> + <patternset refid="beehive.jars"/> + </fileset> </copy> <!-- Beehive/NetUI assumes ownership of the resources/beehive/version1 directory --> @@ -206,8 +197,8 @@ </target> <patternset id="jsf.jars"> - <include name="WEB-INF/lib/jsf-api.jar"/> - <include name="WEB-INF/lib/jsf-impl.jar"/> + <include name="jsf-api.jar"/> + <include name="jsf-impl.jar"/> </patternset> <patternset id="jsf.webinf"> Modified: incubator/beehive/trunk/netui/src/webapp-template/default/Controller.jpf Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/webapp-template/default/Controller.jpf?view=diff&rev=124428&p1=incubator/beehive/trunk/netui/src/webapp-template/default/Controller.jpf&r1=124427&p2=incubator/beehive/trunk/netui/src/webapp-template/default/Controller.jpf&r2=124428 ============================================================================== --- incubator/beehive/trunk/netui/src/webapp-template/default/Controller.jpf (original) +++ incubator/beehive/trunk/netui/src/webapp-template/default/Controller.jpf Thu Jan 6 12:00:49 2005 @@ -4,19 +4,19 @@ import org.apache.beehive.netui.pageflow.PageFlowController; import org.apache.beehive.netui.pageflow.annotations.Jpf; [EMAIL PROTECTED] [EMAIL PROTECTED]( + simpleActions={ + @Jpf.SimpleAction(name="begin", path="index.jsp") + }, + sharedFlowRefs={ + @Jpf.SharedFlowRef(name="shared", type=shared.SharedFlow.class) + } +) public class Controller extends PageFlowController { - @Jpf.Action( - forwards={ - @Jpf.Forward(name="success", path="index.jsp") - } - ) - protected Forward begin() - { - return new Forward("success"); - } + @Jpf.SharedFlowField(name="shared") + private shared.SharedFlow sharedFlow; /** * Callback that is invoked when this controller instance is created. Added: incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/build.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/build.xml?view=auto&rev=124428 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/build.xml Thu Jan 6 12:00:49 2005 @@ -0,0 +1,27 @@ +<?xml version="1.0"?> + +<project name="Beehive/NetUI/Webapp" default="build" basedir="../.."> + + <property environment="os"/> + <property name="beehive.home" location="${os.BEEHIVE_HOME}"/> + + <property name="buildWebapp.ant" location="${beehive.home}/test/ant/buildWebapp.xml"/> + + <property name="webapp.dir" value="${basedir}"/> + <property name="context.path" value="beehiveWeb"/> + + <import file="${beehive.home}/test/ant/runTomcatCore.xml"/> + + <target name="build" description="Build the webapp"> + <ant antfile="${buildWebapp.ant}" target="build.webapp"> + <property name="webapp.dir" location="${basedir}"/> + </ant> + </target> + + <target name="clean" description="Clean the webapp"> + <ant antfile="${buildWebapp.ant}" target="clean.webapp"> + <property name="webapp.dir" location="${basedir}"/> + </ant> + </target> + +</project> Added: incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/shared/SharedFlow.jpfs Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/shared/SharedFlow.jpfs?view=auto&rev=124428 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/webapp-template/default/WEB-INF/src/shared/SharedFlow.jpfs Thu Jan 6 12:00:49 2005 @@ -0,0 +1,85 @@ +package shared; + +import java.io.IOException; + +import org.apache.beehive.netui.pageflow.Forward; +import org.apache.beehive.netui.pageflow.PageFlowException; +import org.apache.beehive.netui.pageflow.SharedFlowController; +import org.apache.beehive.netui.pageflow.annotations.Jpf; + +/** + * This shared flow can define actions, exception handlers, and state to be shared among page flows + * that reference it. A page flow references this shared flow inside a <code>Jpf.Controller</code> + * annotation as: + * <pre> + * sharedFlowRefs={ + * @Jpf.SharedFlowRef(name="shared", type=shared.SharedFlow.class) + * } + * </pre> + * + * Once referenced, the following features apply: + * <ul> + * <li> + * An instance of this shared flow will be created and stored the first time the page + * flow is accessed. + * </li> + * <li> + * The page flow (or its pages) can reference actions using the pattern + * <i>shared-flow-name.action-name</i>, e.g., "shared.someAction". + * </li> + * <li> + * Unhandled exceptions in the page flow will be handled by <code>Jpf.Catch</code> + * annotations in this shared flow. + * </li> + * <li> + * In pages and annotations that bind to data using the expression language, properties + * in this shared flow are accessed through the <code>sharedFlow</code> binding context. + * </li> + * <li> + * A page flow can have an automatically-initialized member reference to this shared + * flow using the <code>Jpf.SharedFlowField</code> annotation, like this: + * <pre> + * @Jpf.SharedFlowField(name="shared") + * private shared.SharedFlow _mySharedFlowReference; + * </pre> + * </li> + * </ul> + */ [EMAIL PROTECTED]( + catches={ + @Jpf.Catch(type=PageFlowException.class, method="handlePageFlowException"), + @Jpf.Catch(type=Exception.class, method="handleException") + } +) +public class SharedFlow + extends SharedFlowController +{ + @Jpf.ExceptionHandler( + forwards={ + @Jpf.Forward(name="errorPage", path="/error.jsp") + } + ) + protected Forward handleException(Exception ex, String actionName, String message, Object form) + { + System.err.print("[" + getRequest().getContextPath() + "] "); + System.err.println("Unhandled exception caught in shared flow " + getDisplayName() + ":"); + ex.printStackTrace(); + return new Forward("errorPage"); + } + + /** + * Handler for native page flow exceptions (e.g., ActionNotFoundException, which is thrown when + * an unknown page flow action is requested). This handler allows these exceptions to write + * informative error pages to the response when the server is not in production mode, and it + * allows them to send an appropriate error on the response when the server is in production + * mode. To use the standard exception handler for these exceptions, simply remove this method + * and the Jpf.Catch annotation that references it. + */ + @Jpf.ExceptionHandler + public Forward handlePageFlowException(PageFlowException ex, String actionName, String message, Object form) + throws IOException + { + ex.sendError(getRequest(), getResponse()); + return null; + } +} Modified: incubator/beehive/trunk/test/ant/runTomcatCore.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/test/ant/runTomcatCore.xml?view=diff&rev=124428&p1=incubator/beehive/trunk/test/ant/runTomcatCore.xml&r1=124427&p2=incubator/beehive/trunk/test/ant/runTomcatCore.xml&r2=124428 ============================================================================== --- incubator/beehive/trunk/test/ant/runTomcatCore.xml (original) +++ incubator/beehive/trunk/test/ant/runTomcatCore.xml Thu Jan 6 12:00:49 2005 @@ -4,15 +4,13 @@ <property file="beehive.tomcat.properties"/> - <property name="tomcat.home" location="${tomcat.dir}"/> - <property name="catalina.username" value="manager"/> <property name="catalina.password" value="manager"/> - <property name="catalina-ant.jar" location="${tomcat.home}/server/lib/catalina-ant.jar"/> + <property name="catalina-ant.jar" location="${tomcat.dir}/server/lib/catalina-ant.jar"/> <path id="appserver.build.classpath"> - <fileset dir="${tomcat.home}/common/lib"> + <fileset dir="${tomcat.dir}/common/lib"> <include name="*.jar"/> </fileset> </path> @@ -55,28 +53,28 @@ <not><isset property="java.options"/></not> </condition> - <echo>startup.dir: ${tomcat.home}/bin</echo> + <echo>startup.dir: ${tomcat.dir}/bin</echo> <echo>cmdline.options: ${cmdline.options}</echo> <echo>java.options: ${java.options}</echo> <echo>Start Tomcat</echo> - <exec os="Windows 2000,Windows 2003,Windows XP" dir="${tomcat.home}\bin" executable="cmd.exe"> + <exec os="Windows 2000,Windows 2003,Windows XP" dir="${tomcat.dir}\bin" executable="cmd.exe"> <env key="JAVA_OPTS" value="${java.options}"/> <arg line="/c startup.bat ${cmdline.options}"/> </exec> - <exec os="Linux,SunOS,Solaris,Mac OS X" dir="${tomcat.home}/bin" executable="sh"> + <exec os="Linux,SunOS,Solaris,Mac OS X" dir="${tomcat.dir}/bin" executable="sh"> <env key="JAVA_OPTS" value="${java.options}"/> <arg line="startup.sh ${cmdline.options}"/> </exec> </target> <target name="stop" description="Stop the NetUI server"> - <echo>Stop Tomcat in: ${tomcat.home}</echo> - <exec os="Windows 2000,Windows 2003,Windows XP" dir="${tomcat.home}\bin" executable="cmd.exe"> + <echo>Stop Tomcat in: ${tomcat.dir}</echo> + <exec os="Windows 2000,Windows 2003,Windows XP" dir="${tomcat.dir}\bin" executable="cmd.exe"> <arg line=" /c shutdown"/> </exec> - <exec os="Linux,SunOS,Solaris,Mac OS X" dir="${tomcat.home}/bin" executable="sh"> + <exec os="Linux,SunOS,Solaris,Mac OS X" dir="${tomcat.dir}/bin" executable="sh"> <arg line="shutdown.sh"/> </exec> </target>
