| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.commons.jelly.servlet.JellyServletContext |
|
|
| 1 | /* |
|
| 2 | * Copyright 2002,2004 The Apache Software Foundation. |
|
| 3 | * |
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | * you may not use this file except in compliance with the License. |
|
| 6 | * You may obtain a copy of the License at |
|
| 7 | * |
|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 9 | * |
|
| 10 | * Unless required by applicable law or agreed to in writing, software |
|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 13 | * See the License for the specific language governing permissions and |
|
| 14 | * limitations under the License. |
|
| 15 | */ |
|
| 16 | ||
| 17 | package org.apache.commons.jelly.servlet; |
|
| 18 | ||
| 19 | import org.apache.commons.jelly.JellyContext; |
|
| 20 | ||
| 21 | import javax.servlet.ServletContext; |
|
| 22 | import java.io.InputStream; |
|
| 23 | import java.net.MalformedURLException; |
|
| 24 | import java.net.URL; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * |
|
| 28 | * @author <a href="mailto:kelvint@apache.org">Kelvin Tan</a> |
|
| 29 | * @version 1.1 |
|
| 30 | */ |
|
| 31 | public class JellyServletContext extends JellyContext { |
|
| 32 | ||
| 33 | private ServletContext ctx; |
|
| 34 | ||
| 35 | 0 | public JellyServletContext() { |
| 36 | 0 | } |
| 37 | ||
| 38 | public JellyServletContext(ServletContext ctx) { |
|
| 39 | 0 | super(); |
| 40 | 0 | this.ctx = ctx; |
| 41 | 0 | } |
| 42 | ||
| 43 | public JellyServletContext(JellyContext parent, ServletContext ctx) { |
|
| 44 | 0 | super(parent); |
| 45 | 0 | this.ctx = ctx; |
| 46 | 0 | } |
| 47 | ||
| 48 | /** |
|
| 49 | * Allow access of relative URIs when performing <j:include>. |
|
| 50 | * @param s |
|
| 51 | * @return |
|
| 52 | * @throws MalformedURLException |
|
| 53 | */ |
|
| 54 | public URL getResource(String s) throws MalformedURLException { |
|
| 55 | 0 | return ctx.getResource(s); |
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Allow access of relative URIs when performing <j:include>. |
|
| 60 | * @param s |
|
| 61 | * @return |
|
| 62 | */ |
|
| 63 | public InputStream getResourceAsStream(String s) { |
|
| 64 | 0 | return ctx.getResourceAsStream(s); |
| 65 | } |
|
| 66 | ||
| 67 | protected JellyContext createChildContext() |
|
| 68 | { |
|
| 69 | 0 | return new JellyServletContext(this, ctx); |
| 70 | } |
|
| 71 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |