You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/01/27 18:06:38 UTC

svn commit: r372913 - in /beehive/trunk/netui/src: pageflow/org/apache/beehive/netui/pageflow/ pageflow/org/apache/beehive/netui/pageflow/internal/ tags-databinding/org/apache/beehive/netui/tags/databinding/xml/ tags-html/org/apache/beehive/netui/tags/...

Author: ekoneil
Date: Fri Jan 27 09:06:26 2006
New Revision: 372913

URL: http://svn.apache.org/viewcvs?rev=372913&view=rev
Log:
Javadoc and code cleanup changes in NetUI.

BB: self
Test: netui pass


Modified:
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
    beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java
    beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/AttributeRenderer.java

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java?rev=372913&r1=372912&r2=372913&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java Fri Jan 27 09:06:26 2006
@@ -17,6 +17,14 @@
  */
 package org.apache.beehive.netui.pageflow;
 
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.Iterator;
+import java.lang.reflect.Modifier;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
 import org.apache.beehive.netui.core.factory.Factory;
 import org.apache.beehive.netui.core.factory.FactoryUtils;
 import org.apache.beehive.netui.util.logging.Logger;
@@ -31,36 +39,18 @@
 import org.apache.beehive.netui.pageflow.config.PageFlowControllerConfig;
 import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
 import org.apache.beehive.netui.pageflow.handler.Handlers;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.config.ControllerConfig;
-import org.apache.struts.action.ActionServlet;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.LinkedHashMap;
-import java.util.Iterator;
-import java.lang.reflect.Modifier;
-
 
 /**
- * Factory for creating {@link FlowController}s - user {@link PageFlowController}s and
- * {@link SharedFlowController}s.
- *
  * <p>
- * When using the FlowControllerFactory to create FlowController objects,
- * the caller should first initialize the
+ * Factory for creating {@link FlowController}s - user {@link PageFlowController}s and {@link SharedFlowController}s.
+ * </p>
+ * <p>
+ * When using the FlowControllerFactory to create FlowController objects, the caller should first initialize the
  * {@link org.apache.beehive.controls.api.context.ControlContainerContext} correctly, using
- * {@link org.apache.beehive.netui.pageflow.internal.JavaControlUtils#initializeControlContext}.
- * Once the FlowController has gone through its life cylce, the caller
- * should uninitialize the ControlContainerContext with a call to
- * {@link org.apache.beehive.netui.pageflow.internal.JavaControlUtils#uninitializeControlContext}.
+ * Once the FlowController has gone through its life cylce, the caller should uninitialize the
+ * {@link org.apache.beehive.controls.api.context.ControlContainerContext}.
  * </p>
  */
 public class FlowControllerFactory

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java?rev=372913&r1=372912&r2=372913&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java Fri Jan 27 09:06:26 2006
@@ -17,143 +17,60 @@
  */
 package org.apache.beehive.netui.pageflow.internal;
 
-import org.apache.beehive.controls.api.bean.Controls;
-import org.apache.beehive.controls.api.bean.ControlBean;
-import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.api.context.ControlBeanContext;
-import org.apache.beehive.controls.api.properties.AnnotatedElementMap;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
+import java.beans.beancontext.BeanContext;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.HashSet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
 
+import org.apache.beehive.controls.api.bean.Controls;
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.properties.AnnotatedElementMap;
+import org.apache.beehive.netui.pageflow.ControlFieldInitializationException;
+import org.apache.beehive.netui.pageflow.PageFlowManagedObject;
+import org.apache.beehive.netui.pageflow.PageFlowUtils;
+import org.apache.beehive.netui.pageflow.PageFlowControlContainerFactory;
+import org.apache.beehive.netui.pageflow.PageFlowControlContainer;
 import org.apache.beehive.netui.util.internal.concurrent.InternalConcurrentHashMap;
-import java.beans.beancontext.BeanContext;
-
 import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.pageflow.*;
