dev@javaserverfaces.java.net

NOTICE: Don't want to run your automated tests with clustering, but still want to use GlassFish 3.1?

From: <edward.burns_at_oracle.com>
Date: Mon, 3 Jan 2011 16:58:36 +0000 (GMT)

There's a container.xml for that.

Add a container type for glassfish 3.1 with no cluster
http://java.net/jira/browse/JAVASERVERFACES-1864

I am adding a new container.xml that lets you run the automated tests
on
3.1 without clustering, but naturally tests that require clustering
will
not pass in that case.

The purpose for this is to make it a little faster to run tests
locally.
It turns out running the tests with a clusterd container is a good deal
slower.

To use this, set your container.name property to
glassfishV3.1_no_cluster in your build.properties file.

SECTION: Modified Files
----------------------------
M jsf-ri/systest/src/com/sun/faces/htmlunit/AbstractTestCase.java

- Need to specifically handle the case where you are running on 3.1
with
  no cluster.

M build.properties.glassfish

- documentation of the new container.name value

A common/ant/glassfishV3.1_no_cluster
A common/ant/glassfishV3.1_no_cluster/container.xml

- This is really svn revision 8767 of
  common/ant/glassfishV3.1/container.xml with the necessary
  define.cluster.aware.port target added.

  svn cat -r 8768 container.xml >
../glassfishV3.1-no-cluster/container.xml


