Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 320   Methods: 0
NCLOC: 38   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
IRequestCycle.java - - - -
coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.tapestry.engine.IEngineService;
 19   
 import org.apache.tapestry.engine.IMonitor;
 20   
 import org.apache.tapestry.request.RequestContext;
 21   
 import org.apache.tapestry.services.Infrastructure;
 22   
 
 23   
 /**
 24   
  * Controller object that manages a single request cycle. A request cycle is one 'hit' on the web
 25   
  * server. In the case of a Tapestry application, this will involve:
 26   
  * <ul>
 27   
  * <li>Responding to the URL by finding an {@link IEngineService}object
 28   
  * <li>Determining the result page
 29   
  * <li>Renderring the result page
 30   
  * <li>Releasing any resources
 31   
  * </ul>
 32   
  * <p>
 33   
  * Mixed in with this is:
 34   
  * <ul>
 35   
  * <li>Exception handling
 36   
  * <li>Loading of pages and templates from resources
 37   
  * <li>Tracking changes to page properties, and restoring pages to prior states
 38   
  * <li>Pooling of page objects
 39   
  * </ul>
 40   
  * <p>
 41   
  * A request cycle is broken up into two phases. The <em>rewind</em> phase is optional, as it tied
 42   
  * to {@link org.apache.tapestry.link.ActionLink}or {@link org.apache.tapestry.form.Form}
 43   
  * components. In the rewind phase, a previous page render is redone (discarding output) until a
 44   
  * specific component of the page is reached. This rewinding ensures that the page is restored to
 45   
  * the exact state it had when the URL for the request cycle was generated, taking into account the
 46   
  * dynamic nature of the page ({@link org.apache.tapestry.components.Foreach},
 47   
  * {@link org.apache.tapestry.components.Conditional}, etc.). Once this component is reached, it
 48   
  * can notify its {@link IActionListener}. The listener has the ability to update the state of any
 49   
  * pages and select a new result page.
 50   
  * <p>
 51   
  * Following the rewind phase is the <em>render</em> phase. During the render phase, a page is
 52   
  * actually rendered and output sent to the client web browser.
 53   
  * 
 54   
  * @author Howard Lewis Ship
 55   
  */
 56   
 
 57   
 public interface IRequestCycle
 58   
 {
 59   
     /**
 60   
      * Invoked after the request cycle is no longer needed, to release any resources it may have.
 61   
      * This includes releasing any loaded pages back to the page source.
 62   
      */
 63   
 
 64   
     public void cleanup();
 65   
 
 66   
     /**
 67   
      * Passes the String through
 68   
      * {@link javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String)}, which ensures
 69   
      * that the session id is encoded in the URL (if necessary).
 70   
      */
 71   
 
 72   
     public String encodeURL(String URL);
 73   
 
 74   
     /**
 75   
      * Returns the engine which is processing this request cycle.
 76   
      * @deprecated To be removed in 3.2
 77   
      */
 78   
 
 79   
     public IEngine getEngine();
 80   
 
 81   
     /**
 82   
      * Retrieves a previously stored attribute, returning null if not found. Attributes allow
 83   
      * components to locate each other; primarily they allow a wrapped component to locate a
 84   
      * component which wraps it.
 85   
      */
 86   
 
 87   
     public Object getAttribute(String name);
 88   
 
 89   
     public IMonitor getMonitor();
 90   
 
 91   
     /**
 92   
      * Returns the next action id. ActionLink ids are used to identify different actions on a page
 93   
      * (URLs that are related to dynamic page state).
 94   
      */
 95   
 
 96   
     public String getNextActionId();
 97   
 
 98   
     /**
 99   
      * Identifies the active page, the page which will ultimately render the response.
 100   
      */
 101   
 
 102   
     public IPage getPage();
 103   
 
 104   
     /**
 105   
      * Returns the page with the given name. If the page has been previously loaded in the current
 106   
      * request cycle, that page is returned. Otherwise, the engine's page loader is used to load the
 107   
      * page.
 108   
      * 
 109   
      */
 110   
 
 111   
     public IPage getPage(String name);
 112   
 
 113   
     public RequestContext getRequestContext();
 114   
 
 115   
     /**
 116   
      * Returns true if the context is being used to rewind a prior state of the page. This is only
 117   
      * true when there is a target action id.
 118   
      */
 119   
 
 120   
     public boolean isRewinding();
 121   
 
 122   
     /**
 123   
      * Checks to see if the current action id matches the target action id. Returns true only if
 124   
      * they match. Returns false if there is no target action id (that is, during page rendering).
 125   
      * <p>
 126   
      * If theres a match on action id, then the component is compared against the target component.
 127   
      * If there's a mismatch then a {@link StaleLinkException}is thrown.
 128   
      */
 129   
 
 130   
     public boolean isRewound(IComponent component) throws StaleLinkException;
 131   
 
 132   
     /**
 133   
      * Removes a previously stored attribute, if one with the given name exists.
 134   
      */
 135   
 
 136   
     public void removeAttribute(String name);
 137   
 
 138   
     /**
 139   
      * Renders the given page. Applications should always use this method to render the page, rather
 140   
      * than directly invoking {@link IPage#render(IMarkupWriter, IRequestCycle)}since the request
 141   
      * cycle must perform some setup before rendering.
 142   
      */
 143   
 
 144   
     public void renderPage(IMarkupWriter writer);
 145   
 
 146   
     /**
 147   
      * Rewinds a page and executes some form of action when the component with the specified action
 148   
      * id is reached.
 149   
      * 
 150   
      * @see IAction
 151   
      */
 152   
 
 153   
     public void rewindPage(String targetActionId, IComponent targetComponent);
 154   
 
 155   
     /**
 156   
      * Allows a temporary object to be stored in the request cycle, which allows otherwise unrelated
 157   
      * objects to communicate. This is similar to <code>HttpServletRequest.setAttribute()</code>,
 158   
      * except that values can be changed and removed as well.
 159   
      * <p>
 160   
      * This is used by components to locate each other. A component, such as
 161   
      * {@link org.apache.tapestry.html.Body}, will write itself under a well-known name into the
 162   
      * request cycle, and components it wraps can locate it by that name.
 163   
      */
 164   
 
 165   
     public void setAttribute(String name, Object value);
 166   
 
 167   
     /**
 168   
      * Sets the page to be rendered. This is called by a component during the rewind phase to
 169   
      * specify an alternate page to render during the response phase.
 170   
      * 
 171   
      * @deprecated To be removed in 3.1. Use {@link #activate(IPage)}.
 172   
      */
 173   
 
 174   
     public void setPage(IPage page);
 175   
 
 176   
     /**
 177   
      * Sets the page to be rendered. This is called by a component during the rewind phase to
 178   
      * specify an alternate page to render during the response phase.
 179   
      * 
 180   
      * @deprecated To be removed in 3.1. Use {@link #activate(String)}.
 181   
      */
 182   
 
 183   
     public void setPage(String name);
 184   
 
 185   
     /**
 186   
      * Invoked just before rendering the response page to get all
 187   
      * {@link org.apache.tapestry.engine.IPageRecorder page recorders}touched in this request cycle
 188   
      * to commit their changes (save them to persistant storage).
 189   
      * 
 190   
      * @see org.apache.tapestry.engine.IPageRecorder#commit()
 191   
      */
 192   
 
 193   
     public void commitPageChanges();
 194   
 
 195   
     /**
 196   
      * Returns the service which initiated this request cycle. This may return null (very early
 197   
      * during the request cycle) if the service has not yet been determined.
 198   
      * 
 199   
      * @since 1.0.1
 200   
      */
 201   
 
 202   
     public IEngineService getService();
 203   
 
 204   
     /**
 205   
      * Used by {@link IForm forms}to perform a <em>partial</em> rewind so as to respond to the
 206   
      * form submission (using the direct service).
 207   
      * 
 208   
      * @since 1.0.2
 209   
      */
 210   
 
 211   
     public void rewindForm(IForm form, String targetActionId);
 212   
 
 213   
     /**
 214   
      * Much like {@link #forgetPage(String)}, but the page stays active and can even record
 215   
      * changes, until the end of the request cycle, at which point it is discarded (and any recorded
 216   
      * changes are lost). This is used in certain rare cases where a page has persistent state but
 217   
      * is being renderred "for the last time".
 218   
      * 
 219   
      * @since 2.0.2
 220   
      * @deprecated To be removed in 3.2. Use {@link #forgetPage(String)}.
 221   
      */
 222   
 
 223   
     public void discardPage(String name);
 224   
 
 225   
     /**
 226   
      * Invoked by a {@link IEngineService service}to store an array of application-specific
 227   
      * parameters. These can later be retrieved (typically, by an application-specific listener
 228   
      * method) by invoking {@link #getServiceParameters()}.
 229   
      * <p>
 230   
      * Through release 2.1, parameters was of type String[]. This is an incompatible change in 2.2.
 231   
      * 
 232   
      * @see org.apache.tapestry.engine.DirectService
 233   
      * @since 2.0.3
 234   
      */
 235   
 
 236   
     public void setServiceParameters(Object[] parameters);
 237   
 
 238   
     /**
 239   
      * Returns parameters previously stored by {@link #setServiceParameters(Object[])}.
 240   
      * <p>
 241   
      * Through release 2.1, the return type was String[]. This is an incompatible change in 2.2.
 242   
      * 
 243   
      * @since 2.0.3
 244   
      */
 245   
 
 246   
     public Object[] getServiceParameters();
 247   
 
 248   
     /**
 249   
      * A convienience for invoking {@link #activate(IPage)}. Invokes {@link #getPage(String)}to
 250   
      * get an instance of the named page.
 251   
      * 
 252   
      * @since 3.0
 253   
      */
 254   
 
 255   
     public void activate(String name);
 256   
 
 257   
     /**
 258   
      * Sets the active page for the request. The active page is the page which will ultimately
 259   
      * render the response. The activate page is typically set by the {@link IEngineService service}.
 260   
      * Frequently, the active page is changed (from a listener method) to choose an alternate page
 261   
      * to render the response).
 262   
      * <p>
 263   
      * {@link IPage#validate(IRequestCycle)}is invoked on the page to be activated.
 264   
      * {@link PageRedirectException}is caught and the page specified in the exception will be the
 265   
      * active page instead (that is, a page may "pass the baton" to another page using the
 266   
      * exception). The new page is also validated. This continues until a page does not throw
 267   
      * {@link PageRedirectException}.
 268   
      * <p>
 269   
      * Validation loops can occur, where page A redirects to page B and then page B redirects back
 270   
      * to page A (possibly with intermediate steps). This is detected and results in an
 271   
      * {@link ApplicationRuntimeException}.
 272   
      * 
 273   
      * @since 3.0
 274   
      */
 275   
     public void activate(IPage page);
 276   
 
 277   
     /**
 278   
      * Returns a query parameter value, or null if not provided in the request. If multiple values
 279   
      * are provided, returns the first value.
 280   
      * 
 281   
      * @since 3.1
 282   
      */
 283   
     public String getParameter(String name);
 284   
 
 285   
     /**
 286   
      * Returns all query parameter values for the given name. Returns null if no value were
 287   
      * provided.
 288   
      * 
 289   
      * @since 3.1
 290   
      */
 291   
     public String[] getParameters(String name);
 292   
 
 293   
     /**
 294   
      * Converts a partial URL into an absoluate URL. Prefixes the provided URL with servlet context
 295   
      * path (if any), then expands it to a full URL by prepending with the scheme, server and port.
 296   
      * 
 297   
      * @since 3.1
 298   
      */
 299   
 
 300   
     public String getAbsoluteURL(String partialURL);
 301   
 
 302   
     /**
 303   
      * Forgets any stored changes to the specified page. If the page has already been loaded (and
 304   
      * rolled back) then the loaded page instance is not affected; if the page is only loaded
 305   
      * subsequently, the page instance will not see any persisted property changes.
 306   
      * 
 307   
      * @since 3.1
 308   
      */
 309   
 
 310   
     public void forgetPage(String name);
 311   
     
 312   
     /**
 313   
      * Returns the central {@link org.apache.tapestry.services.Infrastructure} object
 314   
      * used to manage the processing of the request.
 315   
      * 
 316   
      * @since 3.1
 317   
      */
 318   
     
 319   
     public Infrastructure getInfrastructure();
 320   
 }