|
9 | 9 | import android.os.Build; |
10 | 10 | import android.util.Log; |
11 | 11 |
|
12 | | -import Test.Common.ProcessControllerPrx; |
13 | | -import Test.Common.ProcessControllerRegistryPrx; |
14 | | - |
15 | 12 | import com.zeroc.Ice.Communicator; |
16 | 13 | import com.zeroc.Ice.Logger; |
17 | 14 | import com.zeroc.Ice.Time; |
@@ -195,77 +192,8 @@ public ControllerI(boolean bluetooth) { |
195 | 192 |
|
196 | 193 | _communicator = new com.zeroc.Ice.Communicator(initData); |
197 | 194 | com.zeroc.Ice.ObjectAdapter adapter = _communicator.createObjectAdapter("ControllerAdapter"); |
198 | | - ProcessControllerPrx processController = |
199 | | - ProcessControllerPrx.uncheckedCast( |
200 | | - adapter.add( |
201 | | - new ProcessControllerI(), |
202 | | - com.zeroc.Ice.Util.stringToIdentity("Android/ProcessController"))); |
| 195 | + adapter.add(new ProcessControllerI(), new com.zeroc.Ice.Identity("ProcessController", "Android")); |
203 | 196 | adapter.activate(); |
204 | | - |
205 | | - if (!isEmulator()) |
206 | | - { |
207 | | - // Use IceDiscovery to find a process controller registry |
208 | | - ProcessControllerRegistryPrx registry = |
209 | | - ProcessControllerRegistryPrx.createProxy(_communicator, "Util/ProcessControllerRegistry"); |
210 | | - registerProcessController(adapter, registry, processController); |
211 | | - } |
212 | | - } |
213 | | - |
214 | | - public void registerProcessController( |
215 | | - final com.zeroc.Ice.ObjectAdapter adapter, |
216 | | - final ProcessControllerRegistryPrx registry, |
217 | | - final ProcessControllerPrx processController) { |
218 | | - registry.ice_pingAsync() |
219 | | - .whenCompleteAsync( |
220 | | - (r1, e1) -> { |
221 | | - if (e1 != null) { |
222 | | - handleException(e1, adapter, registry, processController); |
223 | | - } else { |
224 | | - com.zeroc.Ice.Connection connection = registry.ice_getConnection(); |
225 | | - connection.setAdapter(adapter); |
226 | | - connection.setCloseCallback( |
227 | | - con -> { |
228 | | - println("connection with process controller registry closed"); |
229 | | - while (true) { |
230 | | - try { |
231 | | - Thread.sleep(500); |
232 | | - break; |
233 | | - } catch (InterruptedException e) { |
234 | | - // Ignore and try again. |
235 | | - } |
236 | | - } |
237 | | - registerProcessController(adapter, registry, processController); |
238 | | - }); |
239 | | - |
240 | | - registry.setProcessControllerAsync(processController) |
241 | | - .whenCompleteAsync( |
242 | | - (r2, e2) -> { |
243 | | - if (e2 != null) { |
244 | | - handleException(e2, adapter, registry, processController); |
245 | | - } |
246 | | - }); |
247 | | - } |
248 | | - }); |
249 | | - } |
250 | | - |
251 | | - public void handleException( |
252 | | - Throwable ex, |
253 | | - final com.zeroc.Ice.ObjectAdapter adapter, |
254 | | - final ProcessControllerRegistryPrx registry, |
255 | | - final ProcessControllerPrx processController) { |
256 | | - if (ex instanceof com.zeroc.Ice.ConnectFailedException || ex instanceof com.zeroc.Ice.TimeoutException) { |
257 | | - while (true) { |
258 | | - try { |
259 | | - Thread.sleep(500); |
260 | | - break; |
261 | | - } catch (InterruptedException e) { |
262 | | - // Ignore and try again. |
263 | | - } |
264 | | - } |
265 | | - registerProcessController(adapter, registry, processController); |
266 | | - } else { |
267 | | - println(ex.toString()); |
268 | | - } |
269 | 197 | } |
270 | 198 |
|
271 | 199 | public void destroy() { |
|
0 commit comments