1 16 17 package org.apache.commons.latka.jelly; 18 19 import org.apache.commons.jelly.JellyContext; 20 import org.apache.commons.jelly.Tag; 21 import org.apache.commons.jelly.TagSupport; 22 23 import org.apache.commons.latka.event.LatkaEventInfo; 24 import org.apache.commons.latka.event.LatkaEventListener; 25 import org.apache.commons.latka.http.Request; 26 27 31 public class JellyUtils { 32 33 protected static final String EVENT_INFO_VAR = 34 "latkaEventInfo"; 35 protected static final String EVENT_LISTENER_VAR = 36 "latkaEventListener"; 37 38 protected static JellyUtils _utils = new JellyUtils(); 39 40 41 public JellyUtils() { 42 } 43 44 public static JellyUtils getInstance() { 45 return _utils; 46 } 47 48 56 public LatkaEventInfo getLatkaEventInfo(JellyContext context) { 57 return (LatkaEventInfo) context.getVariable(EVENT_INFO_VAR); 58 } 59 60 66 public void setLatkaEventInfo(JellyContext context, LatkaEventInfo info) { 67 context.setVariable(EVENT_INFO_VAR,info); 68 } 69 70 71 76 public void removeLatkaEventInfo(JellyContext context) { 77 context.removeVariable(EVENT_INFO_VAR); 78 } 79 80 88 public LatkaEventListener getLatkaEventListener(JellyContext context) { 89 return (LatkaEventListener) context.getVariable(EVENT_LISTENER_VAR); 90 } 91 92 98 public void setLatkaEventListener(JellyContext context, LatkaEventListener listener) { 99 context.setVariable(EVENT_LISTENER_VAR,listener); 100 } 101 102 109 public Request findParentRequest(Tag tag) { 110 RequestTag requestTag = 111 (RequestTag) TagSupport.findAncestorWithClass(tag.getParent(), RequestTag.class); 112 return requestTag.getRequest(); 113 } 114 } 115 | Popular Tags |