Home » tiles-2.2.1-src » org.apache.tiles.compat.preparer » [javadoc | source]

    1   /*
    2    * $Id: UrlPreparer.java 709151 2008-10-30 12:36:29Z apetrelli $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
   10    * with the License.  You may obtain a copy of the License at
   11    *
   12    * http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing,
   15    * software distributed under the License is distributed on an
   16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   17    * KIND, either express or implied.  See the License for the
   18    * specific language governing permissions and limitations
   19    * under the License.
   20    */
   21   
   22   package org.apache.tiles.compat.preparer;
   23   
   24   import java.io.IOException;
   25   
   26   import org.apache.tiles.AttributeContext;
   27   import org.apache.tiles.context.TilesRequestContext;
   28   import org.apache.tiles.preparer.PreparerException;
   29   import org.apache.tiles.preparer.ViewPreparerSupport;
   30   
   31   /**
   32    * Uses a URL that acts as a preparer. When
   33    * {@link org.apache.tiles.preparer.ViewPreparer#execute(TilesRequestContext, AttributeContext)}
   34    * is called, the URL is got, but its response is discarded.
   35    *
   36    * @version $Rev: 709151 $ $Date: 2008-10-30 13:36:29 +0100 (gio, 30 ott 2008) $
   37    * @since 2.1.0
   38    */
   39   public class UrlPreparer extends ViewPreparerSupport {
   40   
   41       /**
   42        * The URL to be used as a preparer.
   43        */
   44       private String url;
   45   
   46       /**
   47        * Constructor.
   48        *
   49        * @param url The URL to be used as a preparer.
   50        */
   51       public UrlPreparer(String url) {
   52           this.url = url;
   53       }
   54   
   55       /** {@inheritDoc} */
   56       @Override
   57       public void execute(TilesRequestContext tilesContext,
   58               AttributeContext attributeContext) {
   59   
   60           try {
   61               tilesContext.include(url);
   62           } catch (IOException e) {
   63               throw new PreparerException("The inclusion of the URL " + url
   64                       + " threw an I/O exception", e);
   65           }
   66       }
   67   }

Home » tiles-2.2.1-src » org.apache.tiles.compat.preparer » [javadoc | source]