You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by do...@apache.org on 2006/01/23 23:59:43 UTC
svn commit: r371706 - in /beehive/trunk/netui:
src/pageflow/org/apache/beehive/netui/pageflow/
src/pageflow/org/apache/beehive/netui/pageflow/internal/
test/webapps/drt/src/controls/lifecycle/
test/webapps/drt/src/miniTests/createPageFlow/ test/webapps...
Author: dolander
Date: Mon Jan 23 14:59:31 2006
New Revision: 371706
URL: http://svn.apache.org/viewcvs?rev=371706&view=rev
Log:
Implement a new Control Container for the page flow runtime.
This implementation has been described in other e-mail to the dev list.
There are two new classes and an interfaces that represent the control container.
These are called PageFlowControlContainerXXX. The interface defines a simple
interface for createing a ControlContainerContext, and for doing the begin and end context
on the CCC.
I update the ControlLifecycle test to check the lifecycle in the create, an action and a
JSP property.
Added:
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainer.java (with props)
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerFactory.java (with props)
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerImpl.java (with props)
Modified:
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/JavaControlUtils.java
beehive/trunk/netui/test/webapps/drt/src/controls/lifecycle/ControlLifecycleController.java
beehive/trunk/netui/test/webapps/drt/src/miniTests/createPageFlow/CreatePageFlowServlet.java
beehive/trunk/netui/test/webapps/drt/src/org/apache/beehive/netui/test/controls/pflifecycle/PfControlLifecycleImpl.java
beehive/trunk/netui/test/webapps/drt/testRecorder/tests/PageFlowControlLifecycle.xml
beehive/trunk/netui/test/webapps/drt/web/controls/lifecycle/index.jsp
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FacesBackingBean.java Mon Jan 23 14:59:31 2006
@@ -26,6 +26,7 @@
import org.apache.beehive.netui.pageflow.handler.StorageHandler;
import org.apache.beehive.netui.util.internal.cache.ClassLevelCache;
import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -56,6 +57,10 @@
private Map _pageInputs;
+ /**
+ * The bean context associated with this request
+ */
+ ControlContainerContext _beanContext;
/**
* Store this object in the user session, in the appropriate place. Used by the framework; normally should not be
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java Mon Jan 23 14:59:31 2006
@@ -25,11 +25,7 @@
import org.apache.beehive.netui.pageflow.handler.FlowControllerHandlerContext;
import org.apache.beehive.netui.pageflow.handler.Handlers;
import org.apache.beehive.netui.pageflow.handler.LoginHandler;
-import org.apache.beehive.netui.pageflow.internal.AdapterManager;
-import org.apache.beehive.netui.pageflow.internal.InternalConstants;
-import org.apache.beehive.netui.pageflow.internal.InternalExpressionUtils;
-import org.apache.beehive.netui.pageflow.internal.InternalUtils;
-import org.apache.beehive.netui.pageflow.internal.UnhandledException;
+import org.apache.beehive.netui.pageflow.internal.*;
import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
import org.apache.beehive.netui.util.internal.FileUtils;
import org.apache.beehive.netui.util.internal.InternalStringBuilder;
@@ -46,7 +42,6 @@
import org.apache.struts.config.ActionConfig;
import org.apache.struts.config.ControllerConfig;
import org.apache.struts.config.ModuleConfig;
-import org.apache.struts.config.ExceptionConfig;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.TokenProcessor;
@@ -155,7 +150,6 @@
*/
private static int _maxConcurrentRequestCount = -1;
-
/**
* Default constructor.
*/
@@ -334,7 +328,19 @@
{
synchronized ( this )
{
- return internalExecute( mapping, form, request, response );
+ ActionForward ret = null;
+ // establish the control context for running the beginAction, Action, afterAction code
+ PageFlowControlContainer pfcc = PageFlowControlContainerFactory.getControlContainer(request,getServletContext());
+ pfcc.beginContextOnPageFlow(this,request,response, getServletContext());
+
+ try {
+ // execute the beginAction, Action, afterAction code
+ ret = internalExecute( mapping, form, request, response );
+ }
+ finally {
+ pfcc.endContextOnPageFlow(this);
+ }
+ return ret;
}
}
finally
@@ -546,6 +552,7 @@
{
try
{
+ // we start the context on the bean so user control can run against Controls in the onCreate() method
super.create( request, response, servletContext );
}
catch ( Throwable th )
@@ -567,6 +574,9 @@
finally
{
setPerRequestState( prevState );
+
+ PageFlowControlContainer pfcc = PageFlowControlContainerFactory.getControlContainer(request,getServletContext());
+ pfcc.endContextOnPageFlow(this);
}
PageFlowEventReporter er = AdapterManager.getServletContainerAdapter( servletContext ).getEventReporter();
Added: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainer.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainer.java?rev=371706&view=auto
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainer.java (added)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainer.java Mon Jan 23 14:59:31 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 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;
+
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
+public interface PageFlowControlContainer
+{
+ /**
+ * This method will ensure that a page flow's <code>ControlContainerContext</code> exists, and
+ * will make make sure that the begin context is called. Once this is called, you must insure that
+ * the endContext method is called. This is typically called when a page flow instance is being created.
+ * @param pfmo
+ * @param request
+ * @param response
+ * @param servletContext
+ */
+ void createAndBeginControlBeanContext(PageFlowManagedObject pfmo, HttpServletRequest request, HttpServletResponse response,
+ ServletContext servletContext);
+
+ /**
+ * This will return the page flows <code>ControlContainerContext</code>. This call should be made after
+ * either the <code>createAndBeginControlBeanContext</code> or <code>beginContextOnPageFlow</code> has
+ * been called.
+ * @param pfmo
+ * @return Returns the ControlContainerContext for the page flow. This may return null if the page flow
+ * currently doesn't have a ControlContainerContext context.
+ */
+ ControlContainerContext getControlContainerContext(PageFlowManagedObject pfmo
+ );
+
+ /**
+ *
+ * @param pfmo
+ * @param request
+
+ @param response
+
+
+ * @param servletContext
+ */
+ void beginContextOnPageFlow(PageFlowManagedObject pfmo, HttpServletRequest request, HttpServletResponse response,
+ ServletContext servletContext);
+
+
+ /**
+ *
+ * @param flowController
+ */
+ void endContextOnPageFlow(PageFlowManagedObject flowController);
+}
Propchange: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerFactory.java?rev=371706&view=auto
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerFactory.java (added)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerFactory.java Mon Jan 23 14:59:31 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2006 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;
+
+import org.apache.beehive.netui.pageflow.handler.StorageHandler;
+import org.apache.beehive.netui.pageflow.handler.Handlers;
+import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.ServletContext;
+
+public class PageFlowControlContainerFactory
+{
+ private static String PAGEFLOW_CONTROL_CONTAINER = "netui.PageFlolwControlContainerInstance";
+
+ public static synchronized PageFlowControlContainer getControlContainer(HttpServletRequest request, ServletContext servletContext)
+ {
+ PageFlowControlContainer pfcc = (PageFlowControlContainer) getSessionVar(request, servletContext, PAGEFLOW_CONTROL_CONTAINER);
+ if (pfcc != null)
+ return pfcc;
+
+ pfcc = new PageFlowControlContainerImpl();
+ setSessionVar(request,servletContext,PAGEFLOW_CONTROL_CONTAINER,pfcc);
+ return pfcc;
+ }
+
+ /**
+ * This is a generic routine that will retrieve a value from the Session through the
+ * StorageHandler.
+ * @param request
+ * @param servletContext
+ * @param name The name of the value to be retrieved
+ * @return The requested value from the session
+ */
+ private static Object getSessionVar(HttpServletRequest request, ServletContext servletContext, String name)
+ {
+ StorageHandler sh = Handlers.get( servletContext ).getStorageHandler();
+
+ HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
+ RequestContext rc = new RequestContext( unwrappedRequest, null );
+ String attrName = ScopedServletUtils.getScopedSessionAttrName(name, unwrappedRequest);
+ return sh.getAttribute( rc, attrName );
+ }
+
+ /**
+ * This is a generic routine that will store a value into the Session through the StorageHandler.
+ * @param request
+ * @param servletContext
+ * @param name The name of the variable to be stored
+ * @param value The value of the variable to be stored
+ */
+ private static void setSessionVar(HttpServletRequest request, ServletContext servletContext, String name, Object value)
+ {
+ StorageHandler sh = Handlers.get( servletContext ).getStorageHandler();
+
+ HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
+ RequestContext rc = new RequestContext( unwrappedRequest, null );
+ String attrName = ScopedServletUtils.getScopedSessionAttrName(name, unwrappedRequest);
+ sh.setAttribute( rc, attrName, value );
+ }
+}
Propchange: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerImpl.java?rev=371706&view=auto
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerImpl.java (added)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerImpl.java Mon Jan 23 14:59:31 2006
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2006 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;
+
+import org.apache.beehive.controls.runtime.servlet.ServletBeanContext;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+import org.apache.beehive.netui.pageflow.internal.AdapterManager;
+import org.apache.beehive.netui.util.logging.Logger;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * This class provide a set of method that deal with the ControlContainerContext that is scoped to
+ * the FlowController.
+ */
+public class PageFlowControlContainerImpl implements PageFlowControlContainer
+{
+ private static final Logger _log = Logger.getInstance( PageFlowControlContainerImpl.class );
+
+ private ControlContainerContext _sharedContext;
+ private ReentrantLock _sharedLock;
+
+ public ControlContainerContext getControlContainerContext(PageFlowManagedObject pfmo)
+ {
+ // Based upon the type of controller return the bean context
+ // For PageFlowController and FacesBackingBean the control is in the object
+ // For SharedFlowController there is a shared object
+ if (pfmo instanceof SharedFlowController)
+ return _sharedContext;
+ if (pfmo instanceof PageFlowController)
+ return ((PageFlowController) pfmo)._beanContext;
+ if (pfmo instanceof FacesBackingBean)
+ return ((FacesBackingBean) pfmo)._beanContext;
+
+ // This is an unknown type. Assert this, log it and then return null
+ _log.error("Unknown FlowController ControlBeanContenxt:" + pfmo.getClass().getName());
+ assert(false) : "Unknown FlowController ControlBeanContenxt:" + pfmo.getClass().getName();
+ return null;
+ }
+
+ public void beginContextOnPageFlow(PageFlowManagedObject pfmo, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
+ {
+ // get the lock on the shared flow if the shared flow context exists. This is the
+ // reason that you must always call endContextOnPageFlow if you call this method.
+ if (_sharedContext != null) {
+ assert(_sharedLock != null) : "Forgot to create the shared lock";
+ _sharedLock.lock();
+
+ if (_sharedContext instanceof ServletBeanContext) {
+ ((ServletBeanContext) _sharedContext).beginContext(servletContext,request,response);
+ }
+ else {
+ _sharedContext.beginContext();
+ }
+ }
+
+ // if the page flow isn't a shared flow then we must begin context on that also
+ if (pfmo instanceof PageFlowController || pfmo instanceof FacesBackingBean) {
+
+ ControlContainerContext cbc = getControlContainerContext(pfmo);
+ if (cbc != null) {
+ if (cbc instanceof ServletBeanContext) {
+ ((ServletBeanContext) cbc).beginContext(servletContext,request,response);
+ }
+ else {
+ cbc.beginContext();
+ }
+ }
+ }
+ }
+
+ public void createAndBeginControlBeanContext(PageFlowManagedObject pfmo, HttpServletRequest request, HttpServletResponse response,
+ ServletContext servletContext)
+ {
+ if (pfmo instanceof SharedFlowController) {
+ if (_sharedContext == null) {
+ _sharedContext = (ControlContainerContext)
+ AdapterManager.getServletContainerAdapter(servletContext).createControlBeanContext( request, response );
+ _sharedLock = new ReentrantLock();
+ }
+ }
+ else if (pfmo instanceof PageFlowController) {
+ if (((PageFlowController) pfmo)._beanContext == null) {
+ ((PageFlowController) pfmo)._beanContext = (ControlContainerContext)
+ AdapterManager.getServletContainerAdapter(servletContext).createControlBeanContext( request, response );
+ }
+ }
+ else if (pfmo instanceof FacesBackingBean) {
+ if (((FacesBackingBean) pfmo)._beanContext == null) {
+ ((FacesBackingBean) pfmo)._beanContext = (ControlContainerContext)
+ AdapterManager.getServletContainerAdapter(servletContext).createControlBeanContext( request, response );
+ }
+ }
+ else {
+ _log.error("Unknown FlowController ControlBeanContenxt:" + pfmo.getClass().getName());
+ assert(false) : "Unknown FlowController ControlBeanContenxt:" + pfmo.getClass().getName();
+ return;
+ }
+ beginContextOnPageFlow(pfmo,request,response,servletContext);
+ }
+
+ public void endContextOnPageFlow(PageFlowManagedObject flowController)
+ {
+
+ // You must reverse the order of the begin because the low level stuff uses a stack for
+ // this. We also do this with a try/finally so that we make sure to free up the lock.
+ try {
+ if (flowController instanceof PageFlowController || flowController instanceof FacesBackingBean) {
+
+ ControlContainerContext cbc = getControlContainerContext(flowController);
+ if (cbc != null) {
+ cbc.endContext();
+ }
+ }
+ }
+ finally {
+ if (_sharedContext != null) {
+ assert(_sharedLock != null) : "The sharedLock was not allocated";
+ try {
+ _sharedContext.endContext();
+ }
+ finally {
+ _sharedLock.unlock();
+ }
+ }
+ }
+ }
+}
Propchange: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowControlContainerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java Mon Jan 23 14:59:31 2006
@@ -46,6 +46,7 @@
import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
import org.apache.beehive.netui.pageflow.handler.StorageHandler;
import org.apache.beehive.netui.pageflow.handler.Handlers;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
/**
@@ -111,36 +112,40 @@
*/
private PreviousPageInfo _previousPageInfo = null;
private PreviousPageInfo _currentPageInfo = null;
-
+
/**
* A 'return-to="action"' forward reruns the previous action. This object stores the previous
* action URI and its ActionForm.
*/
private PreviousActionInfo _previousActionInfo;
-
+
private boolean _isOnNestingStack = false;
private ViewRenderer _returnActionViewRenderer = null;
-
+
private static final String REMOVING_PAGEFLOW_ATTR = InternalConstants.ATTR_PREFIX + "removingPageFlow";
private static final String SAVED_PREVIOUS_PAGE_INFO_ATTR = InternalConstants.ATTR_PREFIX + "savedPrevPageInfo";
private static final String CACHED_INFO_KEY = "cachedInfo";
private static final Logger _log = Logger.getInstance( PageFlowController.class );
-
-
+
+ /**
+ * The bean context associated with this request
+ */
+ ControlContainerContext _beanContext;
+
/**
* Default constructor.
- */
+ */
protected PageFlowController()
{
}
-
+
/**
* Get the Struts module path for this page flow.
*
* @return a String that is the Struts module path for this controller, and which is also
* the directory path from the web application root to this PageFlowController
* (not including the action filename).
- */
+ */
public String getModulePath()
{
return getCachedInfo().getModulePath();
@@ -156,7 +161,7 @@
{
return getCachedInfo().getURI();
}
-
+
/**
* Tell whether this PageFlowController can be "nested", i.e., if it can be invoked from another page
* flow with the intention of returning to the original one. Page flows are declared to be nested by specifying
@@ -168,8 +173,8 @@
protected boolean isNestable()
{
return InternalUtils.isNestable( getModuleConfig() );
- }
-
+ }
+
/**
* Tell whether this is a "long lived" page flow. Once it is invoked, a long lived page flow is never
* removed from the session unless {@link #remove} is called. Navigating to another page flow hides
@@ -178,16 +183,16 @@
protected boolean isLongLived()
{
return InternalUtils.isLongLived( getModuleConfig() );
- }
-
+ }
+
/**
* Remove this instance from the session. When inside a page flow action, {@link #remove} may be called instead.
- */
+ */
public synchronized void removeFromSession( HttpServletRequest request )
{
// This request attribute is used in persistInSession to prevent re-saving of this instance.
request.setAttribute( REMOVING_PAGEFLOW_ATTR, this );
-
+
if ( isLongLived() )
{
PageFlowUtils.removeLongLivedPageFlow( getModulePath(), request );
@@ -197,25 +202,25 @@
InternalUtils.removeCurrentPageFlow( request, getServletContext() );
}
}
-
+
/**
* Tell whether this is a PageFlowController.
*
* @return <code>true</code>.
- */
+ */
public boolean isPageFlow()
{
return true;
}
-
+
/**
* Store this object in the user session, in the appropriate place. Used by the framework; normally should not be
* called directly.
- */
+ */
public void persistInSession( HttpServletRequest request, HttpServletResponse response )
{
PageFlowController currentPageFlow = PageFlowUtils.getCurrentPageFlow( request, getServletContext() );
-
+
if ( currentPageFlow != null && ! currentPageFlow.isOnNestingStack() )
{
//
@@ -240,7 +245,7 @@
* and does not need to be called explicitly in most cases.
*
* @param request the current HttpServletRequest
- */
+ */
public void ensureFailover( HttpServletRequest request )
{
//
@@ -253,7 +258,7 @@
StorageHandler sh = Handlers.get( getServletContext() ).getStorageHandler();
HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
RequestContext rc = new RequestContext( unwrappedRequest, null );
-
+
//
// If this is a long-lived page flow, there are two attributes to deal with.
//
@@ -270,7 +275,7 @@
{
String attrName = ScopedServletUtils.getScopedSessionAttrName( CURRENT_JPF_ATTR, unwrappedRequest );
sh.ensureFailover( rc, attrName, this );
- }
+ }
}
}
@@ -284,7 +289,7 @@
initializeSharedFlowFields( request );
return super.internalExecute( mapping, form, request, response );
}
-
+
private void initializeSharedFlowFields( HttpServletRequest request )
{
//
@@ -292,14 +297,14 @@
//
CachedSharedFlowRefInfo.SharedFlowFieldInfo[] sharedFlowMemberFields =
getCachedInfo().getSharedFlowMemberFields();
-
+
if ( sharedFlowMemberFields != null )
{
for ( int i = 0; i < sharedFlowMemberFields.length; i++ )
{
CachedSharedFlowRefInfo.SharedFlowFieldInfo fi = sharedFlowMemberFields[i];
Field field = fi.field;
-
+
if ( fieldIsUninitialized( field ) )
{
Map/*< String, SharedFlowController >*/ sharedFlows = PageFlowUtils.getSharedFlows( request );
@@ -308,7 +313,7 @@
name != null ?
( SharedFlowController ) sharedFlows.get( name ) :
PageFlowUtils.getGlobalApp( request );
-
+
if ( sf != null )
{
initializeField( field, sf );
@@ -322,16 +327,16 @@
}
}
}
-
+
/**
* Get the a map of shared flow name to shared flow instance.
* @return a Map of shared flow name (string) to shared flow instance ({@link SharedFlowController}).
- */
+ */
public Map/*< String, SharedFlowController >*/ getSharedFlows()
{
return PageFlowUtils.getSharedFlows( getRequest() );
}
-
+
/**
* Get a shared flow, based on its name as defined in this page flow's
* {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Controller#sharedFlowRefs sharedFlowRefs}
@@ -343,12 +348,12 @@
* attribute on the {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Controller @Jpf.Controller}
* annotation.
* @return the {@link SharedFlowController} with the given name.
- */
+ */
public SharedFlowController getSharedFlow( String sharedFlowName )
{
return ( SharedFlowController ) PageFlowUtils.getSharedFlows( getRequest() ).get( sharedFlowName );
}
-
+
/**
* Remove a shared flow from the session, based on its name as defined in this page flow's
* {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Controller#sharedFlowRefs sharedFlowRefs}
@@ -359,35 +364,35 @@
* {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Controller#sharedFlowRefs sharedFlowRefs}
* attribute on the {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Controller @Jpf.Controller}
* annotation.
- */
+ */
public void removeSharedFlow( String sharedFlowName )
{
SharedFlowController sf = getSharedFlow( sharedFlowName );
if ( sf != null ) sf.removeFromSession( getRequest() );
}
-
+
/**
* This is a framework method for initializing a newly-created page flow, and should not normally be called
* directly.
- */
+ */
public final synchronized void create( HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext )
{
reinitialize( request, response, servletContext );
initializeSharedFlowFields( request );
-
+
if ( isNestable() )
{
// Initialize a ViewRenderer for exiting the nested page flow. This is used (currently) as part of popup
// window support -- when exiting a popup nested page flow, a special view renderer writes out javascript
// that maps output values to the original window and closes the popup window.
String vrClassName = request.getParameter( InternalConstants.RETURN_ACTION_VIEW_RENDERER_PARAM );
-
+
if ( vrClassName != null )
{
ViewRenderer vr =
( ViewRenderer ) DiscoveryUtils.newImplementorInstance( vrClassName, ViewRenderer.class );
-
+
if ( vr != null )
{
vr.init( request );
@@ -396,15 +401,15 @@
}
}
}
-
+
super.create( request, response, servletContext );
}
-
+
/**
* Get the "resource taxonomy": a period-separated list that starts with the current
* web application name, continues through all of this PageFlowController's parent directories,
* and ends with this PageFlowController's class name.
- */
+ */
protected String getTaxonomy()
{
assert getRequest() != null : "this method can only be called during execute()";
@@ -412,7 +417,7 @@
assert contextPath.startsWith( "/" ) : contextPath;
return contextPath.substring( 1 ) + '.' + getClass().getName();
}
-
+
/**
* Get the submitted form bean from the most recent action execution in this PageFlowController.
* <p>
@@ -441,13 +446,13 @@
* @see #getPreviousActionURI
* @see #getPreviousForwardPath
* @see #getCurrentForwardPath
- */
+ */
protected ActionForm getPreviousForm()
{
checkPreviousActionInfoDisabled();
return _previousActionInfo != null ? _previousActionInfo.getForm() : null;
}
-
+
/**
* Get the submitted form bean from the most recent action execution in this PageFlowController.
* <p>
@@ -474,13 +479,13 @@
* @see #getPreviousActionURI
* @see #getPreviousForwardPath
* @see #getCurrentForwardPath
- */
+ */
protected Object getPreviousFormBean()
{
checkPreviousActionInfoDisabled();
return _previousActionInfo != null ? InternalUtils.unwrapFormBean( _previousActionInfo.getForm() ) : null;
}
-
+
/**
* Get the URI for the most recent action in this PageFlowController.
* <p>
@@ -507,13 +512,13 @@
* @see #getPreviousFormBean
* @see #getPreviousForwardPath
* @see #getCurrentForwardPath
- */
+ */
protected String getPreviousActionURI()
{
checkPreviousActionInfoDisabled();
return _previousActionInfo != null ? _previousActionInfo.getActionURI() : null;
}
-
+
/**
* Get the webapp-relative URI for the most recent page (in this page flow) shown to the user.
* <p>
@@ -541,12 +546,12 @@
* @see #getPreviousActionURI
* @see #getPreviousFormBean
* @see #getPreviousForwardPath
- */
+ */
public String getCurrentForwardPath()
{
PreviousPageInfo curPageInfo = getCurrentPageInfo();
String path = null;
-
+
if ( curPageInfo != null )
{
ActionForward curForward = curPageInfo.getForward();
@@ -564,7 +569,7 @@
}
return path;
}
-
+
/**
* Get the webapp-relative URI for the previous page (in this page flow) shown to the user.
* The previous page is the one shown before the most recent page.
@@ -593,26 +598,26 @@
* @see #getPreviousActionURI
* @see #getPreviousFormBean
* @see #getCurrentForwardPath
- */
+ */
protected String getPreviousForwardPath()
{
PreviousPageInfo prevPageInfo = getPreviousPageInfo();
-
+
if ( prevPageInfo != null )
{
ActionForward prevForward = prevPageInfo.getForward();
- return prevForward != null ? prevForward.getPath() : null;
+ return prevForward != null ? prevForward.getPath() : null;
}
else
{
return null;
}
}
-
+
/**
* Get a legacy PreviousPageInfo.
* @deprecated This method will be removed without replacement in the next release.
- */
+ */
public final PreviousPageInfo getPreviousPageInfoLegacy( PageFlowController curJpf, HttpServletRequest request )
{
if (PageFlowRequestWrapper.get(request).isReturningFromNesting())
@@ -624,7 +629,7 @@
return getPreviousPageInfo();
}
}
-
+
/**
* Get information about the most recent page (in this page flow) shown to the user.
* <p>
@@ -652,20 +657,20 @@
* @see #getPreviousFormBean
* @see #getPreviousForwardPath
* @see #getCurrentForwardPath
- */
+ */
public final PreviousPageInfo getCurrentPageInfo()
{
checkPreviousPageInfoDisabled();
-
+
if ( _currentPageInfo != null )
- {
+ {
// Allows it to reconstruct transient members after session failover
_currentPageInfo.reinitialize( this );
}
-
+
return _currentPageInfo;
}
-
+
/**
* Get information about the previous page (in this page flow) shown to the user. The previous
* page is the one shown before the most recent page.
@@ -687,21 +692,21 @@
* @see #getPreviousFormBean
* @see #getPreviousForwardPath
* @see #getCurrentForwardPath
- */
+ */
public final PreviousPageInfo getPreviousPageInfo()
{
checkPreviousPageInfoDisabled();
-
+
PreviousPageInfo ret = _previousPageInfo != null ? _previousPageInfo : _currentPageInfo;
-
+
if ( ret != null )
{
ret.reinitialize( this ); // Allows it to reconstruct transient members after session failover
}
-
+
return ret;
}
-
+
/**
* Get information about the most recent action run in this page flow.
* <p>
@@ -728,13 +733,13 @@
* @see #getPreviousFormBean
* @see #getPreviousForwardPath
* @see #getCurrentForwardPath
- */
+ */
public final PreviousActionInfo getPreviousActionInfo()
{
checkPreviousActionInfoDisabled();
return _previousActionInfo;
}
-
+
private void checkPreviousActionInfoDisabled()
{
if ( isPreviousActionInfoDisabled() )
@@ -742,7 +747,7 @@
throw new IllegalStateException( "Previous action information has been disabled in this page flow. Override alwaysTrackPreviousAction() to enable it." );
}
}
-
+
private void checkPreviousPageInfoDisabled()
{
if ( isPreviousPageInfoDisabled() )
@@ -750,37 +755,37 @@
throw new IllegalStateException( "Previous page information has been disabled in this page flow. Override alwaysTrackPreviousPage() to enable it." );
}
}
-
+
/**
* Get the display name of this page flow.
* @return the display name (the URI) of this page flow.
- */
+ */
public String getDisplayName()
{
return getURI();
}
-
+
public boolean isPreviousActionInfoDisabled()
{
if ( alwaysTrackPreviousAction() ) return false;
-
+
ModuleConfig mc = getModuleConfig();
- ControllerConfig cc = mc.getControllerConfig();
+ ControllerConfig cc = mc.getControllerConfig();
return cc instanceof PageFlowControllerConfig && ( ( PageFlowControllerConfig ) cc ).isReturnToActionDisabled();
}
-
+
public boolean isPreviousPageInfoDisabled()
{
if ( alwaysTrackPreviousPage() ) return false;
-
+
ModuleConfig mc = getModuleConfig();
- ControllerConfig cc = mc.getControllerConfig();
+ ControllerConfig cc = mc.getControllerConfig();
return cc instanceof PageFlowControllerConfig && ( ( PageFlowControllerConfig ) cc ).isReturnToPageDisabled();
}
-
+
/**
* Called from {@link FlowController#execute}.
- */
+ */
void savePreviousActionInfo( ActionForm form, HttpServletRequest request, ActionMapping mapping,
ServletContext servletContext )
{
@@ -791,11 +796,11 @@
String actionURI = InternalUtils.getDecodedServletPath( request );
_previousActionInfo = new PreviousActionInfo( form, actionURI, request.getQueryString() );
}
-
+
/**
* Store information about recent pages displayed. This is a framework-invoked method that should not normally be
* called directly.
- */
+ */
public void savePreviousPageInfo( ActionForward forward, ActionForm form, ActionMapping mapping,
HttpServletRequest request, ServletContext servletContext,
boolean isSpecialForward )
@@ -807,11 +812,11 @@
// this request (for example, forward to foo.faces which forwards to foo.jsp), just return.
//
if ( request.getAttribute( SAVED_PREVIOUS_PAGE_INFO_ATTR ) != null || isPreviousPageInfoDisabled() ) return;
-
+
String path = forward.getPath();
int queryPos = path.indexOf( '?' );
if ( queryPos != -1 ) path = path.substring( 0, queryPos );
-
+
//
// If a form bean was generated in this request, add it to the most recent PreviousPageInfo, so when we
// go back to that page, the *updated* field values are restored (i.e., we don't revert to the values of
@@ -826,11 +831,11 @@
_currentPageInfo.setMapping( mapping );
}
}
-
+
//
// Only keep track of *pages* forwarded to -- not actions or pageflows.
//
- if ( ! FileUtils.osSensitiveEndsWith( path, ACTION_EXTENSION ) )
+ if ( ! FileUtils.osSensitiveEndsWith( path, ACTION_EXTENSION ) )
{
//
// Only save previous-page info if the page is within this pageflow.
@@ -844,11 +849,11 @@
}
}
}
-
+
private boolean isLocalFile( ActionForward forward )
{
String path = forward.getPath();
-
+
if ( ! forward.getContextRelative() )
{
return path.indexOf( '/', 1 ) == -1; // all paths in Struts start with '/'
@@ -856,7 +861,7 @@
else
{
String modulePath = getModulePath();
-
+
if ( ! path.startsWith( modulePath ) )
{
return false;
@@ -867,16 +872,16 @@
}
}
}
-
+
private boolean isOnNestingStack()
{
return _isOnNestingStack;
}
-
+
/**
* Callback when this object is removed from the user session. Causes {@link #onDestroy} to be called. This is a
* framework-invoked method that should not normally be called indirectly.
- */
+ */
public void valueUnbound( HttpSessionBindingEvent event )
{
//
@@ -887,19 +892,19 @@
super.valueUnbound( event );
}
}
-
+
void setIsOnNestingStack( boolean isOnNestingStack )
{
_isOnNestingStack = isOnNestingStack;
}
-
+
ActionForward forwardTo( ActionForward fwd, ActionMapping mapping, PageFlowExceptionConfig exceptionConfig,
String actionName, ModuleConfig altModuleConfig, ActionForm form,
HttpServletRequest request, HttpServletResponse response, ServletContext servletContext )
{
ActionForward superFwd = super.forwardTo( fwd, mapping, exceptionConfig, actionName, altModuleConfig, form,
request, response, servletContext );
-
+
//
// Special case: the *only* way for a nested pageflow to nest itself is for it
// to forward to itself as a .jpf. Simply executing an action in the .jpf isn't
@@ -909,7 +914,7 @@
if ( superFwd != null && InternalUtils.isNestable( getModuleConfig() ) )
{
boolean selfNesting = false;
-
+
if ( superFwd.getContextRelative() )
{
if ( superFwd.getPath().equals( getURI() ) )
@@ -924,14 +929,14 @@
selfNesting = true;
}
}
-
+
if ( selfNesting )
{
if ( _log.isDebugEnabled() )
{
_log.debug( "Self-nesting page flow " + getURI() );
}
-
+
try
{
// This will cause the right pageflow stack stuff to happen.
@@ -950,10 +955,10 @@
}
}
}
-
+
return superFwd;
}
-
+
private String getStrutsLocalURI()
{
String className = getClass().getName();
@@ -961,18 +966,18 @@
InternalStringBuilder ret = new InternalStringBuilder( "/" );
return ret.append( className.substring( lastDot + 1 ) ).append( PAGEFLOW_EXTENSION ).toString();
}
-
+
private CachedPageFlowInfo getCachedInfo()
{
ClassLevelCache cache = ClassLevelCache.getCache( getClass() );
CachedPageFlowInfo info = ( CachedPageFlowInfo ) cache.getCacheObject( CACHED_INFO_KEY );
-
+
if ( info == null )
{
info = new CachedPageFlowInfo( getClass(), getServletContext() );
cache.setCacheObject( CACHED_INFO_KEY, info );
}
-
+
return info;
}
@@ -986,7 +991,7 @@
{
HttpServletRequest request = getRequest();
String relativeUri = InternalUtils.getDecodedServletPath( request );
-
+
String path = getCurrentForwardPath();
if ( path == null || ! path.equals( relativeUri ) )
{
@@ -997,10 +1002,10 @@
}
}
}
-
+
/**
* @exclude
- */
+ */
public ActionForward exitNesting( HttpServletRequest request, HttpServletResponse response, ActionMapping mapping,
ActionForm form )
{
@@ -1008,15 +1013,15 @@
// use it later to render the view.
PageFlowController nestingPageFlow = PageFlowUtils.getNestingPageFlow(request, getServletContext());
ViewRenderer returnActionViewRenderer = nestingPageFlow.getReturnActionViewRenderer();
-
+
if ( returnActionViewRenderer != null )
{
PageFlowRequestWrapper.get( request ).setViewRenderer( returnActionViewRenderer );
nestingPageFlow.setReturnActionViewRenderer(null); // we don't need it anymore
}
-
+
PerRequestState prevState = setPerRequestState( new PerRequestState( request, response, mapping ) );
-
+
try
{
onExitNesting();
@@ -1036,15 +1041,15 @@
{
setPerRequestState( prevState );
}
-
+
return null;
}
-
+
/**
* Callback that is invoked when this controller instance is exiting nesting (through a return action).
* {@link FlowController#getRequest}, {@link FlowController#getResponse}, {@link FlowController#getSession}
* may all be used during this method.
- */
+ */
protected void onExitNesting()
throws Exception
{
@@ -1056,5 +1061,12 @@
private void setReturnActionViewRenderer(ViewRenderer returnActionViewRenderer) {
_returnActionViewRenderer = returnActionViewRenderer;
+ }
+
+ protected void ensureControlContainerContextExists()
+ {
+ if (_beanContext != null)
+ return;
+ //PageFlowControlContainerImpl.createAndBeginControlBeanContext(this,getRequest(),getResponse(),getServletContext());
}
}
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowPageFilter.java Mon Jan 23 14:59:31 2006
@@ -143,11 +143,6 @@
long startTime = System.currentTimeMillis();
//
- // Initialize the ControlBeanContext in the session.
- //
- JavaControlUtils.initializeControlContext( httpRequest, httpResponse, _servletContext );
-
- //
// Create the PageFlow Context
//
PageFlowContext pfCtxt = PageFlowContext.getContext();
@@ -157,6 +152,11 @@
pfCtxt.setServletContext(_servletContext);
//
+ // Initialize the ControlBeanContext in the session.
+ //TODO: initializeControlContext
+ //JavaControlUtils.initializeControlContext( httpRequest, httpResponse, _servletContext );
+
+ //
// Register the default URLRewriter
//
URLRewriterService.registerURLRewriter( 0, request, new DefaultURLRewriter() );
@@ -230,8 +230,8 @@
{
//
// Clean up the ControlBeanContext in the session.
- //
- JavaControlUtils.uninitializeControlContext( httpRequest, httpResponse, _servletContext );
+ // TODO: uninitializeControlContext
+ //JavaControlUtils.uninitializeControlContext( httpRequest, httpResponse, _servletContext );
//
// Callback to the server adapter.
@@ -283,6 +283,11 @@
//
synchronized ( curJpf )
{
+ // establish the control context for rendering the JSP
+ PageFlowControlContainer pfcc = PageFlowControlContainerFactory.getControlContainer(request,_servletContext);
+ pfcc.beginContextOnPageFlow(curJpf,request,response,_servletContext);
+
+
FlowController.PerRequestState newState =
new FlowController.PerRequestState( request, response, null );
FlowController.PerRequestState prevState = curJpf.setPerRequestState( newState );
@@ -326,6 +331,8 @@
finally
{
curJpf.setPerRequestState( prevState );
+
+ pfcc.endContextOnPageFlow(curJpf);
}
}
}
Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java Mon Jan 23 14:59:31 2006
@@ -811,9 +811,18 @@
long startTime = System.currentTimeMillis();
//
- // Initialize the ControlBeanContext in the session.
+ // Create the PageFlow Context
//
- JavaControlUtils.initializeControlContext( request, response, servletContext );
+ PageFlowContext pfCtxt = PageFlowContext.getContext();
+ pfCtxt.init();
+ pfCtxt.setRequest(request);
+ pfCtxt.setResponse(response);
+ pfCtxt.setServletContext(servletContext);
+
+ //
+ // Initialize the ControlBeanContext in the session.
+ //TODO: initializeControlContext
+ //JavaControlUtils.initializeControlContext( request, response, servletContext );
//
// Register the default URLRewriter
@@ -840,8 +849,8 @@
//
// Clean up the ControlBeanContext in the session.
- //
- JavaControlUtils.uninitializeControlContext( request, response, getServletContext() );
+ // TODO: uninitializeControlContext
+ //JavaControlUtils.uninitializeControlContext( request, response, getServletContext() );
//
// Callback to the server adapter.
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=371706&r1=371705&r2=371706&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 Mon Jan 23 14:59:31 2006
@@ -17,7 +17,6 @@
*/
package org.apache.beehive.netui.pageflow.internal;
-import org.apache.beehive.controls.runtime.servlet.ServletBeanContext;
import org.apache.beehive.controls.api.bean.Controls;
import org.apache.beehive.controls.api.bean.ControlBean;
import org.apache.beehive.controls.api.bean.Control;
@@ -26,7 +25,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import javax.servlet.ServletContext;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -39,24 +37,25 @@
import java.beans.beancontext.BeanContext;
import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.pageflow.ControlFieldInitializationException;
-import org.apache.beehive.netui.pageflow.PageFlowUtils;
-import org.apache.beehive.netui.pageflow.PageFlowManagedObject;
+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 String CONTROL_CONTEXT_CLASSNAME = ServletBeanContext.class.getName();
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 )
{
@@ -67,22 +66,26 @@
//
if ( beanContext instanceof ServletBeanContext )
{
- ( ( ServletBeanContext ) beanContext ).beginContext( servletContext, request, response );
+ ( ( 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 )
{
@@ -97,12 +100,12 @@
}
return beanContext;
}
-
+
HttpSession session = request.getSession( false );
if ( session != null )
{
beanContext = ( ControlBeanContext ) session.getAttribute( CONTROL_CONTEXT_CLASSNAME );
-
+
if ( beanContext != null )
{
if (_log.isTraceEnabled()) {
@@ -112,7 +115,7 @@
return beanContext;
}
}
-
+
//
// If no context exists, then create a new one and store it in the session.
//
@@ -126,10 +129,11 @@
_log.debug("Created ControlBeanContext " + beanContext);
}
}
-
+
return beanContext;
}
-
+ */
+
public static void destroyControl( Object controlInstance )
{
assert controlInstance instanceof ControlBean : controlInstance.getClass().getName();
@@ -138,53 +142,53 @@
if (_log.isTraceEnabled()) {
_log.trace("Removing control " + controlInstance + " from ControlBeanContext " + beanContext);
}
- beanContext.remove( controlInstance );
+ beanContext.remove( controlInstance );
}
}
-
-
+
+
/**
* @return a map of Field (accessible) -> AnnotationMap
- */
+ */
private static Map getAccessibleControlFieldAnnotations( Class controlContainerClass, ServletContext servletContext )
{
String className = controlContainerClass.getName();
-
+
//
// Reading the annotations is expensive. See if there's a cached copy of the map.
//
Map/*< Field, PropertyMap >*/ cached = ( Map ) _controlFieldCache.get( className );
-
+
if ( cached != null )
{
return cached;
}
-
+
HashMap/*< Field, PropertyMap >*/ ret = new HashMap/*< Field, PropertyMap >*/();
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 );
-
+
//
// 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();
-
+
for ( int i = 0; i < fields.length; i++ )
{
Field field = fields[i];
String fieldName = field.getName();
int modifiers = field.getModifiers();
-
+
if ( ! fieldNames.contains( fieldName ) && ! Modifier.isStatic( modifiers )
&& annReader.getAnnotation( field.getName(), CONTROL_ANNOTATION_CLASSNAME ) != null )
{
@@ -200,24 +204,18 @@
}
}
}
-
+
accessPrivateFields = false;
controlContainerClass = controlContainerClass.getSuperclass();
} while ( controlContainerClass != null );
-
+
_controlFieldCache.put( className, ret );
return ret;
- }
-
+ }
+
/**
* Initialize all null member variables that are Java Controls.
*
- * <p>
- * This method assumes that the {@link ControlBeanContext}
- * (a {@link org.apache.beehive.controls.api.context.ControlContainerContext})
- * was already intialized correctly using {@link #initializeControlContext}.
- * </p>
- *
* @param request the current HttpServletRequest
* @param response the current HttpServletRequest
* @param servletContext the ServletContext
@@ -229,7 +227,7 @@
throws ControlFieldInitializationException
{
Class controlClientClass = controlClient.getClass();
-
+
//
// First, just return if there are no annotated Control fields. This saves us from having to catch a
// (wrapped) ClassNotFoundException for the control client initializer if we were to simply call
@@ -240,12 +238,18 @@
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);
return;
}
request = PageFlowUtils.unwrapMultipart( request );
- ControlBeanContext beanContext = getControlBeanContext( request, response, servletContext, false );
+
+ PageFlowControlContainer pfcc = PageFlowControlContainerFactory.getControlContainer(request,servletContext);
+ pfcc.createAndBeginControlBeanContext(controlClient,request,response,servletContext);
+ ControlBeanContext beanContext = pfcc.getControlContainerContext(controlClient);
assert beanContext != null : "ControlBeanContext was not initialized by PageFlowRequestProcessor";
+
try
{
if (_log.isDebugEnabled()) {
@@ -259,14 +263,14 @@
throw new ControlFieldInitializationException( controlClientClass.getName(), controlClient, e );
}
}
-
+
/**
* Clean up all member variables that are Java Controls.
- */
+ */
public static void uninitJavaControls( ServletContext servletContext, PageFlowManagedObject controlClient )
{
Map controlFields = getAccessibleControlFieldAnnotations( controlClient.getClass(), servletContext );
-
+
for ( Iterator i = controlFields.keySet().iterator(); i.hasNext(); )
{
Field controlField = ( Field ) i.next();
@@ -274,7 +278,7 @@
try
{
Object fieldValue = controlField.get( controlClient );
-
+
if ( fieldValue != null )
{
controlField.set( controlClient, null );
@@ -284,7 +288,7 @@
catch ( IllegalAccessException e )
{
_log.error( "Exception while uninitializing Java Control " + controlField.getName(), e );
- }
+ }
}
}
}
Modified: beehive/trunk/netui/test/webapps/drt/src/controls/lifecycle/ControlLifecycleController.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/drt/src/controls/lifecycle/ControlLifecycleController.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/test/webapps/drt/src/controls/lifecycle/ControlLifecycleController.java (original)
+++ beehive/trunk/netui/test/webapps/drt/src/controls/lifecycle/ControlLifecycleController.java Mon Jan 23 14:59:31 2006
@@ -35,15 +35,25 @@
@Control
private PfControlLifecycle _control;
- private String _message;
+ private String _onCreateMsg;
+ private String _beginMsg;
+
+ public String getPropertyMsg()
+ {
+ //System.err.println("Inside the property Accessor");
+ return _control.echo("get property -- controls.lifecycle.ControlLifecycleController");
+ }
public void onCreate() {
+ //System.err.println("Inside the Controller onCreate");
+ _onCreateMsg = _control.echo("onCreate -- controls.lifecycle.ControlLifecycleController");
}
@Jpf.Action()
public Forward begin() {
- _message = _control.echo("Hello World! -- controls.lifecycle.ControlLifecycleController");
- getRequest().setAttribute("echoMessage", _message);
+ _beginMsg = _control.echo("begin.do -- controls.lifecycle.ControlLifecycleController");
+ getRequest().setAttribute("createMsg", _onCreateMsg);
+ getRequest().setAttribute("beginMsg", _beginMsg);
return new Forward("index");
}
}
Modified: beehive/trunk/netui/test/webapps/drt/src/miniTests/createPageFlow/CreatePageFlowServlet.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/drt/src/miniTests/createPageFlow/CreatePageFlowServlet.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/test/webapps/drt/src/miniTests/createPageFlow/CreatePageFlowServlet.java (original)
+++ beehive/trunk/netui/test/webapps/drt/src/miniTests/createPageFlow/CreatePageFlowServlet.java Mon Jan 23 14:59:31 2006
@@ -77,7 +77,7 @@
if (doInitialization) {
// Initialize the ControlBeanContext in the session.
- JavaControlUtils.initializeControlContext( request, response, servletContext );
+ //JavaControlUtils.initializeControlContext( request, response, servletContext );
}
RequestContext requestContext = new RequestContext(scopedRequest, scopedResponse);
@@ -116,7 +116,7 @@
{
if (doInitialization) {
// Clean up the ControlBeanContext in the session.
- JavaControlUtils.uninitializeControlContext( request, response, servletContext );
+ //JavaControlUtils.uninitializeControlContext( request, response, servletContext );
}
}
Modified: beehive/trunk/netui/test/webapps/drt/src/org/apache/beehive/netui/test/controls/pflifecycle/PfControlLifecycleImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/drt/src/org/apache/beehive/netui/test/controls/pflifecycle/PfControlLifecycleImpl.java?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/test/webapps/drt/src/org/apache/beehive/netui/test/controls/pflifecycle/PfControlLifecycleImpl.java (original)
+++ beehive/trunk/netui/test/webapps/drt/src/org/apache/beehive/netui/test/controls/pflifecycle/PfControlLifecycleImpl.java Mon Jan 23 14:59:31 2006
@@ -45,17 +45,20 @@
private ResourceContext _resourceContext;
public String echo(String value) {
+ //System.err.println("Echo:" + value);
return "Echo: '" + value + "'";
}
@EventHandler(field = "_context", eventSet = ControlBeanContext.LifeCycle.class, eventName = "onCreate")
public void onCreate() {
+ //System.err.println("PfControlLifecycleImpl Created");
LOG.info("bean context event -- onCreate");
checkContainerContext();
}
@EventHandler(field = "_resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onAcquire")
public void onAquire() {
+ //System.err.println("OnAcquire");
LOG.info("bean context event -- onAcquire");
checkContainerContext();
@@ -67,6 +70,7 @@
@EventHandler(field = "_resourceContext", eventSet = ResourceContext.ResourceEvents.class, eventName = "onRelease")
public void onRelease() {
+ //System.err.println("OnRelease");
LOG.info("bean context event -- onRelease");
checkContainerContext();
_onReleaseCalled = true;
Modified: beehive/trunk/netui/test/webapps/drt/testRecorder/tests/PageFlowControlLifecycle.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/PageFlowControlLifecycle.xml?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/test/webapps/drt/testRecorder/tests/PageFlowControlLifecycle.xml (original)
+++ beehive/trunk/netui/test/webapps/drt/testRecorder/tests/PageFlowControlLifecycle.xml Mon Jan 23 14:59:31 2006
@@ -2,8 +2,8 @@
<recorderSession xmlns="http://beehive.apache.org/netui/tools/testrecorder/2004/session">
<sessionName>PageFlowControlLifecycle</sessionName>
<tester>ekoneil</tester>
-<startDate>14 Nov 2005, 03:43:41.140 PM MST</startDate>
-<description>Test that verifies that the control lifecycle works correctly when integrated with Page Flows.</description>
+<startDate>17 Jan 2006, 10:44:26.213 AM MST</startDate>
+<description>ekoneil</description>
<tests>
<test>
<testNumber>1</testNumber>
@@ -19,15 +19,15 @@
<cookies>
<cookie>
<name>JSESSIONID</name>
-<value>0D32DD4FAE1320C24692916310C4C602</value>
-</cookie>
-<cookie>
-<name>nde-textsize</name>
-<value>16px</value>
+<value>551FF8A9199B35CC550A149ADCFF4CCF</value>
</cookie>
</cookies>
<headers>
<header>
+<name>---------------</name>
+<value>------------</value>
+</header>
+<header>
<name>accept</name>
<value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</value>
</header>
@@ -36,10 +36,6 @@
<value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</value>
</header>
<header>
-<name>accept-encoding</name>
-<value>gzip,deflate</value>
-</header>
-<header>
<name>accept-language</name>
<value>en-us,en;q=0.5</value>
</header>
@@ -49,7 +45,7 @@
</header>
<header>
<name>cookie</name>
-<value>JSESSIONID=0D32DD4FAE1320C24692916310C4C602; nde-textsize=16px</value>
+<value>$Version=0; JSESSIONID=551FF8A9199B35CC550A149ADCFF4CCF; $Path=/coreWeb</value>
</header>
<header>
<name>host</name>
@@ -60,6 +56,10 @@
<value>300</value>
</header>
<header>
+<name>testrecorder.playback.testid</name>
+<value>-32a8799b:108d968db46:-795c</value>
+</header>
+<header>
<name>user-agent</name>
<value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051107 Firefox/1.5</value>
</header>
@@ -74,16 +74,26 @@
<html lang="en">
<head>
- <title></title>
+ <title>Control Lifecycle Test</title>
</head>
<body>
- Echo message 'Echo: 'Hello World! -- controls.lifecycle.ControlLifecycleController''
+ <p style="color:green">This test will call a method on a control in the three blocks
+ that can run control code in a page flow, the onCreate, the Action and during JSP rendering.
+ The table below contains an echo'd message from a control. Each line represents calling the control
+ at various stages of the page flow life cycle for rendering a page.
+ </p>
+ <table>
+ <tr><td>onCreate message</td><td>'Echo: 'onCreate -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ <tr><td>begin message</td><td>'Echo: 'begin.do -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ <tr><td>property access message</td><td>'Echo: 'get property -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ </table>
</body>
</html>]]>
</responseBody>
</response>
-</test>
+<testResults><testStatus>fail</testStatus>
+</testResults></test>
<test>
<testNumber>2</testNumber>
<request>
@@ -98,15 +108,15 @@
<cookies>
<cookie>
<name>JSESSIONID</name>
-<value>0D32DD4FAE1320C24692916310C4C602</value>
-</cookie>
-<cookie>
-<name>nde-textsize</name>
-<value>16px</value>
+<value>551FF8A9199B35CC550A149ADCFF4CCF</value>
</cookie>
</cookies>
<headers>
<header>
+<name>---------------</name>
+<value>------------</value>
+</header>
+<header>
<name>accept</name>
<value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</value>
</header>
@@ -115,10 +125,6 @@
<value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</value>
</header>
<header>
-<name>accept-encoding</name>
-<value>gzip,deflate</value>
-</header>
-<header>
<name>accept-language</name>
<value>en-us,en;q=0.5</value>
</header>
@@ -132,7 +138,7 @@
</header>
<header>
<name>cookie</name>
-<value>JSESSIONID=0D32DD4FAE1320C24692916310C4C602; nde-textsize=16px</value>
+<value>$Version=0; JSESSIONID=551FF8A9199B35CC550A149ADCFF4CCF; $Path=/coreWeb</value>
</header>
<header>
<name>host</name>
@@ -143,6 +149,10 @@
<value>300</value>
</header>
<header>
+<name>testrecorder.playback.testid</name>
+<value>-32a8799b:108d968db46:-795c</value>
+</header>
+<header>
<name>user-agent</name>
<value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051107 Firefox/1.5</value>
</header>
@@ -157,16 +167,26 @@
<html lang="en">
<head>
- <title></title>
+ <title>Control Lifecycle Test</title>
</head>
<body>
- Echo message 'Echo: 'Hello World! -- controls.lifecycle.ControlLifecycleController''
+ <p style="color:green">This test will call a method on a control in the three blocks
+ that can run control code in a page flow, the onCreate, the Action and during JSP rendering.
+ The table below contains an echo'd message from a control. Each line represents calling the control
+ at various stages of the page flow life cycle for rendering a page.
+ </p>
+ <table>
+ <tr><td>onCreate message</td><td>'Echo: 'onCreate -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ <tr><td>begin message</td><td>'Echo: 'begin.do -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ <tr><td>property access message</td><td>'Echo: 'get property -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ </table>
</body>
</html>]]>
</responseBody>
</response>
-</test>
+<testResults><testStatus>fail</testStatus>
+</testResults></test>
<test>
<testNumber>3</testNumber>
<request>
@@ -181,15 +201,15 @@
<cookies>
<cookie>
<name>JSESSIONID</name>
-<value>0D32DD4FAE1320C24692916310C4C602</value>
-</cookie>
-<cookie>
-<name>nde-textsize</name>
-<value>16px</value>
+<value>551FF8A9199B35CC550A149ADCFF4CCF</value>
</cookie>
</cookies>
<headers>
<header>
+<name>---------------</name>
+<value>------------</value>
+</header>
+<header>
<name>accept</name>
<value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</value>
</header>
@@ -198,10 +218,6 @@
<value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</value>
</header>
<header>
-<name>accept-encoding</name>
-<value>gzip,deflate</value>
-</header>
-<header>
<name>accept-language</name>
<value>en-us,en;q=0.5</value>
</header>
@@ -215,7 +231,7 @@
</header>
<header>
<name>cookie</name>
-<value>JSESSIONID=0D32DD4FAE1320C24692916310C4C602; nde-textsize=16px</value>
+<value>$Version=0; JSESSIONID=551FF8A9199B35CC550A149ADCFF4CCF; $Path=/coreWeb</value>
</header>
<header>
<name>host</name>
@@ -226,6 +242,10 @@
<value>300</value>
</header>
<header>
+<name>testrecorder.playback.testid</name>
+<value>-32a8799b:108d968db46:-795c</value>
+</header>
+<header>
<name>user-agent</name>
<value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051107 Firefox/1.5</value>
</header>
@@ -240,17 +260,30 @@
<html lang="en">
<head>
- <title></title>
+ <title>Control Lifecycle Test</title>
</head>
<body>
- Echo message 'Echo: 'Hello World! -- controls.lifecycle.ControlLifecycleController''
+ <p style="color:green">This test will call a method on a control in the three blocks
+ that can run control code in a page flow, the onCreate, the Action and during JSP rendering.
+ The table below contains an echo'd message from a control. Each line represents calling the control
+ at various stages of the page flow life cycle for rendering a page.
+ </p>
+ <table>
+ <tr><td>onCreate message</td><td>'Echo: 'onCreate -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ <tr><td>begin message</td><td>'Echo: 'begin.do -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ <tr><td>property access message</td><td>'Echo: 'get property -- controls.lifecycle.ControlLifecycleController''</td></tr>
+ </table>
</body>
</html>]]>
</responseBody>
</response>
-</test>
+<testResults><testStatus>fail</testStatus>
+</testResults></test>
</tests>
-<endDate>14 Nov 2005, 03:43:51.921 PM MST</endDate>
+<endDate>17 Jan 2006, 10:44:27.825 AM MST</endDate>
+<sessionStatus>fail</sessionStatus>
<testCount>3</testCount>
+<passedCount>0</passedCount>
+<failedCount>3</failedCount>
</recorderSession>
Modified: beehive/trunk/netui/test/webapps/drt/web/controls/lifecycle/index.jsp
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/test/webapps/drt/web/controls/lifecycle/index.jsp?rev=371706&r1=371705&r2=371706&view=diff
==============================================================================
--- beehive/trunk/netui/test/webapps/drt/web/controls/lifecycle/index.jsp (original)
+++ beehive/trunk/netui/test/webapps/drt/web/controls/lifecycle/index.jsp Mon Jan 23 14:59:31 2006
@@ -1,13 +1,19 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
-<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<netui:html>
<head>
- <title></title>
+ <title>Control Lifecycle Test</title>
</head>
<netui:body>
- Echo message '${requestScope.echoMessage}'
+ <p style="color:green">This test will call a method on a control in the three blocks
+ that can run control code in a page flow, the onCreate, the Action and during JSP rendering.
+ The table below contains an echo'd message from a control. Each line represents calling the control
+ at various stages of the page flow life cycle for rendering a page.
+ </p>
+ <table>
+ <tr><td>onCreate message</td><td>'${requestScope.createMsg}'</td></tr>
+ <tr><td>begin message</td><td>'${requestScope.beginMsg}'</td></tr>
+ <tr><td>property access message</td><td>'${pageFlow.propertyMsg}'</td></tr>
+ </table>
</netui:body>
</netui:html>