You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/05/10 08:32:59 UTC

svn commit: r169423 - in /incubator/beehive/trunk/netui/src: pageflow/org/apache/beehive/netui/pageflow/ pageflow/org/apache/beehive/netui/pageflow/faces/internal/ pageflow/org/apache/beehive/netui/pageflow/internal/ util/org/apache/beehive/netui/util/ util/org/apache/beehive/netui/util/config/

Author: rich
Date: Mon May  9 23:32:58 2005
New Revision: 169423

URL: http://svn.apache.org/viewcvs?rev=169423&view=rev
Log:
Fixes for:
    - http://issues.apache.org/jira/browse/BEEHIVE-615 : Static _config member in ConfigUtil not uninitialized on servlet destroy()
    - http://issues.apache.org/jira/browse/BEEHIVE-623 : Unable to perform background process on manager warning
    - http://issues.apache.org/jira/browse/BEEHIVE-630 : NPE calling page flow action that calls JSF code

tests: bvt in netui (WinXP)
BB: self (linux)


Modified:
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowContextListener.java
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.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/faces/internal/PageFlowActionListener.java
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowNavigationHandler.java
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
    incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java
    incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties

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?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- 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 May  9 23:32:58 2005
@@ -67,33 +67,41 @@
     {
         servletContext.setAttribute( ALREADY_INIT_ATTR, Boolean.TRUE );
         
-        try
+        //
+        // Initialize the config file, unless it's already initialized.  This can happen because the scope for the 
+        // config (static) isn't the same as the scope for PageFlowActionServlet, which may get created and destroyed
+        // within a classloader (which is the case during StrutsTestCase tests).
+        //
+        if ( ! ConfigUtil.isInit() )
         {
-            InputStream configInput = servletContext.getResourceAsStream( InternalConstants.NETUI_CONFIG_PATH );
-            
             try
             {
-                ConfigUtil.init( configInput );
-            }
-            finally
-            {
+                InputStream configInput = servletContext.getResourceAsStream( InternalConstants.NETUI_CONFIG_PATH );
+                
                 try
                 {
-                    if ( configInput != null ) configInput.close();
+                    ConfigUtil.init( configInput );
                 }
-                catch ( IOException e )
+                finally
                 {
-                    if ( _log.isErrorEnabled() )
+                    try
+                    {
+                        if ( configInput != null ) configInput.close();
+                    }
+                    catch ( IOException e )
                     {
-                        _log.error( "Could not close input for " + InternalConstants.NETUI_CONFIG_PATH );
+                        if ( _log.isErrorEnabled() )
+                        {
+                            _log.error( "Could not close input for " + InternalConstants.NETUI_CONFIG_PATH );
+                        }
                     }
                 }
             }
-        }
-        catch ( ConfigInitializationException e )
-        {
-            _log.fatal( "Could not initialize from " + InternalConstants.NETUI_CONFIG_PATH, e );
-            throw new IllegalStateException( "Could not initialize from " + InternalConstants.NETUI_CONFIG_PATH, e );
+            catch ( ConfigInitializationException e )
+            {
+                _log.fatal( "Could not initialize from " + InternalConstants.NETUI_CONFIG_PATH, e );
+                throw new IllegalStateException( "Could not initialize from " + InternalConstants.NETUI_CONFIG_PATH, e );
+            }
         }
         
         AdapterManager.initServletContext( servletContext );

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowStack.java Mon May  9 23:32:58 2005
@@ -21,6 +21,7 @@
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.pageflow.internal.InternalConstants;
 import org.apache.beehive.netui.pageflow.internal.AdapterManager;
+import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.interceptor.action.InterceptorForward;
 import org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptor;
 import org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext;
@@ -254,7 +255,16 @@
         
         if ( request != null )  // may be null if we're called from valueUnbound()
         {
-            ensureFailover( request, pfc.getServletContext() );   // to ensure that this attribute is replicated for session failover
+            ServletContext servletContext = pfc.getServletContext();
+            
+            // The ServletContext reference will be null if the page flow has been serialized/deserialized.
+            if ( servletContext == null )
+            {
+                servletContext = InternalUtils.getServletContext( request );
+                pfc.reinitialize( request, null, servletContext );
+            }
+            
+            ensureFailover( request, servletContext );   // to ensure that this attribute is replicated for session failover
         }
         
         return ppf;
@@ -310,6 +320,14 @@
         while ( ! isEmpty() )
         {
             PageFlowController jpf = pop( null ).getPageFlow();
+            
+            // Note that this page flow may have been serialized/deserialized, which will cause its transient info
+            // to be lost.  Rehydrate it.
+            if ( jpf.getServletContext() == null )
+            {
+                jpf.reinitialize( null, null, event.getSession().getServletContext() );
+            }
+            
             if ( ! jpf.isLongLived() ) jpf.destroy( event.getSession() );
         }
     }

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?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- 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 May  9 23:32:58 2005
@@ -946,8 +946,9 @@
      * @param context the current ServletContext
      * @param request the ServletRequest, which must be a {@link ScopedRequest}.
      * @param response the ServletResponse, which must be a {@link ScopedResponse}.