SECTION: Diffs
----------------------------
Index: common/ant/glassfishV3.1_no_cluster/container.xml
===================================================================
--- common/ant/glassfishV3.1_no_cluster/container.xml (revision 0)
+++ common/ant/glassfishV3.1_no_cluster/container.xml (revision 0)
@@ -0,0 +1,366 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+ Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights
reserved.
+
+ The contents of this file are subject to the terms of either the
GNU
+ General Public License Version 2 only ("GPL") or the Common
Development
+ and Distribution License("CDDL") (collectively, the "License").
You
+ may not use this file except in compliance with the License. You
can
+ obtain a copy of the License at
+ https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+ or packager/legal/LICENSE.txt. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ When distributing the software, include this License Header Notice
in each
+ file and include the License file at packager/legal/LICENSE.txt.
+
+ GPL Classpath Exception:
+ Oracle designates this particular file as subject to the
"Classpath"
+ exception as provided by Oracle in the GPL Version 2 section of
the License
+ file that accompanied this code.
+
+ Modifications:
+ If applicable, add the following below the License Header, with
the fields
+ enclosed by brackets [] replaced by your own identifying
information:
+ "Portions Copyright [year] [name of copyright owner]"
+
+ Contributor(s):
+ If you wish your version of this file to be governed by only the
CDDL or
+ only the GPL Version 2, indicate your decision by adding
"[Contributor]
+ elects to include this software in this distribution under the
[CDDL or GPL
+ Version 2] license." If you don't indicate a single choice of
license, a
+ recipient has the option to distribute your version of this file
under
+ either the CDDL, the GPL Version 2 or to extend the choice of
license to
+ its licensees as provided above. However, if you add GPL Version
2 code
+ and therefore, elected the GPL Version 2 license, then the option
applies
+ only if the new code is made subject to such option by the
copyright
+ holder.
+
+-->
+
+<project name="GlassFishV3.1" basedir=".">
+
+ <!-- JARs that may be packaged in WEB-INF/lib
+ in order for the implementation to run
+ properly if they aren't availabe in the
+ container's classloader.
+
+ This is a comma separated list of fully
+ qualified JARs -->
+
+ <property name="webapp.jars" value=""/>
+
+ <!-- Required Targets -->
+ <macrodef name="deploy.artifact">
+ <attribute name="artifact"
+ description="The WAR to deploy"/>
+ <attribute name="appName"
+ description="The name of the application"/>
+ <sequential>
+ <condition property="exec.name" value="cmd.exe">
+ <os family="windows"/>
+ </condition>
+ <condition property="exec.arg.1"
+ value="/c ${container.home}/bin/asadmin">
+ <os family="windows"/>
+ </condition>
+ <property name="exec.name"
value="${container.home}/bin/asadmin"/>
+ <property name="exec.arg.1" value=""/>
+ <echo>
+
+---------------- Glassfish - Deploying @{appName} ----------------
+
+ </echo>
+ <exec executable="${exec.name}" failonerror="true">
+ <arg line="${exec.arg.1}"/>
+ <arg line="deploy"/>
+ <arg line="--user ${glassfish.admin.user}"/>
+ <arg line="--passwordfile
${glassfish.password.file}"/>
+ <arg line="--host ${glassfish.admin.host}"/>
+ <arg line="--port ${glassfish.admin.port}"/>
+ <arg line="@{artifact}"/>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="deploydir.artifact">
+ <attribute name="explodedWarDir"
+ description="The exploded war directory to
deploy"/>
+ <attribute name="appName"
+ description="The name of the application"/>
+ <sequential>
+ <condition property="exec.name" value="cmd.exe">
+ <os family="windows"/>
+ </condition>
+ <condition property="exec.arg.1"
+ value="/c ${container.home}/bin/asadmin">
+ <os family="windows"/>
+ </condition>
+ <property name="exec.name"
value="${container.home}/bin/asadmin"/>
+ <property name="exec.arg.1" value=""/>
+ <echo>
+
+---------------- Glassfish - Deploying @{appName} ----------------
+
+ </echo>
+ <exec executable="${exec.name}" failonerror="true">
+ <arg line="${exec.arg.1}"/>
+ <arg line="deploydir"/>
+ <arg line="--user ${glassfish.admin.user}"/>
+ <arg line="--passwordfile
${glassfish.password.file}"/>
+ <arg line="--host ${glassfish.admin.host}"/>
+ <arg line="--port ${glassfish.admin.port}"/>
+ <arg line="--contextroot @{appName}
@{explodedWarDir}"/>
+ </exec>
+ </sequential>
+ </macrodef>
+
+
+ <macrodef name="undeploy.artifact">
+ <attribute name="artifact"
+ description="The WAR to deploy"/>
+ <attribute name="appName"
+ description="The name of the application"/>
+ <sequential>
+ <condition property="exec.name" value="cmd.exe">
+ <os family="windows"/>
+ </condition>
+ <condition property="exec.arg.1"
+ value="/c ${container.home}/bin/asadmin">
+ <os family="windows"/>
+ </condition>
+ <property name="exec.name"
value="${container.home}/bin/asadmin"/>
+ <property name="exec.arg.1" value=""/>
+ <echo>
+
+---------------- Glassfish - Undeploying @{appName} ----------------
+
+ </echo>
+ <exec executable="${exec.name}">
+ <arg line="${exec.arg.1}"/>
+ <arg line="undeploy"/>
+ <arg line="--user ${glassfish.admin.user}"/>
+ <arg line="--passwordfile
${glassfish.password.file}"/>
+ <arg line="--host ${glassfish.admin.host}"/>
+ <arg line="--port ${glassfish.admin.port}"/>
+ <arg line="@{appName}"/>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <target name="config.container">
+ </target>
+
+ <!-- Require target to display information about the build
environment -->
+ <target name="props">
+ <echo message="PENDING - Please add a message"/>
+ <echo message="container.home->${container.home}" />
+ <echo message="javaee.jar->${container.home}/lib/javaee.jar"
/>
+ </target>
+
+ <target name="update.impl.manifest">
+ <echo message="PENDING - Please implement"/>
+ </target>
+
+ <target name="container.deploy"
+ description="Deploy the JSF Implementation artifacts to
the target container.">
+ <if>
+ <os family="windows"/>
+ <then>
+ <container.stop/>
+ </then>
+ </if>
+
+ <copy overwrite="true" file="${api.dir}/build/lib/jsf-api.jar"
toFile="${container.home}/modules/jsf-api.jar"/>
+ <copy overwrite="true"
file="${impl.dir}/build/lib/jsf-impl.jar"
toFile="${container.home}/modules/jsf-impl.jar"/>
+
+ <if>
+ <os family="windows"/>
+ <then>
+ <!-- container.start/ -->
+ <echo>The container may have been stopped. Please
restart it, if
+ needed.
+ </echo>
+ </then>
+ </if>
+ </target>
+
+ <target name="define.cluster.aware.port">
+ <property name="cluster.aware.port" value="${container.port}" />
+ </target>
+
+ <target name="container.deploy.test.dependencies"
+ description="Deploy any container level dependencies to
the container.">
+ <if>
+ <os family="windows"/>
+ <then>
+ <container.stop/>
+ </then>
+ </if>
+
+ <copy overwrite="true" file="${groovy.jar}"
todir="${container.home}/modules"/>
+
+ <if>
+ <os family="windows"/>
+ <then>
+ <!-- container.start/ -->
+ <echo>The container may have been stopped. Please
restart it, if
+ needed.
+ </echo>
+ </then>
+ </if>
+ </target>
+
+ <target name="container.start"
+ description="Start the GlassFish container">
+ <container.start/>
+ </target>
+
+ <target name="container.stop"
+ description="Stop the GlassFish container">
+ <container.stop/>
+ </target>
+
+ <target name="container.restart"
+ description="Stop the GlassFish container">
+ <container.stop/>
+ <container.start/>
+ </target>
+
+ <macrodef name="container.start"
+ description="Start the GlassFish container">
+ <sequential>
+ <start.domain/>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="container.debug"
+ description="Start the GlassFish container in debug mode">
+ <sequential>
+ <debug.domain/>
+ </sequential>
+ </macrodef>
+
+
+ <macrodef name="container.stop"
+ description="Stop the GlassFish container">
+ <sequential>
+ <stop.domain/>
+ </sequential>
+ </macrodef>
+
+ <!-- 'PRIVATE' targets -->
+ <macrodef name="start.domain">
+ <sequential>
+ <echo>
+
+"------------ Starting ${glassfish.domain} ------------"
+
+ </echo>
+ <if>
+ <os family="unix"/>
+ <then>
+ <exec executable="${container.home}/bin/asadmin"
+ failonerror="true">
+ <arg line="start-domain"/>
+ <arg line="--user ${glassfish.admin.user}"/>
+ <arg line="${glassfish.domain}"/>
+ </exec>
+ <waitfor>
+ <http
url="http://${container.host}:${container.port}"/>
+ </waitfor>
+ </then>
+ <else>
+ <exec
executable="${container.home}/bin/asadmin.bat"
+ spawn="true">
+ <arg line="start-domain"/>
+ <arg line="--user ${glassfish.admin.user}"/>
+ <arg line="${glassfish.domain}"/>
+ </exec>
+ <waitfor>
+ <http
url="http://${container.host}:${container.port}"/>
+ </waitfor>
+ </else>
+ </if>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="debug.domain">
+ <sequential>
+ <echo>
+
+"------------ Starting ${glassfish.domain} in debug mode------------"
+
+ </echo>
+ <if>
+ <os family="unix"/>
+ <then>
+ <exec executable="${container.home}/bin/asadmin"
+ failonerror="true">
+ <arg line="start-domain"/>
+ <arg line="--user ${glassfish.admin.user}"/>
+ <arg line="--debug"/>
+ <arg line="${glassfish.domain}"/>
+ </exec>
+ <waitfor>
+ <http
url="http://${container.host}:${container.port}"/>
+ </waitfor>
+ </then>
+ <else>
+ <exec
executable="${container.home}/bin/asadmin.bat"
+ spawn="true">
+ <arg line="start-domain"/>
+ <arg line="--user ${glassfish.admin.user}"/>
+ <arg line="--debug"/>
+ <arg line="${glassfish.domain}"/>
+ </exec>
+ <waitfor>
+ <http
url="http://${container.host}:${container.port}"/>
+ </waitfor>
+ </else>
+ </if>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="stop.domain">
+ <sequential>
+ <echo>
+
+"------------ Stopping ${glassfish.domain} ------------"
+
+ </echo>
+ <if>
+ <os family="unix"/>
+ <then>
+ <exec executable="${container.home}/bin/asadmin">
+ <arg line="stop-domain"/>
+ <arg line="${glassfish.domain}"/>
+ </exec>
+ </then>
+ <else>
+ <exec
executable="${container.home}/bin/asadmin.bat"
+ spawn="true">
+ <arg line="stop-domain"/>
+ <arg line="${glassfish.domain}"/>
+ </exec>
+ </else>
+ </if>
+ <sleep seconds="15"/>
+ </sequential>
+ </macrodef>
+
+
+ <!-- ************ Compiler Defaults
*************************************** -->
+
+
+ <!-- ************ Executable Targets
************************************** -->
+
+ <target name="main">
+ </target>
+
+
+</project>
+
Index: jsf-ri/conf/share/facelet-dev-debug.xml
===================================================================
--- jsf-ri/conf/share/facelet-dev-debug.xml (revision 8770)
+++ jsf-ri/conf/share/facelet-dev-debug.xml (working copy)
@@ -106,6 +106,8 @@
 <div id="tree" class="grayBox"><code>@@tree@@</code></div>
 <h2><a href="#" onclick="faceletstoggle('vars'); return false;"><span
