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/02/16 17:45:39 UTC
svn commit: r378296 -
/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
Author: ekoneil
Date: Thu Feb 16 08:45:35 2006
New Revision: 378296
URL: http://svn.apache.org/viewcvs?rev=378296&view=rev
Log:
Fix for BEEHIVE-1068. This change alters the behavior of the method that looks up a "global/Global.class" object for back-compat. If the check fails once, a ServletContext attribute is set in FlowControllerFactory that prevents the lookup from running again. This short-circuits the logic that throws a ClassNotFoundException twice on a simple JPF -> JSP request.
The distribution tests and BVTs both passed with this change.
BB: self
Tests: see above
Modified:
beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.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=378296&r1=378295&r2=378296&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 Thu Feb 16 08:45:35 2006
@@ -46,22 +46,14 @@
* <p>
* Factory for creating {@link FlowController}s - user {@link PageFlowController}s and {@link SharedFlowController}s.
* </p>
- * <p>
- * When we create a FlowController object, if the object has any <code>@Control</code> annotations, the
- * <code>ControlContainerContext</code> will be created. See {@link org.apache.beehive.controls.api.context.ControlContainerContext}
- * for more information. If there are no annotations, the <code>ControlContainerContext</code> may not
- * be created. If the FlowController is going to instantiate controls programmatically, you need to make
- * sure that the <code>ControlContainerContext</code> is created. See the
- * {@link org.apache.beehive.netui.pageflow.PageFlowControlContainerFactory} and
- * {@link org.apache.beehive.netui.pageflow.PageFlowControlContainer} for more information.
- * </p>
*/
public class FlowControllerFactory
- extends Factory
+ extends Factory
{
- private static final Logger _log = Logger.getInstance( FlowControllerFactory.class );
+ private static final Logger LOG = Logger.getInstance( FlowControllerFactory.class );
private static final String CONTEXT_ATTR = InternalConstants.ATTR_PREFIX + "fcFactory";
+ private static final String NO_GLOBAL_APP_KEY = "__beehive_netui_noglobalapp";
private transient ReloadableClassHandler _rch;
@@ -69,10 +61,6 @@
{
}
- protected void onCreate()
- {
- }
-
/**
* Initialize an instance of this class in the ServletContext. This is a framework-invoked
* method and should not normally be called directly.
@@ -170,7 +158,7 @@
}
catch ( ClassNotFoundException e )
{
- if ( _log.isInfoEnabled() ) _log.info( "No page flow exists for path " + path );
+ if ( LOG.isInfoEnabled() ) LOG.info( "No page flow exists for path " + path );
return null;
}
}
@@ -228,7 +216,7 @@
if ( mc == null )
{
- _log.error( "Struts module " + modulePath + " not found for " + pageFlowClass.getName()
+ LOG.error( "Struts module " + modulePath + " not found for " + pageFlowClass.getName()
+ "; cannot create page flow.");
return null;
}
@@ -237,11 +225,11 @@
{
retVal = PageFlowUtils.getLongLivedPageFlow( modulePath, request );
- if ( _log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
if ( retVal != null )
{
- _log.debug( "Using long lived PageFlowController of type " + pageFlowClass.getName() );
+ LOG.debug( "Using long lived PageFlowController of type " + pageFlowClass.getName() );
}
}
}
@@ -285,9 +273,9 @@
//
if ( retVal == null )
{
- if ( _log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- _log.debug( "Creating PageFlowController of type " + pageFlowClass.getName() );
+ LOG.debug( "Creating PageFlowController of type " + pageFlowClass.getName() );
}
retVal = ( PageFlowController ) getFlowControllerInstance( pageFlowClass );
@@ -308,9 +296,9 @@
if ( current != null )
{
- if ( _log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- _log.debug( "Pushing PageFlowController " + current + " onto the nesting stack" );
+ LOG.debug( "Pushing PageFlowController " + current + " onto the nesting stack" );
}
if ( pfStack == null ) pfStack = PageFlowStack.get( request, getServletContext(), true );
@@ -327,9 +315,9 @@
//
if ( pfStack != null )
{
- if ( _log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- _log.debug( "Destroying the PageFlowController stack." );
+ LOG.debug( "Destroying the PageFlowController stack." );
}
//
@@ -342,9 +330,9 @@
if ( onStackAlready != null )
{
- if ( _log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- _log.debug( "Found a page flow of type " + retVal.getClass() + " in the stack; "
+ LOG.debug( "Found a page flow of type " + retVal.getClass() + " in the stack; "
+ "using that instance and stopping destruction of the nesting stack." );
}
@@ -405,9 +393,9 @@
{
assert SharedFlowController.class.isAssignableFrom( sharedFlowClass ) : sharedFlowClass.getName();
- if ( _log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- _log.debug( "Creating SharedFlowController of type " + sharedFlowClass.getName() );
+ LOG.debug( "Creating SharedFlowController of type " + sharedFlowClass.getName() );
}
SharedFlowController retVal = ( SharedFlowController ) getFlowControllerInstance( sharedFlowClass );
@@ -415,9 +403,9 @@
HttpServletResponse response = context.getHttpResponse();
retVal.create( request, response, getServletContext() );
- if ( _log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
- _log.debug( "Storing " + retVal + " in the session..." );
+ LOG.debug( "Storing " + retVal + " in the session..." );
}
retVal.persistInSession( request, response );
@@ -519,9 +507,9 @@
for ( int i = 0; i < defaultRefs.length; i++ )
{
SharedFlowRefConfig ref = defaultRefs[i];
- if ( _log.isInfoEnabled() )
+ if ( LOG.isInfoEnabled() )
{
- _log.info( "Shared flow of type " + ref.getType() + " is a default shared flow reference "
+ LOG.info( "Shared flow of type " + ref.getType() + " is a default shared flow reference "
+ "with name " + ref.getName() );
}
addSharedFlow( context, ref.getName(), ref.getType(), sharedFlows );
@@ -641,12 +629,12 @@
}
catch ( InstantiationException e )
{
- _log.error( "Could not instantiate PageFlowController for request " + request.getRequestURI(), e );
+ LOG.error( "Could not instantiate PageFlowController for request " + request.getRequestURI(), e );
return null;
}
catch ( IllegalAccessException e )
{
- _log.error( "Could not instantiate PageFlowController for request " + request.getRequestURI(), e );
+ LOG.error( "Could not instantiate PageFlowController for request " + request.getRequestURI(), e );
return null;
}
}
@@ -671,17 +659,17 @@
}
catch ( ClassNotFoundException e)
{
- if ( _log.isErrorEnabled() ) _log.error( "Requested page flow class " + pageFlowClassName + " not found." );
+ if ( LOG.isErrorEnabled() ) LOG.error( "Requested page flow class " + pageFlowClassName + " not found." );
return null;
}
catch ( InstantiationException e )
{
- _log.error( "Could not instantiate PageFlowController of type " + pageFlowClassName, e );
+ LOG.error( "Could not instantiate PageFlowController of type " + pageFlowClassName, e );
return null;
}
catch ( IllegalAccessException e )
{
- _log.error( "Could not instantiate PageFlowController of type " + pageFlowClassName, e );
+ LOG.error( "Could not instantiate PageFlowController of type " + pageFlowClassName, e );
return null;
}
}
@@ -698,8 +686,13 @@
public static GlobalApp getGlobalApp( HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext )
{
+ Boolean noGlobalApp = (Boolean)servletContext.getAttribute(NO_GLOBAL_APP_KEY);
+ if(noGlobalApp != null && noGlobalApp.booleanValue())
+ return null;
+
GlobalApp current = PageFlowUtils.getGlobalApp( request );
- if ( current != null ) return current;
+ if ( current != null )
+ return current;
try
{
@@ -711,7 +704,7 @@
if ( ! ( sf instanceof GlobalApp ) )
{
- _log.error( "Class " + PageFlowConstants.GLOBALAPP_CLASSNAME + " is not an instance of "
+ LOG.error( "Class " + PageFlowConstants.GLOBALAPP_CLASSNAME + " is not an instance of "
+ GlobalApp.class.getName() );
return null;
}
@@ -720,18 +713,28 @@
}
catch ( InstantiationException e )
{
- _log.error( "Could not instantiate Global.app.", e );
+ LOG.error( "Could not instantiate Global.app.", e );
return null;
}
catch ( IllegalAccessException e )
{
- _log.error( "Could not instantiate Global.app", e );
+ LOG.error( "Could not instantiate Global.app", e );
return null;
}
}
+ /*
+ This is an expected failure. When no "global/Global.class" is found in classloader, the
+ ReloadableClassHandler will throw a CNF exception. When that happens, set a flag that
+ short-circuits this check on subsequent requests so as to prevent throwing CNF(s) for
+ every request.
+
+ Note, iterative development of "global/Global.class" files doesn't work in "bouncy" mode
+ and shouldn't -- this is a deprecated feature and just needs to continue to function.
+ */
catch ( ClassNotFoundException e )
{
- // Ignore -- this is expected if there's no (legacy) Global.app.
+ LOG.info("No Global.app was found in " + request.getContextPath());
+ servletContext.setAttribute(NO_GLOBAL_APP_KEY, Boolean.TRUE);
return null;
}
}
@@ -757,12 +760,12 @@
}
catch ( InstantiationException e )
{
- _log.error( "Could not instantiate PageFlowController of type " + pageFlowClass.getName(), e );
+ LOG.error( "Could not instantiate PageFlowController of type " + pageFlowClass.getName(), e );
return null;
}
catch ( IllegalAccessException e )
{
- _log.error( "Could not instantiate PageFlowController of type " + pageFlowClass.getName(), e );
+ LOG.error( "Could not instantiate PageFlowController of type " + pageFlowClass.getName(), e );
return null;
}
}