Author: rich
Date: Mon Nov 22 15:53:44 2004
New Revision: 106241

Added:
   incubator/beehive/trunk/netui/external/tomcat/5x/
   incubator/beehive/trunk/netui/external/tomcat/5x/catalina.jar   (contents, 
props changed)
   incubator/beehive/trunk/netui/external/tomcat/5x/servlet-api.jar   
(contents, props changed)
   incubator/beehive/trunk/netui/external/tomcat/5x/tomcat-coyote.jar   
(contents, props changed)
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServerAdapter.java
      - copied, changed from r76205, 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultServerAdapter.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SecurityProtocol.java
   (contents, props changed)
   incubator/beehive/trunk/netui/src/tomcat-common/5x/
      - copied from r76205, incubator/beehive/trunk/netui/src/tomcat-common/4x/
   incubator/beehive/trunk/netui/src/tomcat-common/5x/build.xml
      - copied, changed from r106203, 
incubator/beehive/trunk/netui/src/tomcat-common/4x/build.xml
   incubator/beehive/trunk/netui/src/tomcat-common/5x/org/
      - copied from r106203, 
incubator/beehive/trunk/netui/src/tomcat-common/4x/org/
   incubator/beehive/trunk/netui/src/tomcat-server/5x/
      - copied from r76205, incubator/beehive/trunk/netui/src/tomcat-server/4x/
   incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml
      - copied, changed from r106203, 
incubator/beehive/trunk/netui/src/tomcat-server/4x/build.xml
   incubator/beehive/trunk/netui/src/tomcat-server/5x/org/
      - copied from r106203, 
incubator/beehive/trunk/netui/src/tomcat-server/4x/org/
   incubator/beehive/trunk/netui/src/tomcat-webapp/5x/
      - copied from r76205, incubator/beehive/trunk/netui/src/tomcat-webapp/4x/
   incubator/beehive/trunk/netui/src/tomcat-webapp/5x/build.xml
      - copied, changed from r106203, 
incubator/beehive/trunk/netui/src/tomcat-webapp/4x/build.xml
   incubator/beehive/trunk/netui/src/tomcat-webapp/5x/org/
      - copied from r106203, 
incubator/beehive/trunk/netui/src/tomcat-webapp/4x/org/
   
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java
   (contents, props changed)
Removed:
   incubator/beehive/trunk/netui/external/tomcat/4x/
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultServerAdapter.java
   incubator/beehive/trunk/netui/src/tomcat-common/4x/
   incubator/beehive/trunk/netui/src/tomcat-server/4x/
   incubator/beehive/trunk/netui/src/tomcat-webapp/4x/
Modified:
   incubator/beehive/trunk/netui/ant/netui.properties
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowConstants.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServerAdapter.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java
   
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
   
incubator/beehive/trunk/netui/src/tomcat-common/5x/org/apache/beehive/netui/tomcat/PageflowHelper.java
   incubator/beehive/trunk/netui/src/tomcat-common/build.xml
   
incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowHelperImpl.java
   
incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowValve.java
   incubator/beehive/trunk/netui/src/tomcat-server/build.xml
   
incubator/beehive/trunk/netui/src/tomcat-webapp/5x/org/apache/beehive/netui/tomcat/TomcatServerAdapter.java
   incubator/beehive/trunk/netui/src/tomcat-webapp/build.xml
   incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd
   
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest1/Begin.jsp
   
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest2/Begin.jsp
   
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NestedFormReturn.xml
Log:
Several changes:
    - Revamped the ServerAdapter layer.  Cleaned up the interface and its 
usage, and removed all hardcoded logic for choosing the ServerAdapter 
appropriate for the current environment.  This is replaced with a combination 
of discovery and acceptance: ServerAdapters are declared on classpath through 
the file META-INF/services/org.apache.beehive.netui.pageflow.ServerAdapter, 
where the file contains the implementation class name (e.g., 
org.apache.beehive.netui.tomcat.TomcatServerAdapter).  Each ServerAdapter that 
is discovered is given a chance to "accept", which means that it looks in the 
current environment to see if it is the right one.  The first one that accepts 
wins.  Log messages detail the process for choosing, including exceptions and 
LinkageErrors.

    - Ported TomcatServerAdapter to Tomcat 5 (and removed the old Tomcat 4 
version).

    - Fixed a bug where netui tags would render secure anchors for secure 
(transport-guarantee of CONFIDENTIAL in web.xml) URIs even when there was no 
ServerAdapter to specify the port.  This resulted in URLs like this:
        http://myserver:-1/webapp/secure.do

    - Added the following configuration parameters to the schema for 
netui-config.xml:
         max-forwards-per-request: the number of consecutive server forwards 
before we return an error to the user.
         max-nesting-stack-depth: the maximum size of the Page Flow nesting 
stack; nesting deeper than this causes an error.
         ensure-secure-forwards: tells whether to run server-specific security 
checks before doing a server forward (normally these may only happen on direct 
hits).
      All three of these settings were formerly read from context-params in 
web.xml, which still works but is deprecated.

    - General API and constants cleanup.

DRT/BVT: netui (WinXP)
BB: self (WinXP)



Modified: incubator/beehive/trunk/netui/ant/netui.properties
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/ant/netui.properties?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/ant/netui.properties&r1=106240&p2=incubator/beehive/trunk/netui/ant/netui.properties&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/ant/netui.properties  (original)
+++ incubator/beehive/trunk/netui/ant/netui.properties  Mon Nov 22 15:53:44 2004
@@ -95,14 +95,12 @@
 xjavadoc.jar=${xdoclet.dir}/xjavadoc-1.0.jar
 
 #
-# Tomcat properties.  These JARs are still used to compile
-# the Tomcat 4x security integration which hasn't yet been
-# ported to 5x.
+# Tomcat properties.  These JARs are used to compile the Tomcat 5x 
ServerAdapter.
 #
 tomcat.lib.dir=${build.external.dir}/tomcat
-catalina.4x.jar=${tomcat.lib.dir}/4x/catalina.jar
-coyote.4x.jar=${tomcat.lib.dir}/4x/tomcat-coyote.jar
-servlet23.jar=${tomcat.lib.dir}/4x/servlet.jar
+catalina.5x.jar=${tomcat.lib.dir}/5x/catalina.jar
+coyote.5x.jar=${tomcat.lib.dir}/5x/tomcat-coyote.jar
+servlet23.jar=${tomcat.lib.dir}/5x/servlet-api.jar
 
 # 
---------------------------------------------------------------------------------
 #
@@ -120,9 +118,9 @@
 pageflow.jar.name=beehive-netui-pageflow.jar
 scoping.jar.name=beehive-netui-scoping.jar
 
-netui-tomcat-common.4x.jar.name=beehive-netui-tomcat-common-4x.jar
-netui-tomcat-server.4x.jar.name=beehive-netui-tomcat-server-4x.jar
-netui-tomcat-webapp.4x.jar.name=beehive-netui-tomcat-webapp-4x.jar
+netui-tomcat-common.5x.jar.name=beehive-netui-tomcat-common-5x.jar
+netui-tomcat-server.5x.jar.name=beehive-netui-tomcat-server-5x.jar
+netui-tomcat-webapp.5x.jar.name=beehive-netui-tomcat-webapp-5x.jar
 
 # NetUI TLD Names
 netui-tags-html.tld.name=beehive-netui-tags-html.tld
@@ -151,9 +149,9 @@
 pageflow.jar=${build.lib.dir}/${pageflow.jar.name}
 scoping.jar=${build.lib.dir}/${scoping.jar.name}
 
-netui-tomcat-common.4x.jar=${build.lib.dir}/${netui-tomcat-common.4x.jar.name}
-netui-tomcat-server.4x.jar=${build.lib.dir}/${netui-tomcat-server.4x.jar.name}
-netui-tomcat-webapp.4x.jar=${build.lib.dir}/${netui-tomcat-webapp.4x.jar.name}
+netui-tomcat-common.5x.jar=${build.lib.dir}/${netui-tomcat-common.5x.jar.name}
+netui-tomcat-server.5x.jar=${build.lib.dir}/${netui-tomcat-server.5x.jar.name}
+netui-tomcat-webapp.5x.jar=${build.lib.dir}/${netui-tomcat-webapp.5x.jar.name}
 
 # NetUI dist TLD(x)
 netui-tags-html.tld=${build.lib.dir}/${netui-tags-html.tld.name}

Added: incubator/beehive/trunk/netui/external/tomcat/5x/catalina.jar
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/external/tomcat/5x/catalina.jar?view=auto&rev=106241
==============================================================================
Binary file. No diff available.

Added: incubator/beehive/trunk/netui/external/tomcat/5x/servlet-api.jar
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/external/tomcat/5x/servlet-api.jar?view=auto&rev=106241
==============================================================================
Binary file. No diff available.

Added: incubator/beehive/trunk/netui/external/tomcat/5x/tomcat-coyote.jar
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/external/tomcat/5x/tomcat-coyote.jar?view=auto&rev=106241
==============================================================================
Binary file. No diff available.

Copied: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServerAdapter.java
 (from r76205, 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultServerAdapter.java)
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServerAdapter.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultServerAdapter.java&r1=76205&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServerAdapter.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultServerAdapter.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/DefaultServerAdapter.java
      Mon Nov 22 15:53:44 2004
@@ -15,9 +15,9 @@
  *
  * $Header:$
  */
-package org.apache.beehive.netui.pageflow.internal;
+package org.apache.beehive.netui.pageflow;
 
-import org.apache.beehive.netui.pageflow.ServerAdapter;
+import org.apache.beehive.netui.pageflow.internal.PageFlowBeanContext;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -26,10 +26,8 @@
 
 import org.apache.beehive.controls.api.context.ControlBeanContext;
 
