1 /*
2 * $Id: JspAutotagRuntime.java 1360343 2012-07-11 18:35:52Z nlebas $
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 package org.apache.tiles.request.jsp.autotag;
22
23 import javax.servlet.jsp.JspContext;
24 import javax.servlet.jsp.PageContext;
25 import javax.servlet.jsp.tagext.SimpleTagSupport;
26 import org.apache.tiles.autotag.core.runtime.ModelBody;
27 import org.apache.tiles.autotag.core.runtime.AutotagRuntime;
28 import org.apache.tiles.request.Request;
29 import org.apache.tiles.request.jsp.JspRequest;
30
31 /**
32 * A Runtime for implementing JSP tag libraries.
33 */
34 public class JspAutotagRuntime extends SimpleTagSupport implements AutotagRuntime<Request> {
35 /** {@inheritDoc} */
36 @Override
37 public void doTag() {
38 // do nothing like the parent implementation,
39 // but don't throw exceptions either
40 }
41
42 /** {@inheritDoc} */
43 @Override
44 public Request createRequest() {
45 JspContext pageContext = getJspContext();
46 return JspRequest.createServletJspRequest(org.apache.tiles.request.jsp.JspUtil.getApplicationContext(pageContext),
47 (PageContext) pageContext);
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public ModelBody createModelBody() {
53 return new JspModelBody(getJspBody(), getJspContext());
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public <T> T getParameter(String name, Class<T> type, T defaultValue) {
59 throw new UnsupportedOperationException("the parameters are injected into the tag itself, no need to fetch them");
60 }
61 }