1 package org.jacorb.events; 2 3 22 23 import org.jacorb.orb.*; 24 25 43 public class ProxyPullConsumerImpl 44 extends org.omg.CosEventChannelAdmin.ProxyPullConsumerPOA 45 implements Runnable 46 { 47 private EventChannelImpl myEventChannel; 48 private org.omg.CosEventComm.PullSupplier myPullSupplier; 49 private org.omg.PortableServer.POA myPoa = null; 50 private boolean connected = false; 51 52 55 protected ProxyPullConsumerImpl ( EventChannelImpl ec, 56 org.omg.CORBA.ORB orb, 57 org.omg.PortableServer.POA poa ) 58 { 59 myEventChannel = ec; 60 myPoa = poa; 61 connected = false; 62 _this_object( orb ); 63 } 64 65 80 81 public void connect_pull_supplier ( org.omg.CosEventComm.PullSupplier pullSupplier ) 82 throws org.omg.CosEventChannelAdmin.AlreadyConnected, 83 org.omg.CosEventChannelAdmin.TypeError 84 { 85 if ( connected ) { throw new org.omg.CosEventChannelAdmin.AlreadyConnected(); } 86 if ( pullSupplier == null ) { throw new org.omg.CORBA.BAD_PARAM (); } 87 88 myPullSupplier = pullSupplier; 89 connected = true; 90 new Thread (this).start(); 91 } 92 93 105 106 public void disconnect_pull_consumer() 107 { 108 109 if ( connected ) 110 { 111 if ( myPullSupplier != null ) 112 { 113 myPullSupplier.disconnect_pull_supplier(); 114 myPullSupplier = null; 115 } 116 connected = false; 117 } 118 else 119 { 120 throw new org.omg.CORBA.OBJECT_NOT_EXIST (); 121 } 122 } 123 124 127 128 public void run() 129 { 130 org.omg.CORBA.BooleanHolder hasEvent = new org.omg.CORBA.BooleanHolder (); 131 org.omg.CORBA.Any event = null; 132 while( connected ) 133 { 134 synchronized(this) 135 { 136 try 137 { 138 event = myPullSupplier.try_pull( hasEvent ); 139 } 140 catch( org.omg.CORBA.UserException userEx ) 141 { 142 connected = false; 143 return; 145 } 146 catch( org.omg.CORBA.SystemException sysEx ) 147 { 148 connected = false; 149 return; 151 } 152 153 if ( hasEvent.value ) 154 { 155 myEventChannel.push_event( event ); 156 } 157 Thread.yield(); 160 } 161 } 162 } 163 164 165 171 public org.omg.PortableServer.POA _default_POA() 172 { 173 return myPoa; 174 } 175 } 176 | Popular Tags |