-import java.io.File;
 
-
-public class DefaultServerAdapter implements ServerAdapter
+public abstract class DefaultServerAdapter implements ServerAdapter
 {
     private static boolean _productionMode = true;
     
@@ -37,36 +35,53 @@
     
     static
     {
-        //
-        // This is our definition of "production mode": when asserts are 
disabled.
-        //
+        String productionModeFlag = System.getProperty( 
"beehive.produtionmode" );
         
-        try
+        if ( productionModeFlag != null )
         {
-            assert false;
+            _productionMode = Boolean.parseBoolean( productionModeFlag );
         }
-        catch ( AssertionError e )
+        else
         {
-            _productionMode = false;
+            //
+            // This is our default definition of "production mode": when 
asserts are disabled (the following statement
+            // sets _productionMode to false when asserts are enabled).
+            //
+            assert ( _productionMode = false ) || true;
         }
     }
 
+    protected DefaultServerAdapter()
+    {
+    }
+    
+    /**
+     * Tell whether the system is in production mode.
+     * 
+     * @return <code>true</code> if the system property 
"beehive.productionmode" is set to "true", or if asserts are
+     *         disabled for this class in the case where the system property 
has no value; <code>false</code>  if the
+     *         system property is set to "false", or if asserts are enabled 
for this class in the case where the
+     *         system property has no value.
+     */ 
     public boolean isInProductionMode()
     {
         return _productionMode;
     }
 
-    public Boolean isSecureResource( String uri, HttpServletRequest request )
+    public SecurityProtocol getSecurityProtocol( String uri, 
HttpServletRequest request )
     {
-        return null;
+        // TODO: implement this based on parsing of web.xml
+        return SecurityProtocol.UNSPECIFIED;
     }
 
-    public boolean checkSecurity( String uri, HttpServletRequest request, 
HttpServletResponse response )
-                                  
+    public boolean doSecurityRedirect( String uri, HttpServletRequest request, 
HttpServletResponse response )
     {
         return false;
     }
 
+    /**
+     * Get the non-secure server listen port.  This default implementation 
simply returns the current server port.
+     */ 
     public int getListenPort( HttpServletRequest request )
     {
         return -1;
@@ -80,10 +95,12 @@
     public void login( String username, String password, HttpServletRequest 
request, HttpServletResponse response )
             throws LoginException
     {
+        throw new UnsupportedOperationException( "login is not supported by " 
+ DefaultServerAdapter.class.getName() );
     }
 
     public void logout( boolean invalidateSessions, HttpServletRequest 
request, HttpServletResponse response )
     {
+        throw new UnsupportedOperationException( "logout is not supported by " 
+ DefaultServerAdapter.class.getName() );
     }
     
     public String getFullContextPath( HttpServletRequest request )
@@ -91,14 +108,11 @@
         return request.getContextPath();
     }
 
+    /**
+     * This default implementation does nothing; the functionality (and the 
need for it) is server-specific.
+     */ 
     public void ensureFailover( String attrName, Object attrVal, 
HttpServletRequest request )
     {
-        // By default, this doesn't do anything -- it's server-specific.
-    }
-
-    public void initServletContext( ServletContext servletContext )
-    {
-        _servletContext = servletContext;
     }
 
     public void beginRequest( HttpServletRequest request, HttpServletResponse 
response )
@@ -117,5 +131,15 @@
     protected ServletContext getServletContext()
     {
         return _servletContext;
+    }
+    
+    public void setServletContext( ServletContext servletContext )
+    {
+        _servletContext = servletContext;
+    }
+    
+    public String getPlatformName()
+    {
+        return "generic";
     }
 }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowConstants.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowConstants.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowConstants.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowConstants.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowConstants.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowConstants.java
 Mon Nov 22 15:53:44 2004
@@ -31,7 +31,7 @@
     public static final String BEGIN_ACTION_NAME = "begin";
     
     /**
-     * The file extension for user-defined [EMAIL PROTECTED] 
PageFlowController} source files.
+     * The extension used for hitting a [EMAIL PROTECTED] PageFlowController} 
through its URI.
      */ 
     public static final String JPF_EXTENSION = ".jpf";
     
@@ -42,18 +42,21 @@
     
     /**
      * The name of the [EMAIL PROTECTED] GlobalApp} class defined by the user 
for a web application.
+     * 
+     * @deprecated This constant will be removed with no replacement.
      */ 
     public static final String GLOBALAPP_CLASSNAME = "global.Global";
     
     /**
      * The name of the source file for the [EMAIL PROTECTED] GlobalApp} class 
defined by the user for a
      * web application.
+     * 
+     * @deprecated This constant will be removed with no replacement.
      */ 
     public static final String GLOBALAPP_SOURCEFILE_NAME = "Global.app";
     
     /**
-     * The filename prefix for Struts module configuration files generated by 
the page flow
-     * compiler.
+     * The filename prefix for Struts module configuration files generated 
from page flow source files.
      */ 
     public static final String JPF_MODULE_CONFIG_PREFIX = "jpf-struts-config";
 
@@ -69,39 +72,26 @@
 
     /**
      * Servlet context-param that configures the maximum number of consecutive 
server forwards before error.
+     * 
+     * @deprecated Instead of this context-param, use the 
<code>max-forwards-per-request</code> element within
+     *             <code>pageflow-config</code> in /WEB-INF/netui-config.xml.
      */ 
     public static final String FORWARD_OVERFLOW_COUNT_PARAM = 
"jpf-forward-overflow-count";
     
     /**
-     * Servlet context-param that configures the maximum size of the page flow 
nesting stack.
+     * Servlet context-param that configures the maximum depth of the page 
flow nesting stack.
+     * 
+     * @deprecated Instead of this context-param, use the 
<code>max-nesting-stack-depth</code> element within
+     *             <code>pageflow-config</code> in /WEB-INF/netui-config.xml.
      */ 
     public static final String NESTING_OVERFLOW_COUNT_PARAM = 
"jpf-nesting-overflow-count";
     
     /**
-     * The default maximum number of consecutive server forwards before error.
-     */ 
-    public static final int DEFAULT_FORWARD_OVERFLOW_COUNT = 50;
-    
-    /**
-     * The default maximum size of the page flow nesting stack.
-     */ 
-    public static final int DEFAULT_NESTING_OVERFLOW_COUNT = 25;
-
-    /**
-     * Servlet context-param that configures a [EMAIL PROTECTED] 
org.apache.beehive.netui.pageflow.handler.ForwardRedirectHandler}-
-     * derived class to instantiate to handle forwards and redirects.
-     */ 
-    public static final String HTTP_REDIRECTOR_PARAM = "jpf-http-redirector";
-    
-    /**
-     * Servlet context-param that configures a [EMAIL PROTECTED] 
org.apache.beehive.netui.pageflow.handler.LoginHandler}-derived
-     * class to instantiate to handle user logins.
-     */ 
-    public static final String LOGIN_HANDLER_PARAM = "jpf-login-handler";
-    
-    /**
      * Servlet context-param that configures whether to apply security 
constraints on server forwards to page
      * flow actions.  Normally, security constraints are not applied on server 
forwards.
+     * 
+     * @deprecated Instead of this context-param, use the 
<code>ensure-secure-forwards</code> element within
+     *             <code>pageflow-config</code> in /WEB-INF/netui-config.xml.
      */ 
     public static final String SECURE_FORWARDS_PARAM = "jpf-secure-forwards";
     

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
   Mon Nov 22 15:53:44 2004
@@ -22,7 +22,6 @@
 //internal imports
 import org.apache.beehive.netui.pageflow.util.UrlTemplateDescriptor;
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
-import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 import org.apache.beehive.netui.util.config.ConfigUtil;
 import org.apache.beehive.netui.util.config.ConfigInitializationException;
@@ -32,17 +31,17 @@
 import javax.servlet.ServletContextListener;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
 import java.io.InputStream;
 import java.io.IOException;
 
+import static 
org.apache.beehive.netui.pageflow.internal.InternalConstants.NETUI_CONFIG_PATH;
+
 
 /**
  * Performs various initialization at ServletContext-init time.
  */ 
 public class PageFlowContextListener implements ServletContextListener
 {
-    private static final String CONFIG_FILE = "/WEB-INF/netui-config.xml";
     private static final String ALREADY_INIT_ATTR = 
InternalConstants.ATTR_PREFIX + "contextInit";
             
     private static final Logger _log = Logger.getInstance( 
PageFlowContextListener.class );
@@ -68,7 +67,7 @@
         
         try
         {
-            InputStream configInput = servletContext.getResourceAsStream( 
CONFIG_FILE );
+            InputStream configInput = servletContext.getResourceAsStream( 
NETUI_CONFIG_PATH );
             
             try
             {
@@ -84,15 +83,15 @@
                 {
                     if ( _log.isErrorEnabled() )
                     {
-                        _log.error( "Could not close input for " + CONFIG_FILE 
);
+                        _log.error( "Could not close input for " + 
NETUI_CONFIG_PATH );
                     }
                 }
             }
         }
         catch ( ConfigInitializationException e )
         {
-            _log.fatal( "Could not initialize from " + CONFIG_FILE, e );
-            throw new IllegalStateException( "Could not initialize from " + 
CONFIG_FILE, e );
+            _log.fatal( "Could not initialize from " + NETUI_CONFIG_PATH, e );
+            throw new IllegalStateException( "Could not initialize from " + 
NETUI_CONFIG_PATH, e );
         }
         
         ContextCache.init( servletContext );

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
  (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
  Mon Nov 22 15:53:44 2004
@@ -486,7 +486,7 @@
             // security check may not have been done for the request URI.  In 
this case, a redirect
             // to https may happen during checkSecurity().
             //
-            if ( serverAdapter.checkSecurity( uri, request, response ) )
+            if ( serverAdapter.doSecurityRedirect( uri, request, response ) )
             {
                 if ( _log.isDebugEnabled() )
                 {
@@ -1343,10 +1343,19 @@
         }
     }
     
-    protected void changeScheme( String webappRelativeURI, String scheme, int 
port,
-                                 HttpServletRequest request, 
HttpServletResponse response )
+    protected boolean changeScheme( String webappRelativeURI, String scheme, 
int port, HttpServletRequest request,
+                                 HttpServletResponse response )
         throws URISyntaxException, IOException, ServletException
     {
+        if ( port == -1 )
+        {
+            if ( _log.isWarnEnabled() )
+            {
+                _log.warn( "Could not change the scheme to " + scheme + " 
because the relevant port was not provided "
+                           + "by the ServerAdapter." );
+                return false;
+            }
+        }
         //
         // First put all request attributes into the session, so they can be 
added to the
         // redirected request.
@@ -1385,6 +1394,8 @@
         {
             _log.debug( "Redirected to " + redirectURI );
         }
+        
+        return true;
     }
     
     /**
@@ -1404,30 +1415,28 @@
         
         if ( contextCache.shouldDoSecureForwards() )
         {
-            Boolean needSecure = PageFlowUtils.isSecureResource( uri, 
servletContext, request );
+            SecurityProtocol sp = PageFlowUtils.getSecurityProtocol( uri, 
servletContext, request );
             
-            if ( needSecure != null )
+            if ( ! sp.equals( SecurityProtocol.UNSPECIFIED ) )
             {
                 try
                 {
+                    ServerAdapter sa = contextCache.getServerAdapter();
+                    
                     if ( request.isSecure() )
                     {
-                        if ( needSecure.equals( Boolean.FALSE ) )
+                        if ( sp.equals( SecurityProtocol.UNSECURE ) )
                         {
-                            changeScheme( uri, SCHEME_UNSECURE,
-                                          
contextCache.getServerAdapter().getListenPort(request),
-                                          request, response );
-                            securityRedirected = true;
+                            securityRedirected =
+                                changeScheme( uri, SCHEME_UNSECURE, 
sa.getListenPort( request ), request, response );
                         }
                     }
                     else
                     {
-                        if ( needSecure.equals( Boolean.TRUE ) )
+                        if ( sp.equals( SecurityProtocol.SECURE ) )
                         {
-                            changeScheme( uri, SCHEME_SECURE, 
-                                          
contextCache.getServerAdapter().getSecureListenPort(request),
-                                          request, response );
-                            securityRedirected = true;
+                            securityRedirected = changeScheme( uri, 
SCHEME_SECURE,  sa.getSecureListenPort( request ),
+                                                               request, 
response );
                         }
                     }
                 }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
     Mon Nov 22 15:53:44 2004
@@ -22,6 +22,7 @@
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.RequestValues;
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
+import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
 import org.apache.beehive.netui.pageflow.scoping.ScopedResponse;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
@@ -172,7 +173,7 @@
      */
     public static final Stack getPageFlowStack( HttpServletRequest request )
     {
-        return ( PageFlowStack.get( request, true ).getLegacyStack() );
+        return PageFlowStack.get( request, true ).getLegacyStack();
     }
     
     /**
@@ -239,7 +240,7 @@
      */ 
     public static GlobalApp getGlobalApp( HttpServletRequest request )
     {
-        SharedFlowController sf = getSharedFlow( GLOBALAPP_CLASSNAME, request 
);
+        SharedFlowController sf = getSharedFlow( 
InternalConstants.GLOBALAPP_CLASSNAME, request );
         return sf instanceof GlobalApp ? ( GlobalApp ) sf : null;
     }
 
@@ -263,7 +264,7 @@
     
     public static void deleteGlobalApp( HttpServletRequest request )
     {
-        deleteSharedFlow( GLOBALAPP_CLASSNAME, request );
+        deleteSharedFlow( InternalConstants.GLOBALAPP_CLASSNAME, request );
     }
     
     public static void deleteSharedFlow( String sharedFlowClassName, 
HttpServletRequest request )
@@ -574,15 +575,12 @@
      * @param uri the URI to the [EMAIL PROTECTED] PageFlowController}, which 
should be relative to the
      *            web application root (i.e., it should not include the 
context path).
      */
-    public static String getJpfClassName( String uri )
+    public static String getPageFlowClassName( String uri )
     {
         assert uri != null;
         assert uri.length() > 0;
         
-        if ( uri.startsWith( "/" ) )
-        {
-            uri = uri.substring( 1 );
-        }
+        if ( uri.charAt( 0 ) == '/' ) uri = uri.substring( 1 );
         
         assert FileUtils.osSensitiveEndsWith( uri, JPF_EXTENSION ) : uri;
         if ( FileUtils.osSensitiveEndsWith( uri, JPF_EXTENSION ) ) 
@@ -594,6 +592,19 @@
     }
     
     /**
+     * Get the class name of a [EMAIL PROTECTED] PageFlowController}, given 
the URI to it.
+     * 
+     * @deprecated Use [EMAIL PROTECTED] #getPageFlowClassName(String)} 
instead.
+     * 
+     * @param uri the URI to the [EMAIL PROTECTED] PageFlowController}, which 
should be relative to the
+     *            web application root (i.e., it should not include the 
context path).
+     */
+    public static String getJpfClassName( String uri )
+    {
+        return getPageFlowClassName( uri );
+    }
+    
+    /**
      * Get the URI for a [EMAIL PROTECTED] PageFlowController}, given its 
class name.
      * 
      * @param className the name of the [EMAIL PROTECTED] PageFlowController} 
class.
@@ -666,13 +677,14 @@
      *         a transport-guarantee of <code>NONE</code> is associated with 
the given resource; or
      *         <code>null</code> if there is no transport-guarantee associated 
with the given resource.
      */ 
-    public static Boolean isSecureResource( String uri, ServletContext 
servletContext, HttpServletRequest request )
+    public static SecurityProtocol getSecurityProtocol( String uri, 
ServletContext servletContext,
+                                                        HttpServletRequest 
request )
     {
-        return ContextCache.get( servletContext 
).getServerAdapter().isSecureResource( uri, request );
+        return ContextCache.get( servletContext 
).getServerAdapter().getSecurityProtocol( uri, request );
     }
     
     /**
-     * @deprecated Use [EMAIL PROTECTED] #isSecureResource(String, 
ServletContext, HttpServletRequest)} instead.
+     * @deprecated Use [EMAIL PROTECTED] #getSecurityProtocol(String, 
ServletContext, HttpServletRequest)} instead.
      */ 
     public static Boolean isSecureResource( String uri, ServletContext context 
)
     {

Added: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SecurityProtocol.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SecurityProtocol.java?view=auto&rev=106241
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SecurityProtocol.java
  Mon Nov 22 15:53:44 2004
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow;
+
+/**
+ * Enumeration to represent secure/unsecure/unspecified values associated with 
URIs in the webapp.
+ */ 
+public enum SecurityProtocol
+{
+    SECURE,
+    UNSECURE,
+    UNSPECIFIED
+}

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServerAdapter.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServerAdapter.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServerAdapter.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServerAdapter.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServerAdapter.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/ServerAdapter.java
     Mon Nov 22 15:53:44 2004
@@ -32,6 +32,17 @@
 public interface ServerAdapter
 {
     /**
+     * Called upon the initialization of the given ServletContext, to decide 
whether this ServerAdapter instance
+     * should become active.
+     * 
+     * @param servletContext the ServletContext being initialized.
+     * @return <code>true</code> if the environment is appropriate for this 
ServerAdapter, and it should become active.
+     */ 
+    public boolean accept( ServletContext servletContext );
+    
+    public void setServletContext( ServletContext servletContext );
+    
+    /**
      * Tell whether the server is running in production mode.  This is 
server-dependent, but by default it should
      * return <code>false</code> only if the System property 
<code>pageflow:devmode</code> is set.
      * 
@@ -62,7 +73,7 @@
      *         a transport-guarantee of <code>NONE</code> is associated with 
the given resource; or
      *         <code>null</code> if there is no transport-guarantee associated 
with the given resource.
      */     
-    public Boolean isSecureResource( String uri, HttpServletRequest request );
+    public SecurityProtocol getSecurityProtocol( String uri, 
HttpServletRequest request );
 
     /**
      * Cause the server to do a security check for the given URI.  If 
required, it does a redirect to
@@ -73,7 +84,7 @@
      * @param response the current HttpServletResponse.
      * @return <code>true</code> if a redirect occurred.
      */ 
-    boolean checkSecurity( String uri, HttpServletRequest request, 
HttpServletResponse response );
+    boolean doSecurityRedirect( String uri, HttpServletRequest request, 
HttpServletResponse response );
                            
     
     /**
@@ -136,13 +147,6 @@
     public void ensureFailover( String attrName, Object attrVal, 
HttpServletRequest request );
     
     /**
-     * Called upon the initialization of the given ServletContext.
-     * 
-     * @param servletContext the ServletContext being initialized.
-     */ 
-    public void initServletContext( ServletContext servletContext );
-    
-    /**
      * Called at the beginning of each processed request.
      * 
      * @param request the current HttpServletRequest.
@@ -165,4 +169,11 @@
      * @return a new ControlBeanContext.
      */
     public ControlBeanContext createControlBeanContext( HttpServletRequest 
request, HttpServletResponse response );
+    
+    /**
+     * Get the name of the platform, which may be used to find 
platform-specific configuration files.
+     * 
+     * @return the name of the platform
+     */ 
+    public String getPlatformName(); 
 }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java
     (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/ContextCache.java
     Mon Nov 22 15:53:44 2004
@@ -21,10 +21,12 @@
 import org.apache.beehive.netui.util.config.ConfigUtil;
 import org.apache.beehive.netui.util.config.bean.NetuiConfigDocument;
 import org.apache.beehive.netui.util.config.bean.PageflowHandlers;
+import org.apache.beehive.netui.util.config.bean.PageflowConfig;
+import org.apache.beehive.netui.util.DiscoveryUtils;
 import org.apache.beehive.netui.pageflow.PageFlowActionServlet;
 import org.apache.beehive.netui.pageflow.PageFlowContextListener;
-import org.apache.beehive.netui.pageflow.PageFlowConstants;
 import org.apache.beehive.netui.pageflow.ServerAdapter;
+import org.apache.beehive.netui.pageflow.DefaultServerAdapter;
 import org.apache.beehive.netui.pageflow.handler.LoginHandler;
 import org.apache.beehive.netui.pageflow.handler.ForwardRedirectHandler;
 import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
@@ -34,8 +36,10 @@
 import javax.servlet.ServletContext;
 import java.io.Serializable;
 
+import static org.apache.beehive.netui.pageflow.PageFlowConstants.*;
 
-public class ContextCache implements Serializable, PageFlowConstants
+
+public class ContextCache implements Serializable
 {
     private static final Logger _log = Logger.getInstance( ContextCache.class 
);
     
@@ -44,14 +48,15 @@
     private static final String DEFAULT_FWD_REDIRECT_HANDLER_CLASS = 
DefaultForwardRedirectHandler.class.getName();
     private static final String DEFAULT_RELOADABLE_CLASS_HANDLER_CLASS = 
DefaultReloadableClassHandler.class.getName();
     private static final String DEFAULT_EXCEPTIONS_HANDLER_CLASS = 
DefaultExceptionsHandler.class.getName();
-    private static final String CATALINA_HOME_PROP = "catalina.home";
     private static final String SERVER_ADAPTER_PROP = "pageflow.serveradapter";
-    private static final String WL_SERVER_ADAPTER_CLASS = 
"com.bea.wlw.netui.pageflow.internal.WebLogicServerAdapter";
-    private static final String TOMCAT_SERVER_ADAPTER_CLASS = 
"org.apache.beehive.netui.tomcat.TomcatServerAdapter";
+    private static final int DEFAULT_MAX_FORWARDS_PER_REQUEST = 25;
+    private static final int DEFAULT_MAX_NESTING_STACK_DEPTH = 10;
+    
+    public static final int serialVersionUID = 1;
     
     private boolean _secureForwards = false;
-    private int _forwardOverflowCount = DEFAULT_FORWARD_OVERFLOW_COUNT;
-    private int _nestingOverflowCount = DEFAULT_NESTING_OVERFLOW_COUNT;
+    private int _forwardOverflowCount;
+    private int _nestingOverflowCount;
     
     private ForwardRedirectHandler _forwardRedirectHandler = null;
     private LoginHandler _loginHandler = null;
@@ -119,22 +124,68 @@
         return cache;
     }
     
-    private ContextCache( ServletContext servletContext )
+    private void loadLegacySettings( ServletContext servletContext )
     {
-        _serverAdapter = createServerAdapter();
-        _serverAdapter.initServletContext( servletContext );  // callback
+        PageflowConfig pageflowConfig = 
ConfigUtil.getConfig().getPageflowConfig();
+        if ( pageflowConfig == null ) pageflowConfig = 
ConfigUtil.getConfig().addNewPageflowConfig();  // for defaults
         
+        Integer forwardOverflowCount =
+                loadLegacyParam( FORWARD_OVERFLOW_COUNT_PARAM, servletContext, 
"max-forwards-per-request" );
+        if ( forwardOverflowCount != null )
+        {
+            _forwardOverflowCount = forwardOverflowCount;
+        }
+        else
+        {
+            // Why can't we read the default value from the XmlObjext?
+            _forwardOverflowCount = pageflowConfig.isSetMaxForwardsPerRequest()
+                                    ? pageflowConfig.getMaxForwardsPerRequest()
+                                    : DEFAULT_MAX_FORWARDS_PER_REQUEST;
+        }
+        
+        Integer nestingOverflowCount =
+                loadLegacyParam( NESTING_OVERFLOW_COUNT_PARAM, servletContext, 
"max-nesting-stack-depth" );
+        if ( nestingOverflowCount != null )
+        {
+            _nestingOverflowCount = nestingOverflowCount;
+        }
+        else
+        {
+            // Why can't we read the default value from the XmlObjext?
+            _nestingOverflowCount = pageflowConfig.isSetMaxNestingStackDepth()
+                                    ? pageflowConfig.getMaxNestingStackDepth()
+                                    : DEFAULT_MAX_NESTING_STACK_DEPTH;
+        }
         
         String doSecureForwards = servletContext.getInitParameter( 
SECURE_FORWARDS_PARAM );
-        _secureForwards = ( Boolean.TRUE.toString().equals( doSecureForwards ) 
);
         
-        // TODO: deprecate these, and move them to netui-config.xml
-        _forwardOverflowCount =
-            loadIntParam( FORWARD_OVERFLOW_COUNT_PARAM, 
DEFAULT_FORWARD_OVERFLOW_COUNT, servletContext );
-        _nestingOverflowCount =
-            loadIntParam( NESTING_OVERFLOW_COUNT_PARAM, 
DEFAULT_NESTING_OVERFLOW_COUNT, servletContext );
-
+        if ( doSecureForwards != null )
+        {
+            _log.warn( "Servlet context-param " + SECURE_FORWARDS_PARAM +
+                       " is deprecated; use the ensure-secure-forwards element 
within pageflow-config in "
+                       + InternalConstants.NETUI_CONFIG_PATH );
+            _secureForwards = Boolean.parseBoolean( doSecureForwards );
+        }
+        else
+        {
+            _secureForwards = pageflowConfig.getEnsureSecureForwards();
+        }
         
+        
+    }
+    private ContextCache( ServletContext servletContext )
+    {
+        _serverAdapter = createServerAdapter( servletContext );
+        
+        //
+        // Try loading some settings (max-forwards-per-requst, 
max-nesting-stack-depth, ensure-secure-forwards) from
+        // the deprecated locations first, then fall back to netui-config.xml.
+        //
+        loadLegacySettings( servletContext );
+        
+        //
+        // Load/create Handlers.
+        //
         NetuiConfigDocument.NetuiConfig netuiConfig = ConfigUtil.getConfig();
         PageflowHandlers handlers = netuiConfig.getPageflowHandlers();
         
@@ -176,10 +227,7 @@
     {
         if ( className != null )
         {
-            if ( _log.isInfoEnabled() )
-            {
-                _log.info( "Loading handler class " + className );
-            }
+            _log.info( "Loading handler class " + className );
             
             try
             {
@@ -193,24 +241,21 @@
                 }
                 else
                 {
-                    if ( _log.isErrorEnabled() )
-                    {
-                        _log.error( "Handler instance is of wrong type; 
expected " + desiredClass.getName()
-                                    + ", got " + instance.getClass().getName() 
);
-                    }
+                    _log.error( "Handler instance is of wrong type; expected " 
+ desiredClass.getName()
+                                + ", got " + instance.getClass().getName() );
                 }
             }
             catch ( ClassNotFoundException e )
             {
-                if ( _log.isErrorEnabled() ) _log.error( "Could not find 
handler class " + className );
+                _log.error( "Could not find Handler class " + className, e );
             }
             catch ( InstantiationException e )
             {
-                if ( _log.isErrorEnabled() ) _log.error( "Could not 
instantiate handler of type " + className );
+                _log.error( "Could not instantiate Handler of type " + 
className, e );
             }
             catch ( IllegalAccessException e )
             {
-                if ( _log.isErrorEnabled() ) _log.error( "Could not 
instantiate handler of type " + className );
+                _log.error( "Could not instantiate Handler of type " + 
className, e );
             }
         }
         
@@ -237,76 +282,100 @@
         return _nestingOverflowCount;
     }
     
-    private static int loadIntParam( String paramName, int defaultVal, 
ServletContext servletContext )
+    private static Integer loadLegacyParam( String paramName, ServletContext 
servletContext, String configElementName )
     {
         String strVal = servletContext.getInitParameter( paramName );
         
         if ( strVal != null )
         {
+            _log.warn( "Servlet context-param " + paramName + "is deprecated; 
use the " + configElementName
+                       + " element within pageflow-config in " + 
InternalConstants.NETUI_CONFIG_PATH );
+            
             try
             {
                 return Integer.parseInt( strVal );
             }
             catch ( NumberFormatException e )
             {
-                _log.error( "Could not parse integer value from context-param 
" + paramName + "; using default "
-                            + defaultVal + ".", e );
+                _log.error( "Could not parse integer value from context-param 
" + paramName + '.' );
             }
         }
         
-        return defaultVal;
+        return null;
     }
     
-    private static ServerAdapter createServerAdapter()
+    private static ServerAdapter tryServerAdapter( Class serverAdapterClass, 
ServletContext servletContext )
     {
-        String serverAdapterClassName = System.getProperty( 
SERVER_ADAPTER_PROP );
-        boolean userSpecifiedServerAdapter = serverAdapterClassName != null;
-        
-        if ( serverAdapterClassName == null )
+        try
         {
-            if ( System.getProperty( CATALINA_HOME_PROP ) != null )
+            ServerAdapter sa = ( ServerAdapter ) 
serverAdapterClass.newInstance();
+            
+            try
             {
-                serverAdapterClassName = TOMCAT_SERVER_ADAPTER_CLASS;
+                if ( sa.accept( servletContext ) )
+                {
+                    _log.info( "ServerAdapter " + serverAdapterClass.getName() 
+ " accepted." );
+                    sa.setServletContext( servletContext );
+                    return sa;
+                }
+                else
+                {
+                    _log.info( "ServerAdapter " + serverAdapterClass.getName() 
+ " is present but did not accept." );
+                }
             }
-            else
+            catch ( Exception e )
             {
-                serverAdapterClassName = WL_SERVER_ADAPTER_CLASS;
+                _log.error( serverAdapterClass.getName() + ".accept() threw an 
exception.", e );
             }
-            
-        }
-            
-        try
-        {
-            Class serverAdapterClass = Class.forName( serverAdapterClassName );
-            ServerAdapter serverAdapter = ( ServerAdapter ) 
serverAdapterClass.newInstance();
-            
-            if ( _log.isInfoEnabled() )
+            catch ( LinkageError e )
             {
-                _log.info( "Created server adapter of type " + 
serverAdapterClass );
+                _log.error( serverAdapterClass.getName() + ".accept() caused a 
linkage error and may be out of date.", e );
             }
-            
-            return serverAdapter;
         }
-        catch ( ClassNotFoundException e )
+        catch ( InstantiationException e )
         {
-            if ( userSpecifiedServerAdapter && _log.isErrorEnabled() )
-            {
-                _log.error( "Could not find ServerAdapter class " + 
serverAdapterClassName
-                            + "; using " + 
DefaultServerAdapter.class.getName() + "." );
-            }
-            
-            return new DefaultServerAdapter();
+            _log.error( "Could not create instance of ServerAdapter class " + 
serverAdapterClass.getName(), e );
+        }
+        catch ( IllegalAccessException e )
+        {
+            _log.error( "Could not create instance of ServerAdapter class " + 
serverAdapterClass.getName(), e );
         }
         catch ( Exception e )
         {
-            if ( _log.isErrorEnabled() )
+            _log.error( "Error creating instance of ServerAdapter class " + 
serverAdapterClass.getName(), e );
+        }
+        
+        return null;
+    }
+    
+    private static ServerAdapter createServerAdapter( ServletContext 
servletContext )
+    {
+        String serverAdapterClassName = System.getProperty( 
SERVER_ADAPTER_PROP );
+        
+        if ( serverAdapterClassName != null )
+        {
+            Class serverAdapterClass = DiscoveryUtils.loadServiceClass( 
serverAdapterClassName, ServerAdapter.class );
+            
+            if ( serverAdapterClass != null )
             {
-                _log.error( "Error instantiating ServerAdapter " + 
serverAdapterClassName
-                            + "; using " + 
DefaultServerAdapter.class.getName() + ".", e );
+                ServerAdapter sa = tryServerAdapter( serverAdapterClass, 
servletContext );
+                if ( sa != null ) return sa;
             }
-            
-            return new DefaultServerAdapter();
         }
+        
+        Class[] classes = DiscoveryUtils.getServiceClasses( 
ServerAdapter.class );
+        
+        for ( int i = 0; i < classes.length; i++ )
+        {
+            ServerAdapter sa = tryServerAdapter( classes[i], servletContext );
+            if ( sa != null ) return sa;
+        }
+        
+        _log.info( "No ServerAdapter specified or discovered; using " + 
DefaultServerAdapter.class );
+        ServerAdapter sa =
+               new DefaultServerAdapter(){ public boolean accept( 
ServletContext servletContext ) { return true; } };
+        sa.setServletContext( servletContext );
+        return sa;
     }
 
     public ServerAdapter getServerAdapter()

Deleted: 
/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultServerAdapter.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultServerAdapter.java?view=auto&rev=106240
==============================================================================

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java
        (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalConstants.java
        Mon Nov 22 15:53:44 2004
@@ -46,6 +46,7 @@
     public static final String INTERNAL_VAR_PREFIX = "_netui:";
     public static final int    ACTION_EXTENSION_LEN = 
PageFlowConstants.ACTION_EXTENSION.length();
     public static final String GLOBALAPP_MODULE_CONTEXT_PATH = "/-global";
+    public static final String GLOBALAPP_CLASSNAME = "global.Global";
     public static final String GLOBALAPP_MEMBER_NAME = "globalApp";
     public static final String WEBINF_DIR = "/WEB-INF";
     public static final String BEGIN_ACTION_PATH = "/" + 
PageFlowConstants.BEGIN_ACTION_NAME;
@@ -55,5 +56,6 @@
     public static final String CURRENT_LONGLIVED_ATTR = ATTR_PREFIX + 
"curLongLivedModule";
     public static final String SHARED_FLOW_ATTR_PREFIX = ATTR_PREFIX + 
"sharedFlow:";
 
+    public static final String NETUI_CONFIG_PATH = "/WEB-INF/netui-config.xml";
     
 }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/DefaultURLRewriter.java
   Mon Nov 22 15:53:44 2004
@@ -24,6 +24,7 @@
 import org.apache.beehive.netui.pageflow.internal.ContextCache;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.util.FileUtils;
+import org.apache.beehive.netui.util.logging.Logger;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
@@ -34,7 +35,8 @@
 
 public class DefaultURLRewriter extends URLRewriter
 {
-
+    private static final Logger _log = Logger.getInstance( 
DefaultURLRewriter.class );
+    
     public String rewriteName(ServletContext servletContext, ServletRequest 
request, String name)
     {
         // Continue chaining if there is another
@@ -62,12 +64,42 @@
             if ((type.equals(URLRewriter.ACTION_SECURE) || 
(type.equals(URLRewriter.RESOURCE_SECURE))))
             {
                 if (!request.isSecure())
-                    url = internalRewriteUrl(url, "https", 
serverAdapter.getSecureListenPort((HttpServletRequest) request), 
request.getServerName());
+                {
+                    int securePort = 
serverAdapter.getSecureListenPort((HttpServletRequest) request);
+                    
+                    if (securePort != -1)
+                    {
+                        url = internalRewriteUrl(url, "https", securePort, 
request.getServerName());
+                    }
+                    else
+                    {
+                        if (_log.isWarnEnabled())
+                        {
+                            _log.warn("Could not rewrite URL " + url + " to be 
secure because a secure port was" +
+                                      " not provided by the ServerAdapter.");
+                        }
+                    }
+                }
             }
             else
             {
                 if (request.isSecure())
-                    url = internalRewriteUrl(url, "http", 
serverAdapter.getListenPort((HttpServletRequest) request), 
request.getServerName());
+                {
+                    int listenPort = 
serverAdapter.getListenPort((HttpServletRequest) request);
+                    
+                    if (listenPort != -1 )
+                    {
+                        url = internalRewriteUrl(url, "http", listenPort, 
request.getServerName());
+                    }
+                    else
+                    {
+                        if (_log.isWarnEnabled())
+                        {
+                            _log.warn("Could not rewrite URL " + url + " to be 
secure because a secure port was" +
+                                      " not provided by the ServerAdapter.");
+                        }
+                    }
+                }
             }
         }
 

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java&r1=106240&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
   Mon Nov 22 15:53:44 2004
@@ -23,6 +23,7 @@
 
 //internal imports
 import org.apache.beehive.netui.pageflow.PageFlowUtils;
+import org.apache.beehive.netui.pageflow.SecurityProtocol;
 
 //external imports
 import javax.servlet.ServletRequest;
@@ -251,16 +252,15 @@
             secureCheck = secureCheck.substring(0, secureCheck.indexOf("?"));
         }
 
-        Boolean secureResource = PageFlowUtils.isSecureResource(secureCheck, 
context, (HttpServletRequest)request);
-        if (secureResource == null)
+        SecurityProtocol sp = PageFlowUtils.getSecurityProtocol(secureCheck, 
context, (HttpServletRequest)request);
+        if (sp.equals(SecurityProtocol.UNSPECIFIED))
         {
             secure = request.isSecure();
         }
         else
-            secure = secureResource.booleanValue();
+            secure = sp.equals(SecurityProtocol.SECURE);
         return secure;
-
-    }    
+    }
     
     /**
      * Tell whether rewritten form actions should be allowed to have query 
parameters.  If this returns

Copied: incubator/beehive/trunk/netui/src/tomcat-common/5x/build.xml (from 
r106203, incubator/beehive/trunk/netui/src/tomcat-common/4x/build.xml)
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-common/5x/build.xml?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-common/4x/build.xml&r1=106203&p2=incubator/beehive/trunk/netui/src/tomcat-common/5x/build.xml&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/src/tomcat-common/4x/build.xml        
(original)
+++ incubator/beehive/trunk/netui/src/tomcat-common/5x/build.xml        Mon Nov 
22 15:53:44 2004
@@ -6,7 +6,7 @@
     <property file="${os.BEEHIVE_HOME}/beehive.properties"/>
     <property file="${os.BEEHIVE_HOME}/netui/ant/netui.properties"/>
 
-    <property name="module.dir" location="${src.dir}/${module.name}/4x"/>
+    <property name="module.dir" location="${src.dir}/${module.name}/5x"/>
     <property name="module.classpath" location="${servlet23.jar}"/>
 
     <target name="build">
@@ -29,12 +29,12 @@
             <fileset dir="${module.dir}" includes="**/*.properties"/>
         </copy>
 
-        <jar jarfile="${build.lib.dir}/${netui-tomcat-common.4x.jar.name}" 
basedir="${classes.dir}/${module.name}"/>
+        <jar jarfile="${build.lib.dir}/${netui-tomcat-common.5x.jar.name}" 
basedir="${classes.dir}/${module.name}"/>
     </target>
 
     <target name="clean">
         <delete dir="${classes.dir}/${module.name}"/>
-        <delete dir="${build.lib.dir}/${netui-tomcat-common.4x.jar.name}"/>
+        <delete dir="${build.lib.dir}/${netui-tomcat-common.5x.jar.name}"/>
     </target>
 
 </project>

Modified: 
incubator/beehive/trunk/netui/src/tomcat-common/5x/org/apache/beehive/netui/tomcat/PageflowHelper.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-common/5x/org/apache/beehive/netui/tomcat/PageflowHelper.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-common/4x/org/apache/beehive/netui/tomcat/PageflowHelper.java&r1=106203&p2=incubator/beehive/trunk/netui/src/tomcat-common/5x/org/apache/beehive/netui/tomcat/PageflowHelper.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tomcat-common/4x/org/apache/beehive/netui/tomcat/PageflowHelper.java
      (original)
+++ 
incubator/beehive/trunk/netui/src/tomcat-common/5x/org/apache/beehive/netui/tomcat/PageflowHelper.java
      Mon Nov 22 15:53:44 2004
@@ -40,8 +40,8 @@
      * @param response
      * @return <code>true</code> if a redirect occurred.
      */
-    public boolean checkSecurity( String uri, HttpServletRequest request, 
HttpServletResponse response,
-                                  ServletContext servletContext );
+    public boolean doSecurityRedirect( String uri, HttpServletRequest request, 
HttpServletResponse response,
+                                       ServletContext servletContext );
 
     /**
      * Tell whether a web application resource requires a secure transport 
protocol.  This is

Modified: incubator/beehive/trunk/netui/src/tomcat-common/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-common/build.xml?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-common/build.xml&r1=106240&p2=incubator/beehive/trunk/netui/src/tomcat-common/build.xml&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/src/tomcat-common/build.xml   (original)
+++ incubator/beehive/trunk/netui/src/tomcat-common/build.xml   Mon Nov 22 
15:53:44 2004
@@ -10,13 +10,13 @@
     <property name="module.dir" location="${src.dir}/${module.name}"/>
 
     <target name="build">
-        <ant antfile="build.xml" target="build" dir="${module.dir}/4x" 
inheritAll="false">
+        <ant antfile="build.xml" target="build" dir="${module.dir}/5x" 
inheritAll="false">
             <property name="module.name" value="${module.name}"/>
         </ant>
     </target>
 
     <target name="clean">
-        <ant antfile="build.xml" target="clean" dir="${module.dir}/4x" 
inheritAll="false">
+        <ant antfile="build.xml" target="clean" dir="${module.dir}/5x" 
inheritAll="false">
             <property name="module.name" value="${module.name}"/>
         </ant>
     </target>

Copied: incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml (from 
r106203, incubator/beehive/trunk/netui/src/tomcat-server/4x/build.xml)
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-server/4x/build.xml&r1=106203&p2=incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/src/tomcat-server/4x/build.xml        
(original)
+++ incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml        Mon Nov 
22 15:53:44 2004
@@ -6,8 +6,8 @@
     <property file="${os.BEEHIVE_HOME}/beehive.properties"/>
     <property file="${os.BEEHIVE_HOME}/netui/ant/netui.properties"/>
 
-    <property name="module.dir" location="${src.dir}/${module.name}/4x"/>
-    <property name="module.classpath" 
location="${servlet23.jar};${netui-tomcat-common.4x.jar};${log4j.jar};${commons-logging.jar};${catalina.4x.jar};${coyote.4x.jar}"/>
+    <property name="module.dir" location="${src.dir}/${module.name}/5x"/>
+    <property name="module.classpath" 
location="${servlet23.jar};${netui-tomcat-common.5x.jar};${log4j.jar};${commons-logging.jar};${catalina.5x.jar};${coyote.5x.jar}"/>
 
     <target name="build">
         <echo>dompile module: ${module.name}</echo>
@@ -30,12 +30,12 @@
             <fileset dir="${module.dir}" includes="**/mbeans-descriptors.xml"/>
         </copy>
 
-        <jar jarfile="${build.lib.dir}/${netui-tomcat-server.4x.jar.name}" 
basedir="${classes.dir}/${module.name}"/>
+        <jar jarfile="${build.lib.dir}/${netui-tomcat-server.5x.jar.name}" 
basedir="${classes.dir}/${module.name}"/>
     </target>
 
     <target name="clean">
         <delete dir="${classes.dir}/${module.name}"/>
-        <delete dir="${build.lib.dir}/${netui-tomcat-server.4x.jar.name}"/>
+        <delete dir="${build.lib.dir}/${netui-tomcat-server.5x.jar.name}"/>
     </target>
 
 </project>

Modified: 
incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowHelperImpl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowHelperImpl.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-server/4x/org/apache/beehive/netui/tomcat/PageflowHelperImpl.java&r1=106203&p2=incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowHelperImpl.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tomcat-server/4x/org/apache/beehive/netui/tomcat/PageflowHelperImpl.java
  (original)
+++ 
incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowHelperImpl.java
  Mon Nov 22 15:53:44 2004
@@ -21,7 +21,7 @@
 import org.apache.catalina.deploy.SecurityConstraint;
 import org.apache.catalina.deploy.SecurityCollection;
 import org.apache.catalina.authenticator.Constants;
-import org.apache.coyote.tomcat4.CoyoteConnector;
+import org.apache.coyote.tomcat5.CoyoteConnector;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -56,8 +56,8 @@
      * @param response
      * @return <code>true</code> if a redirect occurred.
      */
-    public boolean checkSecurity( String uri, HttpServletRequest request, 
HttpServletResponse response,
-                                  ServletContext servletContext )
+    public boolean doSecurityRedirect( String uri, HttpServletRequest request, 
HttpServletResponse response,
+                                       ServletContext servletContext )
     {
         SecurityConstraint constraint = findBestMatchSecurityConstraint( uri, 
_valve.getContext() );
 
@@ -263,11 +263,10 @@
         return matchingConstraint;
     }
 
-    public static String getFileExtension( String filename )
+    private static String getFileExtension( String filename )
     {
         int lastDot = filename.lastIndexOf( '.' );
-
-        return ( lastDot != -1 ? filename.substring( lastDot + 1 ) : "" );
+        return lastDot != -1 ? filename.substring( lastDot + 1 ) : "";
     }
 
     void initRequest( HttpRequest request, HttpResponse response, 
PageflowValve valve )
@@ -276,5 +275,4 @@
         _response = response;
         _valve = valve;
     }
-
 }

Modified: 
incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowValve.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowValve.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-server/4x/org/apache/beehive/netui/tomcat/PageflowValve.java&r1=106203&p2=incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowValve.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tomcat-server/4x/org/apache/beehive/netui/tomcat/PageflowValve.java
       (original)
+++ 
incubator/beehive/trunk/netui/src/tomcat-server/5x/org/apache/beehive/netui/tomcat/PageflowValve.java
       Mon Nov 22 15:53:44 2004
@@ -38,7 +38,6 @@
  */
 public class PageflowValve extends BasicAuthenticator
 {
-
     public void invoke(Request request, Response response, ValveContext 
valveContext)
             throws IOException, ServletException
     {
@@ -94,7 +93,7 @@
             return;
         }
 
-        throw new FailedLoginException( "Pageflow login failed: " + username 
); // TODO: I18N
+        throw new FailedLoginException( "Page Flow login failed: " + username 
); // TODO: I18N
     }
 
     void logout( boolean invalidateSessions, HttpRequest request, HttpResponse 
response )
@@ -127,8 +126,9 @@
     public boolean checkSecurity( HttpRequest request, HttpResponse response, 
SecurityConstraint constraint )
         throws IOException
     {
+        // TODO: need a LoginConfig for the last argument?
         // the tomcat version of this returns false if the user was 
redirected, so we want the opposite of that
-        return !checkUserData( request, response, constraint );
+        return ! authenticate( request, response, null );
     }
 
 

Modified: incubator/beehive/trunk/netui/src/tomcat-server/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-server/build.xml?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-server/build.xml&r1=106240&p2=incubator/beehive/trunk/netui/src/tomcat-server/build.xml&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/src/tomcat-server/build.xml   (original)
+++ incubator/beehive/trunk/netui/src/tomcat-server/build.xml   Mon Nov 22 
15:53:44 2004
@@ -10,13 +10,13 @@
     <property name="module.dir" location="${src.dir}/${module.name}"/>
 
     <target name="build">
-        <ant antfile="build.xml" target="build" dir="${module.dir}/4x" 
inheritAll="false">
+        <ant antfile="build.xml" target="build" dir="${module.dir}/5x" 
inheritAll="false">
             <property name="module.name" value="${module.name}"/>
         </ant>
     </target>
 
     <target name="clean">
-        <ant antfile="build.xml" target="clean" dir="${module.dir}/4x" 
inheritAll="false">
+        <ant antfile="build.xml" target="clean" dir="${module.dir}/5x" 
inheritAll="false">
             <property name="module.name" value="${module.name}"/>
         </ant>
     </target>

Copied: incubator/beehive/trunk/netui/src/tomcat-webapp/5x/build.xml (from 
r106203, incubator/beehive/trunk/netui/src/tomcat-webapp/4x/build.xml)
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-webapp/5x/build.xml?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-webapp/4x/build.xml&r1=106203&p2=incubator/beehive/trunk/netui/src/tomcat-webapp/5x/build.xml&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/src/tomcat-webapp/4x/build.xml        
(original)
+++ incubator/beehive/trunk/netui/src/tomcat-webapp/5x/build.xml        Mon Nov 
22 15:53:44 2004
@@ -6,8 +6,8 @@
     <property file="${os.BEEHIVE_HOME}/beehive.properties"/>
     <property file="${os.BEEHIVE_HOME}/netui/ant/netui.properties"/>
 
-    <property name="module.dir" location="${src.dir}/${module.name}/4x"/>
-    <property name="module.classpath" 
location="${servlet23.jar};${netui-tomcat-common.4x.jar};${scoping.jar};${pageflow.jar}"/>
+    <property name="module.dir" location="${src.dir}/${module.name}/5x"/>
+    <property name="module.classpath" 
location="${servlet23.jar};${netui-tomcat-common.5x.jar};${scoping.jar};${pageflow.jar};${util.jar}"/>
 
     <target name="build">
         <echo>compile module: ${module.name}</echo>
@@ -27,14 +27,15 @@
         </javac>
         <copy todir="${classes.dir}/${module.name}">
             <fileset dir="${module.dir}" includes="**/*.properties"/>
+            <fileset dir="${module.dir}" includes="META-INF/**"/>
         </copy>
 
-        <jar jarfile="${build.lib.dir}/${netui-tomcat-webapp.4x.jar.name}" 
basedir="${classes.dir}/${module.name}"/>
+        <jar jarfile="${build.lib.dir}/${netui-tomcat-webapp.5x.jar.name}" 
basedir="${classes.dir}/${module.name}"/>
     </target>
 
     <target name="clean">
         <delete dir="${classes.dir}/${module.name}"/>
-        <delete dir="${build.lib.dir}/${netui-tomcat-webapp.4x.jar.name}"/>
+        <delete dir="${build.lib.dir}/${netui-tomcat-webapp.5x.jar.name}"/>
     </target>
 
 </project>

Modified: 
incubator/beehive/trunk/netui/src/tomcat-webapp/5x/org/apache/beehive/netui/tomcat/TomcatServerAdapter.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-webapp/5x/org/apache/beehive/netui/tomcat/TomcatServerAdapter.java?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-webapp/4x/org/apache/beehive/netui/tomcat/TomcatServerAdapter.java&r1=106203&p2=incubator/beehive/trunk/netui/src/tomcat-webapp/5x/org/apache/beehive/netui/tomcat/TomcatServerAdapter.java&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tomcat-webapp/4x/org/apache/beehive/netui/tomcat/TomcatServerAdapter.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/tomcat-webapp/5x/org/apache/beehive/netui/tomcat/TomcatServerAdapter.java
 Mon Nov 22 15:53:44 2004
@@ -17,9 +17,11 @@
  */
 package org.apache.beehive.netui.tomcat;
 
-import org.apache.beehive.netui.tomcat.PageflowHelper;
-import org.apache.beehive.netui.pageflow.internal.DefaultServerAdapter;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
+import org.apache.beehive.netui.pageflow.DefaultServerAdapter;
+import org.apache.beehive.netui.pageflow.SecurityProtocol;
+import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.netui.util.DiscoveryUtils;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -28,6 +30,50 @@
 
 public class TomcatServerAdapter extends DefaultServerAdapter
 {
+    private static final Logger _log = Logger.getInstance( 
TomcatServerAdapter.class );
+    
+    private static final String CATALINA_HOME_PROP = "catalina.home";
+    private static final String HELPER_INTERFACE_CLASSNAME = 
"org.apache.beehive.netui.tomcat.PageflowHelper";
+    
+    
+    public boolean accept( ServletContext servletContext )
+    {
+        if ( System.getProperty( CATALINA_HOME_PROP ) != null )
+        {
+            try
+            {
+                //
+                // See if our helper interface is in the common classloader.
+                //
+                DiscoveryUtils.getClassLoader().loadClass( 
HELPER_INTERFACE_CLASSNAME );
+            }
+            catch ( ClassNotFoundException e )
+            {
+                _log.error( "Could not load helper interface " + 
HELPER_INTERFACE_CLASSNAME + "; cannot use "
+                            + TomcatServerAdapter.class.getName() + ".  Make 
sure that the netui tomcat common" +
+                            " and server jars are in Tomcat's common and 
server lib directories, respectively.", e );
+                return false;
+            }
+            
+            if ( _log.isInfoEnabled() )
+            {
+                _log.info( "Using " + TomcatServerAdapter.class.getName() + " 
as the ServerAdapter." );
+            }
+                    
+            return true;
+        }
+        else
+        {
+            if ( _log.isInfoEnabled() )
+            {
+                _log.info( "Not running in Tomcat (" + CATALINA_HOME_PROP + " 
is not set); "
+                           + TomcatServerAdapter.class.getName() + " will not 
be used." );
+            }
+            
+            return false;
+        }
+    }
+    
     /**
      * Tell whether a web application resource requires a secure transport 
protocol.  This is
      * determined from web.xml; for example, the following block specifies 
that all resources under
@@ -52,55 +98,60 @@
      *         a transport-guarantee of <code>NONE</code> is associated with 
the given resource; or
      *         <code>null</code> if there is no transport-guarantee associated 
with the given resource.
      */
-    public Boolean isSecureResource( String uri, HttpServletRequest request, 
ServletContext servletContext )
+    @Override
+    public SecurityProtocol getSecurityProtocol( String uri, 
HttpServletRequest request )
     {
-        if ( request == null )
-            throw new IllegalArgumentException( 
"ServletAdapter.isSecureResource requires a non-null HttpServletRequest in a 
portable environment" );//NOI18N
-        return getHelper( request ).isSecureResource( uri, request );
+        Boolean isSecure= getHelper( request ).isSecureResource( uri, request 
);
+        
+        return isSecure != null
+               ? ( isSecure ? SecurityProtocol.SECURE : 
SecurityProtocol.UNSECURE )
+               : SecurityProtocol.UNSPECIFIED;
     }
 
-    public boolean checkSecurity( String uri, HttpServletRequest request, 
HttpServletResponse response,
-                                  ServletContext servletContext )
+    @Override
+    public boolean doSecurityRedirect( String uri, HttpServletRequest request, 
HttpServletResponse response )
     {
-        return getHelper( request ).checkSecurity( uri, request, response, 
servletContext );
+        return getHelper( request ).doSecurityRedirect( uri, request, 
response, getServletContext() );
     }
 
+    @Override
     public int getListenPort( HttpServletRequest request )
     {
         return getHelper( request ).getListenPort( request );
     }
 
+    @Override
     public int getSecureListenPort( HttpServletRequest request )
     {
         return getHelper( request ).getSecureListenPort( request );
     }
 
+    @Override
     public void login( String username, String password, HttpServletRequest 
request, HttpServletResponse response )
             throws LoginException
     {
         getHelper( request ).login( username, password, request );
     }
 
+    @Override
     public void logout( boolean invalidateSessions, HttpServletRequest 
request, HttpServletResponse response )
     {
         getHelper( request ).logout( invalidateSessions, request );
     }
 
-    private PageflowHelper getHelper( HttpServletRequest request )
+    private static PageflowHelper getHelper( HttpServletRequest request )
     {
-        try
-        {
-            HttpServletRequest outerRequest = 
ScopedServletUtils.getOuterRequest( request ); 
-            PageflowHelper helper = (PageflowHelper)outerRequest.getAttribute( 
PageflowHelper.PAGEFLOW_HELPER_KEY );
-            if ( helper == null )
-                throw new UnsupportedOperationException( "Pageflow helper not 
found in session. Make sure PageflowValve is installed in this context" );
-            return helper;
-        }
-        catch ( Exception e )
+        HttpServletRequest outerRequest = ScopedServletUtils.getOuterRequest( 
request ); 
+        PageflowHelper helper = ( PageflowHelper ) outerRequest.getAttribute( 
PageflowHelper.PAGEFLOW_HELPER_KEY );
+        
+        if ( helper == null )
         {
-            e.printStackTrace();
-            throw new UnsupportedOperationException( "Error loading pageflow 
tomcat helper." );
+            String msg =
+                    "Page Flow helper not found in session. Make sure 
PageflowValve is installed in this context.";
+            _log.error( msg );
+            throw new UnsupportedOperationException( msg );
         }
+        
+        return helper;
     }
-
 }

Modified: incubator/beehive/trunk/netui/src/tomcat-webapp/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-webapp/build.xml?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/tomcat-webapp/build.xml&r1=106240&p2=incubator/beehive/trunk/netui/src/tomcat-webapp/build.xml&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/src/tomcat-webapp/build.xml   (original)
+++ incubator/beehive/trunk/netui/src/tomcat-webapp/build.xml   Mon Nov 22 
15:53:44 2004
@@ -10,13 +10,13 @@
     <property name="module.dir" location="${src.dir}/${module.name}"/>
 
     <target name="build">
-        <ant antfile="build.xml" target="build" dir="${module.dir}/4x" 
inheritAll="false">
+        <ant antfile="build.xml" target="build" dir="${module.dir}/5x" 
inheritAll="false">
             <property name="module.name" value="${module.name}"/>
         </ant>
     </target>
 
     <target name="clean">
-        <ant antfile="build.xml" target="clean" dir="${module.dir}/4x" 
inheritAll="false">
+        <ant antfile="build.xml" target="clean" dir="${module.dir}/5x" 
inheritAll="false">
             <property name="module.name" value="${module.name}"/>
         </ant>
     </target>

Added: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java?view=auto&rev=106241
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/DiscoveryUtils.java
    Mon Nov 22 15:53:44 2004
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.util;
+
+import org.apache.beehive.netui.util.logging.Logger;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.net.URL;
+
+
+/**
+ * Utility methods for discovering service classes on the classpath.  A 
service class is declared in the standard way,
+ * in a file within META-INF/services where the file name is the class name of 
the service interface, and the file
+ * contains the class name of the implementation.  For example, to declare 
test.MyServiceImpl as a test.MyService
+ * implementation, the file META-INF/services/test.MyService is put on 
classpath (e.g., in a JAR), with contents
+ * "test.MyServiceImpl".
+ */
+public class DiscoveryUtils
+{
+    private static final Logger _log = Logger.getInstance( 
DiscoveryUtils.class );
+    
+    
+    /**
+     * Get the ClassLoader from which service classes will be discovered and 
loaded.
+     */
+    public static ClassLoader getClassLoader()
+    {
+        try
+        {
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            if ( cl != null ) return cl;
+        }
+        catch ( SecurityException e )
+        {
+            if ( _log.isDebugEnabled() )
+            {
+                _log.debug( "Could not get thread context classloader.", e );
+            }
+        }
+        
+        if ( _log.isTraceEnabled() )
+        {
+            _log.trace( "Can't use thread context classloader; using 
classloader for " + DiscoveryUtils.class.getName() );
+        }
+        
+        return DiscoveryUtils.class.getClassLoader();
+    }
+    
+    /**
+     * Get all service classes (on the context classpath) that implement a 
given service interface.
+     *
+     * @param interfaceType the Class that represents the service interface.
+     * @return an array of Classes that are implementations of 
<code>interfaceType</code>.
+     */
+    public static Class[] getServiceClasses( Class interfaceType )
+    {
+        String interfaceName = interfaceType.getName();
+        ArrayList< Class > classes = new ArrayList< Class >();
+        ClassLoader classLoader = getClassLoader();
+        
+        try
+        {
+            Enumeration e = classLoader.getResources( "META-INF/services/" + 
interfaceName );
+            
+            while ( e.hasMoreElements() )
+            {
+                URL url = ( URL ) e.nextElement();
+                
+                if ( _log.isTraceEnabled() )
+                {
+                    _log.trace( "Found service entry for interface " + 
interfaceName + " at " + url );
+                }
+                
+                InputStream is = null;
+                String className = null;
+                
+                try
+                {
+                    is = url.openStream();
+                    BufferedReader reader = new BufferedReader( new 
InputStreamReader( is ) );
+                    className = reader.readLine().trim();
+                    Class serviceClass = loadServiceClass( className, 
interfaceType, classLoader );
+                    if ( serviceClass != null ) classes.add( serviceClass );
+                }
+                catch ( IOException ioe )
+                {
+                    if ( _log.isErrorEnabled() )
+                    {
+                        _log.error( "Could not read service class entry at + " 
+ url );
+                    }
+                }
+                finally
+                {
+                    if ( is != null ) is.close();
+                }
+            }
+        }
+        catch ( IOException e )
+        {
+            if ( _log.isErrorEnabled() )
+            {
+                _log.error( "Could not discover services for " + 
interfaceName, e );
+            }
+        }
+        
+        return classes.toArray( new Class[0] );
+    }
+    
+    /**
+     * Load a service class from the context classloader.
+     *
+     * @param className the name of the service class.
+     * @param interfaceType the service interface that the given class should 
implement.
+     * @return the service Class, or <code>null</code> if an error occurred 
(the error will be logged).
+     */
+    public static Class loadServiceClass( String className, Class 
interfaceType )
+    {
+        return loadServiceClass( className, interfaceType, getClassLoader() );
+    }
+    
+    /**
+     * Load a service class from the context classloader.
+     *
+     * @param className the name of the service class.
+     * @param interfaceType the service interface that the given class should 
implement.
+     * @param classLoader the ClassLoader from which to load the service class.
+     * @return the service Class, or <code>null</code> if an error occurred 
(the error will be logged).
+     */
+    private static Class loadServiceClass( String className, Class 
interfaceType, ClassLoader classLoader )
+    {
+        try
+        {
+            if ( _log.isDebugEnabled() )
+            {
+                _log.debug( "Trying to load service class for interface " + 
interfaceType.getName() + ": " + className );
+            }
+            
+            Class serviceClass = classLoader.loadClass( className );
+            
+            if ( interfaceType.isAssignableFrom( serviceClass ) )
+            {
+                return serviceClass;
+            }
+            else
+            {
+                if ( _log.isErrorEnabled() )
+                {
+                    _log.error( "Service class " + className + " does not 
implement interface "
+                                + interfaceType.getName() );
+                }
+            }
+        }
+        catch ( ClassNotFoundException cnfe )
+        {
+            //
+            // This will happen when the user class was built against an 
out-of-date interface.
+            //
+            if ( _log.isErrorEnabled() )
+            {
+                _log.error( "Could not find service class " + className + " 
for interface " + interfaceType.getName(),
+                            cnfe );
+            }
+        }
+        catch ( LinkageError le )
+        {
+            if ( _log.isErrorEnabled() )
+            {
+                _log.error( "Linkage error when loading service class " + 
className + " for interface "
+                            + interfaceType.getName(), le );
+            }
+        }
+        
+        return null;
+    }
+}

Modified: incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd&r1=106240&p2=incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd&r2=106241
==============================================================================
--- incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd      
(original)
+++ incubator/beehive/trunk/netui/src/util/schema/netui-config.xsd      Mon Nov 
22 15:53:44 2004
@@ -64,6 +64,9 @@
     <xsd:complexType name="pageflow-config">
         <xsd:sequence>
             <xsd:element name="enable-renesting" type="xsd:boolean" 
minOccurs="0" maxOccurs="1" default="false"/>
+            <xsd:element name="max-forwards-per-request" type="xsd:int" 
minOccurs="0" maxOccurs="1" default="25"/>
+            <xsd:element name="max-nesting-stack-depth" type="xsd:int" 
minOccurs="0" maxOccurs="1" default="10"/> 
+            <xsd:element name="ensure-secure-forwards" type="xsd:boolean" 
minOccurs="0" maxOccurs="1" default="false"/> 
             <xsd:element name="multipart-handler" minOccurs="0" maxOccurs="1" 
default="disabled">
                 <xsd:simpleType>
                     <xsd:restriction base="xsd:string">

Modified: 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest1/Begin.jsp
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest1/Begin.jsp?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest1/Begin.jsp&r1=106240&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest1/Begin.jsp&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest1/Begin.jsp
   (original)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest1/Begin.jsp
   Mon Nov 22 15:53:44 2004
@@ -6,8 +6,8 @@
 <body>
 <h4>Nest One</h4>
 <netui:form action="/submit">
-First Name <netui:textBox dataSource="firstName"/></br>
-Last Name <netui:textBox dataSource="lastName"/></br>
+First Name <netui:textBox dataSource="actionForm.firstName"/></br>
+Last Name <netui:textBox dataSource="actionForm.lastName"/></br>
 <netui:button type="submit">Submit</netui:button>
 </netui:form>
 </body>

Modified: 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest2/Begin.jsp
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest2/Begin.jsp?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest2/Begin.jsp&r1=106240&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest2/Begin.jsp&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest2/Begin.jsp
   (original)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/miniTests/nestedFormReturn/nest2/Begin.jsp
   Mon Nov 22 15:53:44 2004
@@ -6,7 +6,7 @@
 <body>
 <h4>Nest Two</h4>
 <netui:form action="/submit">
-Type <netui:textBox dataSource="type"/></br>
+Type <netui:textBox dataSource="actionForm.type"/></br>
 <netui:button type="submit">Submit</netui:button>
 </netui:form>
 </body>

Modified: 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NestedFormReturn.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NestedFormReturn.xml?view=diff&rev=106241&p1=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NestedFormReturn.xml&r1=106240&p2=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NestedFormReturn.xml&r2=106241
==============================================================================
--- 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NestedFormReturn.xml
      (original)
+++ 
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/NestedFormReturn.xml
      Mon Nov 22 15:53:44 2004
@@ -95,7 +95,7 @@
 <a href="/coreWeb/miniTests/nestedFormReturn/nest2.do">Nest Two</a>
 <br />
 <form name="miniTests_nestedFormReturn_Controller_Form" 
action="/coreWeb/miniTests/nestedFormReturn/done.do" method="post">
-Value <input type="text" name="{actionForm.val}" value=""></br>
+Value <input type="text" name="{actionForm.val}"></br>
 <input type="submit" value="Submit">
 </form>
 <br />
@@ -313,8 +313,8 @@
 <body>
 <h4>Nest One</h4>
 <form name="form" action="/coreWeb/miniTests/nestedFormReturn/nest1/submit.do" 
method="post">
-First Name <input type="text" name="{actionForm.firstName}" value=""></br>
-Last Name <input type="text" name="{actionForm.lastName}" value=""></br>
+First Name <input type="text" name="{actionForm.firstName}"></br>
+Last Name <input type="text" name="{actionForm.lastName}"></br>
 <input type="submit" value="Submit">
 </form>
 </body>
@@ -434,7 +434,7 @@
 <a href="/coreWeb/miniTests/nestedFormReturn/nest2.do">Nest Two</a>
 <br />
 <form name="miniTests_nestedFormReturn_Controller_Form" 
action="/coreWeb/miniTests/nestedFormReturn/done.do" method="post">
-Value <input type="text" name="{actionForm.val}" value=""></br>
+Value <input type="text" name="{actionForm.val}"></br>
 <input type="submit" value="Submit">
 </form>
 <br />
@@ -534,7 +534,7 @@
 <body>
 <h4>Nest Two</h4>
 <form name="form" action="/coreWeb/miniTests/nestedFormReturn/nest2/submit.do" 
method="post">
-Type <input type="text" name="{actionForm.type}" value=""></br>
+Type <input type="text" name="{actionForm.type}"></br>
 <input type="submit" value="Submit">
 </form>
 </body>
@@ -650,7 +650,7 @@
 <a href="/coreWeb/miniTests/nestedFormReturn/nest2.do">Nest Two</a>
 <br />
 <form name="miniTests_nestedFormReturn_Controller_Form" 
action="/coreWeb/miniTests/nestedFormReturn/done.do" method="post">
-Value <input type="text" name="{actionForm.val}" value=""></br>
+Value <input type="text" name="{actionForm.val}"></br>
 <input type="submit" value="Submit">
 </form>
 <br />
@@ -791,4 +791,4 @@
   <testCount>7</testCount>
   <passedCount>0</passedCount>
   <failedCount>7</failedCount>
-</recorderSession>
\ No newline at end of file
+</recorderSession>

Reply via email to