/** * Retrieves a DistributedObject proxy or creates it if it is not available. * DistributedObject will be initialized by calling {@link InitializingObject#initialize()}, * if it implements {@link InitializingObject}. * * @param name The name of the DistributedObject proxy object to retrieve or create. * @param publishEvent true if a DistributedObjectEvent should be fired. * @return The DistributedObject instance. */ public DistributedObject getOrCreateProxy(String name, boolean publishEvent) { DistributedObjectFuture proxyFuture = getOrCreateProxyFuture(name, publishEvent, true); return proxyFuture.get(); }
private DistributedObject extractDistributedObject(DistributedObjectFuture future) { try { return future.get(); } catch (Throwable ex) { EmptyStatement.ignore(ex); } return null; }
private DistributedObject extractDistributedObject(DistributedObjectFuture future) { try { return future.get(); } catch (Throwable ex) { EmptyStatement.ignore(ex); } return null; }
/** * Retrieves a DistributedObject proxy or creates it if it is not available. * DistributedObject will be initialized by calling {@link InitializingObject#initialize()}, * if it implements {@link InitializingObject}. * * @param name The name of the DistributedObject proxy object to retrieve or create. * @param publishEvent true if a DistributedObjectEvent should be fired. * @return The DistributedObject instance. */ public DistributedObject getOrCreateProxy(String name, boolean publishEvent) { DistributedObjectFuture proxyFuture = getOrCreateProxyFuture(name, publishEvent, true); return proxyFuture.get(); }
/** * Gets the DistributedObjects in this registry. The result is written into 'result'. * * @param result The DistributedObjects in this registry. */ public void getDistributedObjects(Collection<DistributedObject> result) { Collection<DistributedObjectFuture> futures = proxies.values(); for (DistributedObjectFuture future : futures) { if (!future.isSetAndInitialized()) { continue; } try { DistributedObject object = future.get(); result.add(object); } catch (Throwable ignored) { // ignore if proxy creation failed ignore(ignored); } } }
/** * Gets the DistributedObjects in this registry. The result is written into 'result'. * * @param result The DistributedObjects in this registry. */ public void getDistributedObjects(Collection<DistributedObject> result) { Collection<DistributedObjectFuture> futures = proxies.values(); for (DistributedObjectFuture future : futures) { if (!future.isSetAndInitialized()) { continue; } try { DistributedObject object = future.get(); result.add(object); } catch (Throwable ignored) { // ignore if proxy creation failed ignore(ignored); } } }
/** * Destroys a proxy. * * @param name The name of the proxy to destroy. * @param publishEvent true if this destroy should be published. */ void destroyProxy(String name, boolean publishEvent) { final DistributedObjectFuture proxyFuture = proxies.remove(name); if (proxyFuture == null) { return; } DistributedObject proxy; try { proxy = proxyFuture.get(); } catch (Throwable t) { proxyService.logger.warning("Cannot destroy proxy [" + serviceName + ":" + name + "], since its creation is failed with " + t.getClass().getName() + ": " + t.getMessage()); return; } InternalEventService eventService = proxyService.nodeEngine.getEventService(); ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), DESTROYED, serviceName, name, proxy); eventService.executeEventCallback(callback); if (publishEvent) { publish(new DistributedObjectEventPacket(DESTROYED, serviceName, name)); } }
/** * Destroys a proxy. * * @param name The name of the proxy to destroy. * @param publishEvent true if this destroy should be published. */ void destroyProxy(String name, boolean publishEvent) { final DistributedObjectFuture proxyFuture = proxies.remove(name); if (proxyFuture == null) { return; } DistributedObject proxy; try { proxy = proxyFuture.get(); } catch (Throwable t) { proxyService.logger.warning("Cannot destroy proxy [" + serviceName + ":" + name + "], since its creation is failed with " + t.getClass().getName() + ": " + t.getMessage()); return; } InternalEventService eventService = proxyService.nodeEngine.getEventService(); ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), DESTROYED, serviceName, name, proxy); eventService.executeEventCallback(callback); if (publishEvent) { publish(new DistributedObjectEventPacket(DESTROYED, serviceName, name)); } }