CVS: Tapestry/framework/src/net/sf/tapestry/engine NullMonitor.java,NONE,1.1.2.1 AbstractEngine.java,1.34.2.3,1.34.2.4 DefaultTemplateSource.java,1.9.2.5,1.9.2.6 RequestCycle.java,1.12.2.1,1.12.2.2

Howard Lewis Ship <[email protected]>
Newsgroups gmane.comp.java.tapestry.cvs
Message-ID <[email protected]>
Update of /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine
In directory sc8-pr-cvs1:/tmp/cvs-serv32418/framework/src/net/sf/tapestry/engine

Modified Files:
      Tag: hship-2-3
	AbstractEngine.java DefaultTemplateSource.java 
	RequestCycle.java 
Added Files:
      Tag: hship-2-3
	NullMonitor.java 
Log Message:
Require a IMonitor instance for each request.
Provide a shared null IMonitor implementation.
Allow a monitor to be specified as an application extension.
Add ability to check type of extension.

--- NEW FILE: NullMonitor.java ---
package net.sf.tapestry.engine;

import net.sf.tapestry.IMonitor;

/**
 *  Null implementation of {@link net.sf.tapestry.IMonitor}.
 * 
 *
 *  @author Howard Lewis Ship
 *  @version $Id: NullMonitor.java,v 1.1.2.1 2002/12/16 12:56:34 hship Exp $
 *  @since 2.4
 *
 **/

public class NullMonitor implements IMonitor
{
    public static final NullMonitor SHARED = new NullMonitor();

    public void pageCreateBegin(String pageName)
    {
    }

    public void pageCreateEnd(String pageName)
    {
    }

    public void pageLoadBegin(String pageName)
    {
    }

    public void pageLoadEnd(String pageName)
    {
    }

    public void pageRenderBegin(String pageName)
    {
    }

    public void pageRenderEnd(String pageName)
    {
    }

    public void pageRewindBegin(String pageName)
    {
    }

    public void pageRewindEnd(String pageName)
    {
    }

    public void serviceBegin(String serviceName, String detailMessage)
    {
    }

    public void serviceEnd(String serviceName)
    {
    }

    public void serviceException(Throwable exception)
    {
    }

    public void sessionBegin()
    {
    }

}

Index: AbstractEngine.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine/AbstractEngine.java,v
retrieving revision 1.34.2.3
retrieving revision 1.34.2.4
diff -C2 -d -r1.34.2.3 -r1.34.2.4
*** AbstractEngine.java	12 Dec 2002 12:42:39 -0000	1.34.2.3
--- AbstractEngine.java	16 Dec 2002 12:56:34 -0000	1.34.2.4
***************
*** 454,463 ****
       *  Overriden in subclasses that support monitoring.  Should create and return
       *  an instance of {@link IMonitor} that is appropriate for the request cycle described
!      *  by the {@link RequestContext}.  May return null.
       *
       *  <p>The monitor is used to create a {@link RequestCycle}.
       *
!      *  <p>This implementation returns null always.  Subclasses may overide without
!      *  invoking it.
       *
       *  <p>TBD:  Lifecycle of the monitor ... should there be a commit?
--- 454,469 ----
       *  Overriden in subclasses that support monitoring.  Should create and return
       *  an instance of {@link IMonitor} that is appropriate for the request cycle described
!      *  by the {@link RequestContext}.
       *
       *  <p>The monitor is used to create a {@link RequestCycle}.
       *
!      *  <p>This implementation returns either an application extension named
!      *  <code>net.sf.tapestry.monitor</code>, or
!      *  the shared instance of {@link NullMonitor}.
!      * 
!      *  <p>Subclasses could create their own instances of {@link IMonitor}, specific
!      *  to the individual request or session.
!      * 
!      *  <p>As of release 2.4, this method should <em>not</em> return null.
       *
       *  <p>TBD:  Lifecycle of the monitor ... should there be a commit?
***************
*** 467,471 ****
      public IMonitor getMonitor(RequestContext context)
      {
!         return null;
      }
  
--- 473,480 ----
      public IMonitor getMonitor(RequestContext context)
      {
!         if (_specification.checkExtension(MONITOR_EXTENSION_NAME))
!             return (IMonitor) _specification.getExtension(MONITOR_EXTENSION_NAME, IMonitor.class);
! 
!         return NullMonitor.SHARED;
      }
  
