1 20 package org.enhydra.barracuda.examples; 21 22 import java.io.*; 23 import java.util.*; 24 import java.net.*; 25 import javax.servlet.*; 26 import javax.servlet.http.*; 27 28 import org.enhydra.barracuda.core.event.*; 29 30 31 36 public class GlobalUtilities extends DefaultEventGateway { 37 38 40 private ListenerFactory httpResponseFactory = new DefaultListenerFactory() {public BaseEventListener getInstance() {return new HttpResponseHandler();} public String getListenerID() {return getID(HttpResponseHandler.class);}}; 42 43 private HttpResponseEvent lnkHttpRequestEvent; 46 49 public GlobalUtilities() { 50 specifyLocalEventInterests(httpResponseFactory, HttpResponseEvent.class); 52 } 53 54 63 class HttpResponseHandler extends DefaultBaseEventListener { 64 public void handleViewEvent(ViewEventContext context) throws EventException, ServletException, IOException { 65 BaseEvent event = context.getEvent(); 67 HttpServletResponse resp = context.getResponse(); 68 69 resp.setHeader("Cache-Control","max-age=0"); 72 resp.setDateHeader("Last-Modified", System.currentTimeMillis()); 73 74 resp.setContentType("text/html"); 76 PrintWriter out = resp.getWriter(); 77 out.println("<html><head><title>Resource not Found</title></head>"); 78 out.println("<body><font face=\"Arial\">"); 79 80 String targetEventName = (String ) context.getState(ApplicationGateway.TARGET_EVENT_NAME); 82 out.println("<p>Beep-beep-beep! We're sorry your call did not go through. Will you please hang up and try your call again..."); 83 out.println("<p>If you received this message, it indicates that either <strong>"+targetEventName+"</strong> is not a valid event OR the system is misconfigured. If you feel there is a problem with the system please <a HREF=\"mailto:christianc@lutris.com\">contact the application administrator</a>... "); 84 85 BaseEvent be = DefaultBaseEvent.getRootEvent(event); 87 out.println("<p>The base event that triggered this action was:"+be+"<br>"); 88 out.println("Source:"+be.getSource()+"<br>"); 89 90 out.println("</font></body></html>"); 92 } 93 } 94 } 95 96 | Popular Tags |