id="varsOff">+</span><span id="varsOn" style="display: none;">-</span>
Scoped Variables</a></h2>
 <div id="vars">@@vars@@</div>
+<h2><a href="#" onclick="faceletstoggle('state'); return false;"><span
id="stateOff">+</span><span id="stateOn" style="display:
none;">-</span> View State</a></h2>
+<div id="state">@@state@@</div>
 <div class="grayBox" style="text-align: right; color: #666;">@@now@@ -
Generated by Mojara/Facelets</div>
 </body>
 </html>
Index: jsf-ri/src/main/java/com/sun/faces/facelets/tag/ui/UIDebug.java
===================================================================
--- jsf-ri/src/main/java/com/sun/faces/facelets/tag/ui/UIDebug.java
(revision 8770)
+++ jsf-ri/src/main/java/com/sun/faces/facelets/tag/ui/UIDebug.java
(working copy)
@@ -147,7 +147,7 @@
             session.put(KEY, debugs);
         }
         String id = "" + nextId++;
- debugs.put(id, fw.toString());
+ debugs.put(id, fw.toString()); // store the id in the
facesContext map as the value under KEY
         return id;
     }
     
@@ -195,4 +195,27 @@
         this.hotkey = (hotkey != null) ? hotkey.toUpperCase() : "";
     }
 