***************
*** 748,753 ****
                  cycle.setService(service);
  
!                 if (monitor != null)
!                     monitor.serviceBegin(service.getName(), context.getRequestURI());
  
                  return service.service(this, cycle, output);
--- 757,761 ----
                  cycle.setService(service);
  
!                 monitor.serviceBegin(serviceName, context.getRequestURI());
  
                  return service.service(this, cycle, output);
***************
*** 771,782 ****
              finally
              {
!                 if (monitor != null)
!                     monitor.serviceEnd(service.getName());
              }
          }
          catch (Exception ex)
          {
!             if (monitor != null)
!                 monitor.serviceException(ex);
  
              // Discard any output (if possible).  If output has already been sent to
--- 779,788 ----
              finally
              {
!                 monitor.serviceEnd(service.getName());
              }
          }
          catch (Exception ex)
          {
!             monitor.serviceException(ex);
  
              // Discard any output (if possible).  If output has already been sent to
***************
*** 1789,1795 ****
--- 1795,1819 ----
      }
  
+     /**
+      *  Name of an application extension that can provide configuration properties.
+      * 
+      *  @see #createPropertySource(RequestContext)
+      *  @since 2.3
+      * 
+      **/
+ 
      private static final String EXTENSION_PROPERTY_SOURCE_NAME = "net.sf.tapestry.property-source";
  
      /**
+      *  The name of an application extension that implements {@link IMonitor}.
+      * 
+      *  @see #getMonitor(RequestContext)
+      *  @since 2.4
+      * 
+      **/
+ 
+     protected static final String MONITOR_EXTENSION_NAME = "net.sf.tapestry.monitor";
+ 
+     /**
       *  Creates a shared property source that will be stored into
       *  the servlet context.
***************
*** 1825,1829 ****
          if (spec.checkExtension(EXTENSION_PROPERTY_SOURCE_NAME))
          {
!             IPropertySource source = (IPropertySource) spec.getExtension(EXTENSION_PROPERTY_SOURCE_NAME);
  
              result.addSource(source);
--- 1849,1854 ----
          if (spec.checkExtension(EXTENSION_PROPERTY_SOURCE_NAME))
          {
!             IPropertySource source =
!                 (IPropertySource) spec.getExtension(EXTENSION_PROPERTY_SOURCE_NAME, IPropertySource.class);
  
              result.addSource(source);

Index: DefaultTemplateSource.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine/DefaultTemplateSource.java,v
retrieving revision 1.9.2.5
retrieving revision 1.9.2.6
diff -C2 -d -r1.9.2.5 -r1.9.2.6
*** DefaultTemplateSource.java	15 Dec 2002 16:26:12 -0000	1.9.2.5
--- DefaultTemplateSource.java	16 Dec 2002 12:56:35 -0000	1.9.2.6
***************
*** 79,82 ****
--- 79,86 ----
      private TemplateParser _parser;
  
+     /** @since 2.2 **/
+     
+     private IResourceLocation _applicationRootLocation;
+ 
      private static class ParserDelegate implements ITemplateParserDelegate
      {
***************
*** 221,226 ****
          return result;
      }
