1 7 package org.jboss.webservice.server; 8 9 11 import org.jboss.axis.AxisFault; 12 import org.jboss.axis.Constants; 13 import org.jboss.axis.EngineConfiguration; 14 import org.jboss.axis.Handler; 15 import org.jboss.axis.MessageContext; 16 import org.jboss.axis.SimpleTargetedChain; 17 import org.jboss.axis.description.OperationDesc; 18 import org.jboss.axis.server.AxisServer; 19 import org.jboss.axis.soap.SOAPConstants; 20 import org.jboss.axis.utils.Messages; 21 import org.jboss.logging.Logger; 22 23 import javax.xml.soap.SOAPException ; 24 25 33 public class ServerEngine extends AxisServer 34 { 35 36 static final long serialVersionUID = 5160872757245559530L; 37 private static final Logger log = Logger.getLogger(ServerEngine.class); 39 40 43 public ServerEngine(EngineConfiguration config) 44 { 45 super(config); 46 log.debug("new ServerEngine [config=" + config + "]"); 47 } 48 49 53 public void invoke(final MessageContext msgContext) throws AxisFault 54 { 55 try 56 { 57 long t1 = System.currentTimeMillis(); 59 msgContext.getMessage().getSOAPPart().getEnvelope(); 60 long t2 = System.currentTimeMillis(); 61 Logger.getLogger(Constants.TIME_LOG_CATEGORY).debug("Get SOAPEnvelope in " + (t2 - t1) + "ms"); 62 63 OperationDesc currOperation = msgContext.getOperation(); 64 if (currOperation != null && currOperation.isOneWay()) 65 { 66 Thread th = new Thread () 67 { 68 public void run() 69 { 70 try 71 { 72 invokeInternal(msgContext); 73 } 74 catch (AxisFault fault) 75 { 76 log.error("Asyncronous Server error: " + fault.dumpToString()); 77 } 78 } 79 }; 80 th.start(); 81 82 msgContext.setResponseMessage(null); 83 84 log.debug("Returning immediately from one-way operation: " + currOperation.getName()); 85 return; 86 } 87 88 invokeInternal(msgContext); 90 } 91 catch (AxisFault af) 92 { 93 log.error("Server error: " + af.dumpToString()); 94 throw af; 95 } 96 catch (SOAPException ex) 97 { 98 log.error("Server error", ex); 99 throw AxisFault.makeFault(ex); 100 } 101 catch (RuntimeException ex) 102 { 103 log.error("Server error", ex); 104 throw ex; 105 } 106 } 107 108 111 private void invokeInternal(MessageContext msgContext) throws AxisFault 112 { 113 log.debug("invoke: " + msgContext); 114 115 long t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0; 116 117 if (!isRunning()) 118 { 119 throw new AxisFault("Server.disabled", 120 Messages.getMessage("serverDisabled00"), 121 null, null); 122 } 123 124 String hName = null; 125 Handler handler = null; 126 127 MessageContext previousContext = getCurrentMessageContext(); 129 130 try 131 { 132 setCurrentMessageContext(msgContext); 134 135 146 147 148 149 hName = msgContext.getTransportName(); 150 SimpleTargetedChain transportChain = null; 151 152 log.debug("TransportHandler: " + hName); 153 154 t1 = System.currentTimeMillis(); 156 157 if (hName != null && (handler = getTransport(hName)) != null) 158 { 159 if (handler instanceof SimpleTargetedChain) 160 { 161 transportChain = (SimpleTargetedChain)handler; 162 handler = transportChain.getRequestHandler(); 163 if (handler != null) 164 handler.invoke(msgContext); 165 } 166 } 167 168 t2 = System.currentTimeMillis(); 170 171 172 173 if ((handler = getGlobalRequest()) != null) 174 handler.invoke(msgContext); 175 176 t3 = System.currentTimeMillis(); 178 179 185 handler = msgContext.getService(); 186 if (handler == null) 187 { 188 throw new AxisFault("Server.NoService", 189 Messages.getMessage("noService05", msgContext.getTargetService()), 190 null, null); 191 } 192 193 if (msgContext.getSOAPConstants() != null) 195 { 196 SOAPConstants soapConstants = msgContext.getSOAPConstants(); 197 msgContext.setSOAPConstants(soapConstants); 198 } 199 200 handler.invoke(msgContext); 201 202 t4 = System.currentTimeMillis(); 204 205 if ((handler = getGlobalResponse()) != null) 207 handler.invoke(msgContext); 208 209 t5 = System.currentTimeMillis(); 211 212 if (transportChain != null) 214 { 215 handler = transportChain.getResponseHandler(); 216 if (handler != null) 217 handler.invoke(msgContext); 218 } 219 220 t6 = System.currentTimeMillis(); 222 223 if (log.isTraceEnabled()) 224 { 225 String serviceName = msgContext.getTargetService(); 226 if (msgContext.getOperation() != null) 227 serviceName += "." + msgContext.getOperation().getName(); 228 229 log.trace(serviceName + " [" + 230 "trIn=" + (t2 - t1) + 231 ",glIn=" + (t3 - t2) + 232 ",invoke=" + (t4 - t3) + 233 ",glOut=" + (t5 - t4) + 234 ",trOut=" + (t6 - t5) + 235 "]"); 236 } 237 } 238 catch (AxisFault e) 239 { 240 throw e; 241 } 242 catch (Exception e) 243 { 244 throw AxisFault.makeFault(e); 246 247 } 248 finally 249 { 250 setCurrentMessageContext(previousContext); 252 } 253 } 254 } 255 | Popular Tags |