+ // If the recordStateSize=true is set on the UIDebug component,
+ // in writeDebugOutput, write a facesContext attribute that
indicates that
+ // this view has a uidebug
+ // with recordStateSize=true in it.
+ // The value of the attribute is the id in the debugs map.
+ // Add a static method that takes no action if the new attribute
is absent,
+ // otherwise it takes Map<String clientId, Serializable>, which it
+ // traverses and computes the size of each entry and also sums the
total size.
+ // This data is stored in our debugs map under key id_state where
id is the
+ // value of the new facesContext attribute. The value of key
id_state
+ // is a Map<String, Long> where the strings are the client ids,
the values
+ // are the sizes of the state for that component, and the "" entry
is the total.
+
+ // This method is always called from
StateManagementStrategyImpl.saveView()
+ // but because of the above check, it will only take action if the
tree
+ // has a <ui:debug recordStateSize=true>.
+
+ // Modify fetchDebugOutput to look for the state map and use
+ // string replacement on @@state@@ to write the state size info,
if it
+ // exists, or a nice "No View State information available, set
recordStateSize=true
+ // on <ui:debug> to record the state size." message.
+
+
 }
Index:
jsf-ri/src/main/java/com/sun/faces/application/view/StateManagementStra
tegyImpl.java
===================================================================
---
jsf-ri/src/main/java/com/sun/faces/application/view/StateManagementStra
tegyImpl.java	     (revision 8770)
+++
jsf-ri/src/main/java/com/sun/faces/application/view/StateManagementStra
tegyImpl.java	     (working copy)
@@ -190,7 +190,7 @@
	     stateMap.put(CLIENTIDS_TO_ADD_NAME,
savedAddList.toArray());
	 }
	 //return stateMap;
-	 return new Object[] { null, stateMap };
+	 return new Object[] { null, stateMap }; // call static UIDebug
method that traverses the stateMap and computes the size
 
     }
 
Index: jsf-ri/systest/src/com/sun/faces/htmlunit/AbstractTestCase.java
===================================================================
--- jsf-ri/systest/src/com/sun/faces/htmlunit/AbstractTestCase.java    
(revision 8770)
+++ jsf-ri/systest/src/com/sun/faces/htmlunit/AbstractTestCase.java    
(working copy)
@@ -121,7 +121,7 @@
     protected HtmlPage lastpage = null;
 
     // Possible containers - these should be the uppercase values of
the possible container values in build.properties
-    protected enum Container { GLASSFISH, GLASSFISHV3PRELUDE,
GLASSFISHV3, GLASSFISHV3_1, TOMCAT6 }
+    protected enum Container { GLASSFISH, GLASSFISHV3PRELUDE,
GLASSFISHV3, GLASSFISHV3_1, GLASSFISHV3_1_NO_CLUSTER, TOMCAT6 }
 
     // Per-container exclusions
     protected Map<Container, Vector<String>> exclusions = null;
@@ -145,7 +145,8 @@
	 BrowserVersion browserVersion;
 
	 String instanceNumbersStr =
System.getProperty("instance.numbers");
-	 if (null != instanceNumbersStr && 0 <
instanceNumbersStr.length()) {
+	 if (null != instanceNumbersStr && 0 <
instanceNumbersStr.length() &&
+	    !("${instance.numbers}".equals(instanceNumbersStr))) {
	     String [] strs = instanceNumbersStr.split(",");
	     instanceNumbers = new ArrayList<Integer>();
	     for (String cur : strs) {
Index: build.properties.glassfish
===================================================================
--- build.properties.glassfish	(revision 8770)
+++ build.properties.glassfish	(working copy)
@@ -64,10 +64,12 @@
 #	to the container.xml file in 
 #	${jsf.build.home}/common/ant/${container.name}
 #
-#  For Glassfish V1/V2, use:	   glassfish
-#  For GlassFish V3 Prelude, use: glassfishV3prelude
-#  For GlassFish V3, use:	   glassfishV3
-#  For GlassFish V3.1, use:	   glassfishV3.1
+#  For Glassfish V1/V2, use:			glassfish
+#  For GlassFish V3 Prelude, use:		glassfishV3prelude
+#  For GlassFish V3, use:			glassfishV3
+#  For GlassFish V3.1, use:			glassfishV3.1
+#  For GlassFish V3.1 with no clustering, use:
glassfishV3.1_no_cluster
+
 # --------------------------------------------------
 container.name=glassfish
 
SECTION: New Files
----------------------------
SEE ATTACHMENTS