- 
-     private IResourceLocation _applicationRootLocation;
  
      private ComponentTemplate findPageTemplateInApplicationRoot(
--- 225,228 ----

Index: RequestCycle.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/engine/RequestCycle.java,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -C2 -d -r1.12.2.1 -r1.12.2.2
*** RequestCycle.java	4 Dec 2002 03:31:55 -0000	1.12.2.1
--- RequestCycle.java	16 Dec 2002 12:56:35 -0000	1.12.2.2
***************
*** 82,88 ****
  
      /** @since 2.0.3 **/
!     
      private Object[] _serviceParameters;
!     
      /**
       *  Standard constructor used to render a response page.
--- 82,88 ----
  
      /** @since 2.0.3 **/
! 
      private Object[] _serviceParameters;
! 
      /**
       *  Standard constructor used to render a response page.
***************
*** 186,192 ****
              throw new NullPointerException(Tapestry.getString("RequestCycle.invalid-null-name"));
  
-         if (_monitor != null)
-             _monitor.pageLoadBegin(name);
- 
          if (_loadedPages != null)
              result = (IPage) _loadedPages.get(name);
--- 186,189 ----
***************
*** 194,197 ****
--- 191,196 ----
          if (result == null)
          {
+             _monitor.pageLoadBegin(name);
+ 
              IPageSource pageSource = _engine.getPageSource();
  
***************
*** 243,246 ****
--- 242,247 ----
              }
  
+             _monitor.pageLoadEnd(name);
+ 
              if (_loadedPages == null)
                  _loadedPages = new HashMap();
***************
*** 249,255 ****
          }
  
-         if (_monitor != null)
-             _monitor.pageLoadEnd(name);
- 
          return result;
      }
--- 250,253 ----
***************
*** 340,347 ****
          // Woops.  Mismatch.
  
!         throw new StaleLinkException(
!             component,
!             Integer.toHexString(_targetActionId),
!             _targetComponent.getExtendedId());
      }
  
--- 338,342 ----
          // Woops.  Mismatch.
  
!         throw new StaleLinkException(component, Integer.toHexString(_targetActionId), _targetComponent.getExtendedId());
      }
  
***************
*** 366,376 ****
      public void renderPage(IMarkupWriter writer) throws RequestCycleException
      {
!         String pageName = null;
! 
!         if (_monitor != null)
!         {
!             pageName = _page.getName();
!             _monitor.pageRenderBegin(pageName);
!         }
  
          _rewinding = false;
--- 361,366 ----
      public void renderPage(IMarkupWriter writer) throws RequestCycleException
      {
!         String pageName = _page.getName();
!         _monitor.pageRenderBegin(pageName);
  
          _rewinding = false;
***************
*** 412,417 ****
          }
  
!         if (_monitor != null)
!             _monitor.pageRenderEnd(pageName);
  
      }
--- 402,406 ----
          }
  
!         _monitor.pageRenderEnd(pageName);
  
      }
***************
*** 435,445 ****
      {
          IPage page = form.getPage();
!         String pageName = null;
  
!         if (_monitor != null)
!         {
!             pageName = page.getName();
!             _monitor.pageRewindBegin(pageName);
!         }
  
          _rewinding = true;
--- 424,430 ----
      {
          IPage page = form.getPage();
!         String pageName = page.getName();
  
!         _monitor.pageRewindBegin(pageName);
  
          _rewinding = true;
***************
*** 490,499 ****
              _targetActionId = 0;
              _targetComponent = null;
!             
              page.endPageRender();
          }
  
!         if (_monitor != null)
!             _monitor.pageRewindEnd(pageName);
  
      }
--- 475,483 ----
              _targetActionId = 0;
              _targetComponent = null;
! 
              page.endPageRender();
          }
  
!         _monitor.pageRewindEnd(pageName);
  
      }
***************
*** 513,526 ****
       **/
  
!     public void rewindPage(String targetActionId, IComponent targetComponent)
!         throws RequestCycleException
      {
!         String pageName = null;
  
!         if (_monitor != null)
!         {
!             pageName = _page.getName();
!             _monitor.pageRewindBegin(pageName);
!         }
  
          _rewinding = true;
--- 497,505 ----
       **/
  
!     public void rewindPage(String targetActionId, IComponent targetComponent) throws RequestCycleException
      {
!         String pageName = _page.getName();
  
!         _monitor.pageRewindBegin(pageName);
  
          _rewinding = true;
***************
*** 569,574 ****
          }
  
!         if (_monitor != null)
!             _monitor.pageRewindEnd(pageName);
  
      }
--- 548,552 ----
          }
  
!         _monitor.pageRewindEnd(pageName);
  
      }
***************
*** 685,698 ****
          recorder.markForDiscard();
      }
!     
      /** @since 2.0.3 **/
!     
      public Object[] getServiceParameters()
      {
          return _serviceParameters;
      }
!     
      /** @since 2.0.3 **/
!     
      public void setServiceParameters(Object[] serviceParameters)
      {
--- 663,676 ----
          recorder.markForDiscard();
      }
! 
      /** @since 2.0.3 **/
! 
      public Object[] getServiceParameters()
      {
          return _serviceParameters;
      }
! 
      /** @since 2.0.3 **/
! 
      public void setServiceParameters(Object[] serviceParameters)
      {



-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.