-
 
 /**
  * @exclude
  */
 public class JavaControlUtils
 {
-    private static final Logger _log = Logger.getInstance( JavaControlUtils.class );
-    //private static final String CONTROL_CONTEXT_CLASSNAME = ServletBeanContext.class.getName();
+    private static final Logger LOG = Logger.getInstance( JavaControlUtils.class );
     private static final String CONTROL_ANNOTATION_CLASSNAME = Control.class.getName();
 
     /** Map of control-container-class (e.g., PageFlowController) to Map of fields/control-properties. */
     private static InternalConcurrentHashMap/*< String, Map< Field, PropertyMap > >*/ _controlFieldCache =
             new InternalConcurrentHashMap/*< String, Map< Field, PropertyMap > >*/();
 
-    //@todo: These have been commented out because I've added a control container object that manages
-    // the control container.
-    /*
-    public static void initializeControlContext( HttpServletRequest request, HttpServletResponse response,
-                                                 ServletContext servletContext )
-    {
-        ControlBeanContext beanContext = getControlBeanContext( request, response, servletContext, true );
-
-        //
-        // Start a new execution context
-        //
-        if ( beanContext instanceof ServletBeanContext )
-        {
-            ( ( ServletBeanContext ) beanContext ).beginContext( servletContext, request, response );
-        }
-    }
-    */
-
-    /*
-    public static void uninitializeControlContext( HttpServletRequest request, HttpServletResponse response,
-                                                   ServletContext servletContext )
-    {
-
-        ControlBeanContext beanContext = getControlBeanContext( request, response, servletContext, false );
-
-        if ( beanContext instanceof ServletBeanContext )
-        {
-            ( ( ServletBeanContext ) beanContext ).endContext();
-        }
-    }
-    */
-
-    /*
-    private static ControlBeanContext getControlBeanContext( HttpServletRequest request, HttpServletResponse response,
-                                                             ServletContext servletContext, boolean createIfMissing )
-    {
-        //
-        // Retrieve the control bean context from the request, and if it's not there, from the session.
-        // Using the request first ensures that we don't get confused by session invalidation.
-        //
-        ControlBeanContext beanContext = ( ControlBeanContext ) request.getAttribute( CONTROL_CONTEXT_CLASSNAME );
-        if ( beanContext != null ) {
-            if (_log.isTraceEnabled()) {
-                _log.trace("Found ControlBeanContext " + beanContext + " in the request.");
-            }
-            return beanContext;
-        }
-
-        HttpSession session = request.getSession( false );
-        if ( session != null )
-        {
-            beanContext = ( ControlBeanContext ) session.getAttribute( CONTROL_CONTEXT_CLASSNAME );
-
-            if ( beanContext != null )
-            {
-                if (_log.isTraceEnabled()) {
-                    _log.trace("Found ControlBeanContext " + beanContext + " in the session.");
-                }
-                request.setAttribute( CONTROL_CONTEXT_CLASSNAME, beanContext );
-                return beanContext;
-            }
-        }
-
-        //
-        // If no context exists, then create a new one and store it in the session.
-        //
-        if ( createIfMissing )
-        {
-            beanContext = ( ControlBeanContext )
-                AdapterManager.getServletContainerAdapter( servletContext ).createControlBeanContext( request, response );
-            request.getSession().setAttribute( CONTROL_CONTEXT_CLASSNAME, beanContext );
-            request.setAttribute( CONTROL_CONTEXT_CLASSNAME, beanContext );
-            if (_log.isDebugEnabled()) {
-                _log.debug("Created ControlBeanContext " + beanContext);
-            }
-        }
-
-        return beanContext;
-    }
-    */
-
     public static void destroyControl( Object controlInstance )
     {
         assert controlInstance instanceof ControlBean : controlInstance.getClass().getName();
         BeanContext beanContext = ( ( ControlBean ) controlInstance ).getBeanContext();
         if ( beanContext != null ) {
-            if (_log.isTraceEnabled()) {
-                _log.trace("Removing control " + controlInstance + " from ControlBeanContext " + beanContext);
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Removing control " + controlInstance + " from ControlBeanContext " + beanContext);
             }
             beanContext.remove( controlInstance );
         }
     }
 
-
-
     /**
      * @return a map of Field (accessible) -> AnnotationMap
      */
-    private static Map getAccessibleControlFieldAnnotations( Class controlContainerClass, ServletContext servletContext )
+    private static Map getAccessibleControlFieldAnnotations( Class controlClientClass, ServletContext servletContext )
     {
-        String className = controlContainerClass.getName();
+        String className = controlClientClass.getName();
 
         //
         // Reading the annotations is expensive.  See if there's a cached copy of the map.
@@ -170,18 +87,15 @@
         boolean accessPrivateFields = true;
 
         // Note that the annnotation reader doesn't change per-class.  Inherited annotated elements are all read.
-        AnnotationReader annReader = AnnotationReader.getAnnotationReader( controlContainerClass, servletContext );
+        AnnotationReader annReader = AnnotationReader.getAnnotationReader( controlClientClass, 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();
+        do {
+            Field[] fields = controlClientClass.getDeclaredFields();
 
             for ( int i = 0; i < fields.length; i++ )
             {
@@ -197,17 +111,17 @@
                         if ( ! Modifier.isPublic( field.getModifiers() ) ) field.setAccessible( true );
                         ret.put( field, new AnnotatedElementMap( field ) );
                         fieldNames.add( fieldName );
-                        if (_log.isDebugEnabled()) {
-                            _log.debug("Found control field " + fieldName + " in control client class "
-                                       + controlContainerClass.getName());
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Found control field " + fieldName + " in control client class "
+                                       + controlClientClass.getName());
                         }
                     }
                 }
             }
 
             accessPrivateFields = false;
-            controlContainerClass = controlContainerClass.getSuperclass();
-        } while ( controlContainerClass != null );
+            controlClientClass = controlClientClass.getSuperclass();
+        } while ( controlClientClass != null );
 
         _controlFieldCache.put( className, ret );
         return ret;
