1 21 package org.jacorb.orb.portableInterceptor; 22 23 import org.omg.PortableInterceptor.*; 24 25 import java.util.*; 26 import org.omg.CORBA.LocalObject ; 27 28 public abstract class RecursionAwareCI 29 extends org.omg.CORBA.LocalObject 30 implements ClientRequestInterceptor 31 { 32 private Hashtable thread_stacks = null; 33 34 private Hashtable ignore_operations = null; 35 36 41 public RecursionAwareCI( boolean ignore_special_ops ) 42 { 43 thread_stacks = new Hashtable(); 44 ignore_operations = new Hashtable(); 45 46 if ( ignore_special_ops ) 47 { 48 ignore_operations.put( "_is_a", "" ); 49 ignore_operations.put( "_get_interface", "" ); 50 ignore_operations.put( "_non_existent", "" ); 51 ignore_operations.put( "_get_policy", "" ); 52 ignore_operations.put( "_get_domain_managers", "" ); 53 ignore_operations.put( "_set_policy_overrides", "" ); 54 } 55 } 56 57 public void addIgnoreOperation( String operation_name ) 58 { 59 ignore_operations.put( operation_name, operation_name ); 60 } 61 62 private boolean enterCall( String operation ) 63 { 64 if ( ignore_operations.containsKey( operation ) ) 65 return false; 66 67 Thread current = Thread.currentThread(); 68 69 if ( thread_stacks.containsKey( current )) 70 return false; 71 72 thread_stacks.put( current, current ); 73 74 return true; 75 } 76 77 private void exitCall() 78 { 79 thread_stacks.remove( Thread.currentThread() ); 80 } 81 82 public final void send_request( ClientRequestInfo ri ) 84 throws ForwardRequest 85 { 86 if( enterCall( ri.operation() )) 87 { 88 try 89 { 90 do_send_request( ri ); 91 } 92 finally 93 { 94 exitCall(); 95 } 96 } 97 } 98 99 public final void send_poll(ClientRequestInfo ri) 100 { 101 if( enterCall( ri.operation() )) 102 { 103 try 104 { 105 do_send_poll( ri ); 106 } 107 finally 108 { 109 exitCall(); 110 } 111 } 112 } 113 114 public final void receive_reply(ClientRequestInfo ri) 115 { 116 if( enterCall( ri.operation() )) 117 { 118 try 119 { 120 do_receive_reply( ri ); 121 } 122 finally 123 { 124 exitCall(); 125 } 126 } 127 } 128 129 public final void receive_exception(ClientRequestInfo ri) 130 throws ForwardRequest 131 { 132 if( enterCall( ri.operation() )) 133 { 134 try 135 { 136 do_receive_exception( ri ); 137 } 138 finally 139 { 140 exitCall(); 141 } 142 } 143 } 144 145 public final void receive_other(ClientRequestInfo ri) 146 throws ForwardRequest 147 { 148 if( enterCall( ri.operation() )) 149 { 150 try 151 { 152 do_receive_other( ri ); 153 } 154 finally 155 { 156 exitCall(); 157 } 158 } 159 } 160 161 public abstract void do_send_request( ClientRequestInfo ri ) 162 throws ForwardRequest; 163 164 public abstract void do_send_poll(ClientRequestInfo ri); 165 166 public abstract void do_receive_reply(ClientRequestInfo ri); 167 168 public abstract void do_receive_exception(ClientRequestInfo ri) 169 throws ForwardRequest; 170 171 public abstract void do_receive_other(ClientRequestInfo ri) 172 throws ForwardRequest; 173 } 174 175 176 177 178 179 180 181 182 183 184 185 | Popular Tags |