1/*2 * $Id: JspExpressionFactoryFactory.java 1229087 2012-01-09 10:35:14Z mck $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122package org.apache.tiles.el;
2324import javax.el.ExpressionFactory;
25import javax.servlet.ServletContext;
26import javax.servlet.jsp.JspFactory;
2728import org.apache.tiles.request.ApplicationContext;
29import org.apache.tiles.request.ApplicationContextAware;
3031/**32 * Uses the JSP 2.1 {@link ExpressionFactory} to be used in Tiles.33 *34 * @version $Rev: 1229087 $ $Date: 2012-01-09 21:35:14 +1100 (Mon, 09 Jan 2012) $35 * @since 2.2.136 */37publicclassJspExpressionFactoryFactoryimplements ExpressionFactoryFactory,
38 ApplicationContextAware {
3940/**41 * The servlet context.42 *43 * @since 2.2.144 */45protected ServletContext servletContext;
4647/** {@inheritDoc} */48publicvoid setApplicationContext(ApplicationContext applicationContext) {
49 Object context = applicationContext.getContext();
50if (context instanceof ServletContext) {
51this.servletContext = (ServletContext) context;
52 } else {
53thrownew IllegalArgumentException(
54"The application context does not hold an instance of "55 + "ServletContext, consider using JuelExpressionFactoryFactory");
56 }
57 }
5859/** {@inheritDoc} */60public ExpressionFactory getExpressionFactory() {
61return JspFactory.getDefaultFactory().getJspApplicationContext(
62 servletContext).getExpressionFactory();
63 }
64 }