@@ -220,7 +134,7 @@
      * @param response the current HttpServletRequest
      * @param servletContext the ServletContext
      * @param controlClient the class with possible annotated Control fields
-     * @throws ControlFieldInitializationException
+     * @throws org.apache.beehive.netui.pageflow.ControlFieldInitializationException
      */
     public static void initJavaControls( HttpServletRequest request, HttpServletResponse response,
                                          ServletContext servletContext, PageFlowManagedObject controlClient )
@@ -235,8 +149,8 @@
         //
         Map controlFields = getAccessibleControlFieldAnnotations( controlClientClass, servletContext );
         if ( controlFields.isEmpty() ) {
-            if (_log.isTraceEnabled()) {
-                _log.trace("No control field annotations were found for " + controlClient);
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("No control field annotations were found for " + controlClient);
             }
             PageFlowControlContainer pfcc = PageFlowControlContainerFactory.getControlContainer(request,servletContext);
             pfcc.beginContextOnPageFlow(controlClient,request,response,servletContext);
@@ -252,14 +166,14 @@
 
         try
         {
-            if (_log.isDebugEnabled()) {
-                _log.debug("Initializing control client " + controlClient);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Initializing control client " + controlClient);
             }
             Controls.initializeClient(null, controlClient, beanContext);
         }
         catch ( Exception e )
         {
-            _log.error( "Exception occurred while initializing controls", e);
+            LOG.error( "Exception occurred while initializing controls", e);
             throw new ControlFieldInitializationException( controlClientClass.getName(), controlClient, e );
         }
     }
@@ -287,7 +201,7 @@
             }
             catch ( IllegalAccessException e )
             {
-                _log.error( "Exception while uninitializing Java Control " + controlField.getName(), e );
+                LOG.error( "Exception while uninitializing Java Control " + controlField.getName(), e );
             }
         }
     }

Modified: beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java?rev=372913&r1=372912&r2=372913&view=diff
==============================================================================
--- beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java (original)
+++ beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/tags/databinding/xml/SerializeXML.java Fri Jan 27 09:06:26 2006
@@ -35,7 +35,7 @@
  *            description="A tag that serializes an XMLBean into the output of a JSP page in order to move data to the browser for data binding."
  */
 public class SerializeXML
-        extends AbstractClassicTag {
+    extends AbstractClassicTag {
 
     private static final Logger LOGGER = Logger.getInstance(SerializeXML.class);
     private static final Object[] EMPTY_ARRAY = new Object[0];

Modified: beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/AttributeRenderer.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/AttributeRenderer.java?rev=372913&r1=372912&r2=372913&view=diff
==============================================================================
--- beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/AttributeRenderer.java (original)
+++ beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/AttributeRenderer.java Fri Jan 27 09:06:26 2006
@@ -46,7 +46,6 @@
     /**
      * Add all of the attributes associated with an element to the internal lists.
      * @param elem
-     * @return
      */
     public RemoveInfo addElement(TreeElement elem)
     {