-     * @param actionOverride if not <code>null</code>, this action-name is used to construct an action
-     *                       URI which is set as the request URI.
+     * @param actionOverride if not <code>null</code>, this qualified action-path is used to construct an action
+     *                       URI which is set as the request URI.  The action-path <strong>must</strong> begin with '/',
+     *                       which makes it qualified from the webapp root.
      * @param autoResolveExtensions a list of URI extensions (e.g., ".do", ".jpf") that will be auto-resolved, i.e.,
      *                              on which this method will be recursively called.  If <code>null</code>, the
      *                              default extensions ".do" and ".jpf" will be used.

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowActionListener.java Mon May  9 23:32:58 2005
@@ -40,21 +40,29 @@
     public void processAction( ActionEvent event ) throws AbortProcessingException
     {
         Object submitFormBean = event.getComponent().getAttributes().get( "submitFormBean" );
+        FacesContext context = FacesContext.getCurrentInstance();
         
         if ( submitFormBean != null )
         {
-            FacesContext context = FacesContext.getCurrentInstance();
-            
             ValueBinding binding = context.getApplication().createValueBinding( "#{" + submitFormBean + '}' );
             Object beanInstance = binding.getValue( context );
             Object request = context.getExternalContext().getRequest();
-            if ( request instanceof ServletRequest )
-            {
-                ActionForm wrappedFormBean = InternalUtils.wrapFormBean( beanInstance );
-                InternalUtils.setForwardedFormBean( ( ServletRequest ) request, wrappedFormBean );
-            }
+            assert request instanceof ServletRequest : request.getClass().getName();
+            ActionForm wrappedFormBean = InternalUtils.wrapFormBean( beanInstance );
+            InternalUtils.setForwardedFormBean( ( ServletRequest ) request, wrappedFormBean );
         }
         
         _delegate.processAction( event );
+        
+        Object request = context.getExternalContext().getRequest();
+        assert request instanceof ServletRequest : request.getClass().getName();
+        ServletRequest servletRequest = ( ServletRequest ) request;
+        
+        String actionURI = ( String ) servletRequest.getAttribute( PageFlowNavigationHandler.ALREADY_FORWARDED_ATTR );
+        
+        if ( actionURI != null )
+        {
+            throw new AbortProcessingException( "PageFlowNavigationHandler forwarded to: " + actionURI );
+        }
     }
 }

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowNavigationHandler.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowNavigationHandler.java?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowNavigationHandler.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/faces/internal/PageFlowNavigationHandler.java Mon May  9 23:32:58 2005
@@ -96,7 +96,7 @@
                         }
                         
                         context.responseComplete();
-                        httpRequest.setAttribute( ALREADY_FORWARDED_ATTR, Boolean.TRUE );
+                        httpRequest.setAttribute( ALREADY_FORWARDED_ATTR, actionURI );
                         
                         try
                         {

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java Mon May  9 23:32:58 2005
@@ -36,6 +36,7 @@
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.HashSet;
 
 import org.apache.beehive.netui.util.internal.concurrent.InternalConcurrentHashMap;
 import java.beans.beancontext.BeanContext;
@@ -171,6 +172,13 @@
         // Note that the annnotation reader doesn't change per-class.  Inherited annotated elements are all read.
         AnnotationReader annReader = AnnotationReader.getAnnotationReader( controlContainerClass, servletContext );
         
+        //
+        // Go through this class and all superclasses, looking for control fields.  Make sure that a superclass control
+        // field never replaces a subclass control field (this is what the 'fieldNames' HashSet is for).
+        //
+        
+        HashSet fieldNames = new HashSet();
+        
         do
         {
             Field[] fields = controlContainerClass.getDeclaredFields();
@@ -178,25 +186,26 @@
             for ( int i = 0; i < fields.length; i++ )
             {
                 Field field = fields[i];
+                String fieldName = field.getName();
                 int modifiers = field.getModifiers();
                 
-                if ( ! Modifier.isStatic( modifiers )
+                if ( ! fieldNames.contains( fieldName ) && ! Modifier.isStatic( modifiers )
                      && annReader.getAnnotation( field.getName(), CONTROL_ANNOTATION_CLASSNAME ) != null )
                 {
                     if ( accessPrivateFields || ! Modifier.isPrivate( modifiers ) )
                     {
                         field.setAccessible( true );
                         ret.put( field, new AnnotatedElementMap( field ) );
+                        fieldNames.add( fieldName );
                     }
                 }
             }
     
-            _controlFieldCache.put( className, ret );
-            
             accessPrivateFields = false;
             controlContainerClass = controlContainerClass.getSuperclass();
         } while ( controlContainerClass != null );
         
+        _controlFieldCache.put( className, ret );
         return ret;
     } 
     

Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java (original)
+++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/config/ConfigUtil.java Mon May  9 23:32:58 2005
@@ -83,6 +83,10 @@
 
         internalInit(is);
     }
+    
+    public static final boolean isInit() {
+        return (_config != null);
+    }
 
     /**
      * Internal method used to re-initialize the static class member that holds the

Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties?rev=169423&r1=169422&r2=169423&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties (original)
+++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties Mon May  9 23:32:58 2005
@@ -682,7 +682,8 @@
 IteratorFactory_Iterator_removeUnsupported=Type {0} does not support the remove() operation.
 ProcessPopulate_handler_nonAtomicExpression=The expression \"{0}\" is not an atomic expression.
 ProcessPopulate_handler_notRegistered=A handler with the name \"{0}\" has not been registered.
-ProcessPopulate_exprUpdateError=Caught exception processing request parameter \"{0}\" during expression update.  Cause: {1}TypeUtils_nullType=Can not convert an object into a null type.
+ProcessPopulate_exprUpdateError=Caught exception processing request parameter \"{0}\" during expression update.  Cause: {1}
+TypeUtils_nullType=Can not convert an object into a null type.
 TypeUtils_noConverterForType=Could not find a TypeConverter for converting a String to an object of type \"{0}\"
 TypeUtils_javaUtilDateConvertError=Caugnt an error converting a String to a DateFormat.SHORT formatted Date: {0}
 TypeUtils_javaSqlDateConvertError=Caught an error converting a String to a java.sql.Date: {0}