%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.jetty.NotFoundHandlerTag |
|
|
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.tags.jetty; |
|
18 | ||
19 | import org.apache.commons.jelly.JellyTagException; |
|
20 | import org.apache.commons.jelly.TagSupport; |
|
21 | import org.apache.commons.jelly.XMLOutput; |
|
22 | import org.mortbay.http.handler.NotFoundHandler; |
|
23 | ||
24 | /** |
|
25 | * Declare a not found resource handler for a Jetty http server |
|
26 | * |
|
27 | * @author rtl |
|
28 | * @version $Id: NotFoundHandlerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $ |
|
29 | */ |
|
30 | 0 | public class NotFoundHandlerTag extends TagSupport { |
31 | ||
32 | /** Creates a new instance of NotFoundHandlerTag */ |
|
33 | 0 | public NotFoundHandlerTag() { |
34 | 0 | } |
35 | ||
36 | /** |
|
37 | * Perform the tag functionality. In this case, add a resource handler |
|
38 | * to the parent context, setting the allowed methods if required |
|
39 | * |
|
40 | * @param xmlOutput where to send output |
|
41 | * @throws Exception when an error occurs |
|
42 | */ |
|
43 | public void doTag(XMLOutput xmlOutput) throws JellyTagException { |
|
44 | 0 | HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( |
45 | HttpContextTag.class); |
|
46 | 0 | if ( httpContext == null ) { |
47 | 0 | throw new JellyTagException( "<notFoundHandler> tag must be enclosed inside a <httpContext> tag" ); |
48 | } |
|
49 | 0 | NotFoundHandler notFoundHandler = new NotFoundHandler(); |
50 | 0 | httpContext.addHandler(notFoundHandler); |
51 | 0 | invokeBody(xmlOutput); |
52 | 0 | } |
53 | ||
54 | //-------------------------------------------------------------------------- |
|
55 | // Property accessors/mutators |
|
56 | //-------------------------------------------------------------------------- |
|
57 | ||
58 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |