KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openinventions > webappfilter > processor > test > Request


1 package com.openinventions.webappfilter.processor.test;
2
3 import com.openinventions.metaframework.*;
4 import org.apache.commons.logging.*;
5 import java.util.*;
6 import java.util.regex.*;
7 import junit.framework.*;
8
9 public class Request implements Processor {
10     private static final Log log = LogFactory.getLog(Request.class);
11     
12     public void process(State state, Element context) throws Exception JavaDoc {
13         ElementFactory factory = (ElementFactory) state.get("com.openinventions.metaframework.ElementFactory");
14         Element config = (Element) state.get("com.openinventions.metaframework.Config");
15         Element client = config.getElement(context.getPath() + "/parent::*[1]");
16         if (log.isDebugEnabled()) {
17             log.debug("context.getPath() = " + context.getPath());
18             log.debug("client = " + client);
19         }
20         
21         Element req = factory.createElement("request");
22         req.setValue("path", context.getValue("path"));
23         req.setValue("ip", client.getValue("ip"));
24         req.setValue("host", client.getValue("host"));
25         req.setValue("port", client.getValue("port"));
26         Iterator params = context.getElements("param");
27         while (params.hasNext()) {
28             Element param = (Element) params.next();
29             req.addElement(param);
30         }
31
32         if (log.isDebugEnabled()) {
33             log.debug("request = " + factory.toString(req));
34         }
35         state.set("req", req);
36         state.set("nextCommand", context.getPath() + "/child::*[position() = last()]");
37     }
38 }
39 /* ====================================================================
40  * The webappfilter License, Version 1.1
41  *
42  * Copyright (c) 2002 Ivar Chan. All rights
43  * reserved.
44  *
45  * Redistribution and use in source and binary forms, with or without
46  * modification, are permitted provided that the following conditions
47  * are met:
48  *
49  * 1. Redistributions of source code must retain the above copyright
50  * notice, this list of conditions and the following disclaimer.
51  *
52  * 2. Redistributions in binary form must reproduce the above copyright
53  * notice, this list of conditions and the following disclaimer in
54  * the documentation and/or other materials provided with the
55  * distribution.
56  *
57  * 3. The end-user documentation included with the redistribution,
58  * if any, must include the following acknowledgment:
59  * "This product includes software developed by
60  * Ivar Chan (http://www.openinventions.com/webappfilter/)."
61  * Alternately, this acknowledgment may appear in the software itself,
62  * if and wherever such third-party acknowledgments normally appear.
63  *
64  * 4. The name "webappfilter" must not be used to endorse or promote products
65  * derived from this software without prior written permission. For
66  * written permission, please contact ivarchan@acm.org.
67  *
68  * 5. Products derived from this software may not be called "webappfilter",
69  * nor may "webappfilter" appear in their name, without
70  * prior written permission of Ivar Chan.
71  *
72  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
73  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
74  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
75  * DISCLAIMED. IN NO EVENT SHALL THE IVAR CHAN BE LIABLE FOR ANY
76  * DIRECT, INDIRECT, INCIDENTAL,
77  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
78  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
79  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
80  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
81  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
82  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
83  * SUCH DAMAGE.
84  * ====================================================================
85  *
86  * This software consists of voluntary contributions made by many
87  * individuals. For more information on webappfilter, please see
88  * <http://www.openinventions/webappfilter/>.
89  */

90
91
92
93
94
Popular Tags