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 { 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 90 91 92 93 94 | Popular Tags |