1 package org.jacorb.orb.portableInterceptor; 2 3 22 23 import org.omg.PortableInterceptor.*; 24 import org.omg.CORBA.UserException ; 25 26 import org.jacorb.orb.SystemExceptionHelper; 27 28 35 36 public class ServerInterceptorIterator 37 extends RequestInterceptorIterator 38 { 39 public static final short RECEIVE_REQUEST_SERVICE_CONTEXTS = 0; 40 public static final short RECEIVE_REQUEST = 1; 41 public static final short SEND_REPLY = 2; 42 public static final short SEND_EXCEPTION = 3; 43 public static final short SEND_OTHER = 4; 44 45 private ServerRequestInfoImpl info = null; 46 47 public ServerInterceptorIterator(Interceptor[] interceptors) 48 { 49 super(interceptors); 50 } 51 52 56 public void iterate( ServerRequestInfoImpl info, short op ) 57 throws UserException 58 { 59 60 this.info = info; 61 this.op = op; 62 63 info.update(); 65 info.caller_op = op; 66 67 setDirection( (op == RECEIVE_REQUEST_SERVICE_CONTEXTS) || 70 (op == RECEIVE_REQUEST)); 71 72 iterate(); 73 74 if ( interceptor_ex != null ) 76 if (interceptor_ex instanceof ForwardRequest) 77 throw (ForwardRequest) interceptor_ex; 78 else 79 throw (org.omg.CORBA.SystemException ) interceptor_ex; 80 } 81 82 protected void invoke(Interceptor interceptor) 83 throws UserException 84 { 85 86 try 87 { 88 switch (op) 89 { 90 case RECEIVE_REQUEST_SERVICE_CONTEXTS : 91 ((ServerRequestInterceptor) interceptor). 92 receive_request_service_contexts(info); 93 break; 94 case RECEIVE_REQUEST : 95 ((ServerRequestInterceptor) interceptor).receive_request(info); 96 break; 97 case SEND_REPLY : 98 ((ServerRequestInterceptor) interceptor).send_reply(info); 99 break; 100 case SEND_EXCEPTION : 101 ((ServerRequestInterceptor) interceptor).send_exception(info); 102 break; 103 case SEND_OTHER : 104 ((ServerRequestInterceptor) interceptor).send_other(info); 105 break; 106 } 107 } 108 catch (ForwardRequest _fwd) 109 { 110 reverseDirection(); 111 op = SEND_OTHER; 112 113 info.reply_status = LOCATION_FORWARD.value; 114 115 info.forward_reference = _fwd.forward; 116 117 interceptor_ex = _fwd; 118 } 119 catch (org.omg.CORBA.SystemException _sysex) 120 { 121 reverseDirection(); 122 op = SEND_EXCEPTION; 123 interceptor_ex = _sysex; 124 125 SystemExceptionHelper.insert(info.sending_exception, _sysex); 126 } 127 catch (Throwable th) 128 { 129 th.printStackTrace(); 130 } 131 132 info.caller_op = op; 133 } 134 } 136 137 138 | Popular Tags |