Changeset 5a73c5c6c6be071f8e9267535ca39719136f5e64
- Timestamp:
- 09/22/07 15:19:10 (1 year ago)
- git-parent:
- Files:
-
- src/net/driftingsouls/ds2/server/framework/pipeline/DefaultServletRequestFilter.java (modified) (3 diffs)
- src/net/driftingsouls/ds2/server/framework/pipeline/HttpResponse.java (modified) (1 diff)
- src/net/driftingsouls/ds2/server/framework/pipeline/Response.java (modified) (1 diff)
- src/net/driftingsouls/ds2/server/framework/pipeline/ServletPipeline.java (added)
- src/net/driftingsouls/ds2/server/framework/pipeline/configuration/AbstractRule.java (modified) (8 diffs)
- src/net/driftingsouls/ds2/server/framework/pipeline/configuration/MatchRule.java (modified) (1 diff)
- src/net/driftingsouls/ds2/server/framework/pipeline/configuration/ModuleSetting.java (modified) (1 diff)
- src/net/driftingsouls/ds2/server/framework/pipeline/reader/WSDDReader.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/net/driftingsouls/ds2/server/framework/pipeline/DefaultServletRequestFilter.java
rb504c88 r5a73c5c 20 20 21 21 import java.io.IOException; 22 import java.io.PrintWriter; 23 import java.util.Date; 22 24 23 25 import javax.servlet.FilterChain; … … 33 35 34 36 import net.driftingsouls.ds2.server.framework.BasicContext; 37 import net.driftingsouls.ds2.server.framework.Common; 38 import net.driftingsouls.ds2.server.framework.Context; 39 import net.driftingsouls.ds2.server.framework.ContextMap; 35 40 import net.driftingsouls.ds2.server.framework.Loggable; 41 import net.driftingsouls.ds2.server.framework.pipeline.configuration.PipelineConfig; 36 42 37 43 /** … … 65 71 context.putVariable(HttpServlet.class, "request", httpRequest); 66 72 context.putVariable(HttpServlet.class, "context", context); 73 context.putVariable(HttpServlet.class, "chain", chain); 67 74 68 75 try { 69 chain.doFilter(req, resp); 76 //chain.doFilter(req, resp); 77 //Context context = ContextMap.getContext(); 78 try { 79 //context.putVariable(HttpServlet.class, "config", getServletConfig()); 80 81 Pipeline pipeline = PipelineConfig.getPipelineForContext(context); 82 83 if( pipeline != null ) { 84 pipeline.execute(context); 85 } 86 else { 87 throw new Exception("Unable to find a suitable rule for URL '"+context.getRequest().getRequestURL()+(context.getRequest().getQueryString() != null ? "?"+context.getRequest().getQueryString() : "")+"'"); 88 } 89 90 context.getResponse().send(); 91 } 92 catch( Throwable e ) { 93 context.rollback(); 94 95 StringBuilder msg = new StringBuilder(100); 96 msg.append("Time: "+new Date()+"\n"); 97 msg.append("URI: "+httpRequest.getRequestURI()+"\n"); 98 msg.append("QUERY_STRING: "+httpRequest.getQueryString()+"\n"); 99 msg.append("Session: "+httpRequest.getParameter("sess")+"\n"); 100 msg.append("User: "+(context != null && context.getActiveUser() != null ? context.getActiveUser().getID() : "none")+"\n"); 101 Common.mailThrowable(e, "Framework Exception", msg.toString()); 102 103 e.printStackTrace(); 104 httpResponse.setContentType("text/html"); 105 PrintWriter writer = httpResponse.getWriter(); 106 writer.append("<html><head><title>Drifting Souls Server Framework</title></head>"); 107 writer.append("<body>"); 108 writer.append("<table border=\"0\"><tr><td>\n"); 109 writer.append("<div align=\"center\">\n"); 110 writer.append("<h1>Drifting Souls Server Framework</h1>"); 111 writer.append("Unhandled Exception "+e.getClass().getName()+" during pipeline execution detected<br />\n"); 112 writer.append("Reason: "+e.getMessage()+"</div>\n"); 113 writer.append("<hr style=\"height:1px; border:0px; background-color:#606060; color:#606060\" />"); 114 StackTraceElement[] st = e.getStackTrace(); 115 for( int i=0; i < st.length; i++ ) { 116 writer.append(st[i].toString()+"<br />\n"); 117 } 118 writer.append("</td></tr></table></body></html>"); 119 } 70 120 } 71 121 finally { src/net/driftingsouls/ds2/server/framework/pipeline/HttpResponse.java
r1d7d4ab r5a73c5c 142 142 response.setHeader(name, value); 143 143 } 144 145 /** 146 * Setzt den internen Status auf manuelles senden. 147 * In diesem Fall sendet das Objekt selbst keine Daten mehr. 148 * 149 */ 144 150 145 public void setManualSendStatus() { 151 146 this.manualSend = true; src/net/driftingsouls/ds2/server/framework/pipeline/Response.java
r2d840b8 r5a73c5c 103 103 */ 104 104 public void send() throws IOException; 105 106 /** 107 * Setzt den internen Status auf manuelles senden. 108 * In diesem Fall sendet das Objekt selbst keine Daten mehr. 109 * 110 */ 111 public void setManualSendStatus(); 105 112 } src/net/driftingsouls/ds2/server/framework/pipeline/configuration/AbstractRule.java
rb504c88 r5a73c5c 28 28 import net.driftingsouls.ds2.server.framework.pipeline.Pipeline; 29 29 import net.driftingsouls.ds2.server.framework.pipeline.ReaderPipeline; 30 import net.driftingsouls.ds2.server.framework.pipeline.ServletPipeline; 30 31 import net.driftingsouls.ds2.server.framework.pipeline.actions.Action; 31 32 import net.driftingsouls.ds2.server.framework.pipeline.reader.Reader; … … 35 36 import org.w3c.dom.NodeList; 36 37 37 abstract class AbstractRule implements Rule { 38 private static final int EXECUTE_MODULE = 0; 39 private static final int EXECUTE_READER = 1; 38 // TODO: Behandlung Module, Reader und Servlet in eigene Klassen auslagern 39 abstract class AbstractRule implements Rule { 40 private enum ExecMode { 41 /** 42 * Ausfuehrungsmodus Modul 43 */ 44 MODULE, 45 /** 46 * Ausfuehrungsmodus Reader 47 */ 48 READER, 49 /** 50 * Ausfuehrungsmodus Servlet/Filterchain 51 */ 52 SERVLET 53 } 40 54 41 55 private Node config = null; … … 53 67 private Class<? extends Reader> readerClass = null; 54 68 55 private int executionType = -1;69 private ExecMode executionType = null; 56 70 57 71 private ParameterMap parameterMap = null; … … 82 96 if( node != null ) { 83 97 setupReaderExecuter(node); 98 return; 99 } 100 101 node = XMLUtils.getNodeByXPath(matchNode, "execute-servlet"); 102 if( node != null ) { 103 setupServletExecuter(node); 84 104 return; 85 105 } … … 115 135 116 136 private void setupReaderExecuter(Node node) throws Exception { 117 executionType = E XECUTE_READER;137 executionType = ExecMode.READER; 118 138 119 139 readerClass = Class.forName(XMLUtils.getStringByXPath(node, "reader/@class")) … … 128 148 129 149 private void setupModuleExecuter(Node node) throws Exception { 130 executionType = E XECUTE_MODULE;150 executionType = ExecMode.MODULE; 131 151 132 152 parameter = new Parameter(node); 133 153 } 134 154 135 public boolean executeable(Context context) throws Exception{ 155 private void setupServletExecuter(Node node) throws Exception { 156 executionType = ExecMode.SERVLET; 157 } 158 159 public boolean executeable(Context context) throws Exception { 136 160 if( actions.size() == 0 ) { 137 161 return true; … … 162 186 Pipeline pipe = null; 163 187 164 if( executionType == EXECUTE_MODULE ) { 188 switch( executionType ) { 189 case MODULE: 165 190 pipe = executeModule(context); 166 } 167 if( executionType == EXECUTE_READER ) { 191 break; 192 193 case READER: 168 194 pipe = executeReader(context); 195 break; 196 197 case SERVLET: 198 pipe = executeServlet(context); 199 break; 169 200 } 170 201 … … 190 221 return new GeneratorPipeline( PipelineConfig.getModuleSettingByName(module).generator ); 191 222 } 223 224 private Pipeline executeServlet(Context context) throws Exception { 225 return new ServletPipeline(); 226 } 192 227 } src/net/driftingsouls/ds2/server/framework/pipeline/configuration/MatchRule.java
rb504c88 r5a73c5c 29 29 private Pattern match = null; 30 30 31 publicMatchRule( Node matchNode ) throws Exception {31 MatchRule( Node matchNode ) throws Exception { 32 32 super(matchNode); 33 33 match = Pattern.compile( XMLUtils.getStringByXPath(matchNode, "@pattern") ); src/net/driftingsouls/ds2/server/framework/pipeline/configuration/ModuleSetting.java
rb504c88 r5a73c5c 24 24 Class<? extends Generator> generator = null; 25 25 26 publicModuleSetting(String generator) throws ClassNotFoundException {26 ModuleSetting(String generator) throws ClassNotFoundException { 27 27 if( (generator != null) && !"".equals(generator.trim()) ) { 28 28 this.generator = Class.forName(generator).asSubclass(Generator.class); src/net/driftingsouls/ds2/server/framework/pipeline/reader/WSDDReader.java
rac6bde7 r5a73c5c 43 43 import net.driftingsouls.ds2.server.framework.Context; 44 44 import net.driftingsouls.ds2.server.framework.Loggable; 45 import net.driftingsouls.ds2.server.framework.pipeline.HttpResponse;46 45 import net.driftingsouls.ds2.server.framework.pipeline.ReaderPipeline; 46 import net.driftingsouls.ds2.server.framework.pipeline.Response; 47 47 import net.driftingsouls.ds2.server.framework.xml.XMLUtils; 48 48 … … 324 324 readConfig(pipeline.getConfiguration()); 325 325 326 ((HttpResponse)context.getResponse()).setManualSendStatus();326 context.getResponse().setManualSendStatus(); 327 327 328 328 HttpServletRequest req = (HttpServletRequest)context.getVariable(HttpServlet.class,
