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

    1   /*
    2    * $Id: JspExpressionFactoryFactory.java 816924 2009-09-19 13:45:40Z 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.el;
   23   
   24   import javax.el.ExpressionFactory;
   25   import javax.servlet.ServletContext;
   26   import javax.servlet.jsp.JspFactory;
   27   
   28   import org.apache.tiles.TilesApplicationContext;
   29   import org.apache.tiles.awareness.TilesApplicationContextAware;
   30   
   31   /**
   32    * Uses the JSP 2.1 {@link ExpressionFactory} to be used in Tiles.
   33    *
   34    * @version $Rev: 816924 $ $Date: 2009-09-19 15:45:40 +0200 (sab, 19 set 2009) $
   35    * @since 2.2.1
   36    */
   37   public class JspExpressionFactoryFactory implements ExpressionFactoryFactory,
   38           TilesApplicationContextAware {
   39   
   40       /**
   41        * The servlet context.
   42        *
   43        * @since 2.2.1
   44        */
   45       protected ServletContext servletContext;
   46   
   47       /** {@inheritDoc} */
   48       public void setApplicationContext(TilesApplicationContext applicationContext) {
   49           Object context = applicationContext.getContext();
   50           if (context instanceof ServletContext) {
   51               this.servletContext = (ServletContext) context;
   52           } else {
   53               throw new IllegalArgumentException(
   54                       "The application context does not hold an instance of "
   55                       + "ServletContext, consider using JuelExpressionFactoryFactory");
   56           }
   57       }
   58   
   59       /** {@inheritDoc} */
   60       public ExpressionFactory getExpressionFactory() {
   61           return JspFactory.getDefaultFactory().getJspApplicationContext(
   62                   servletContext).getExpressionFactory();
   63       }
   64   }

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