@Override public void dispatchEvent(final DistributedObjectEventPacket eventPacket, Object ignore) { String serviceName = eventPacket.getServiceName(); if (eventPacket.getEventType() == CREATED) { try { final ProxyRegistry registry = getOrCreateRegistry(serviceName); if (!registry.contains(eventPacket.getName())) { registry.createProxy(eventPacket.getName(), false, true); // listeners will be called if proxy is created here. } } catch (HazelcastInstanceNotActiveException ignored) { ignore(ignored); } } else { final ProxyRegistry registry = registries.get(serviceName); if (registry != null) { registry.destroyProxy(eventPacket.getName(), false); } } }
/** * 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)); } }
private void publish(DistributedObjectEventPacket event) { EventService eventService = proxyService.nodeEngine.getEventService(); Collection<EventRegistration> registrations = eventService.getRegistrations( ProxyServiceImpl.SERVICE_NAME, ProxyServiceImpl.SERVICE_NAME); eventService.publishRemoteEvent(ProxyServiceImpl.SERVICE_NAME, registrations, event, event.getName().hashCode()); }
/** * 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)); } }
private void publish(DistributedObjectEventPacket event) { EventService eventService = proxyService.nodeEngine.getEventService(); Collection<EventRegistration> registrations = eventService.getRegistrations( ProxyServiceImpl.SERVICE_NAME, ProxyServiceImpl.SERVICE_NAME); eventService.publishRemoteEvent(ProxyServiceImpl.SERVICE_NAME, registrations, event, event.getName().hashCode()); }
@Override public void dispatchEvent(final DistributedObjectEventPacket eventPacket, Object ignore) { String serviceName = eventPacket.getServiceName(); if (eventPacket.getEventType() == CREATED) { try { final ProxyRegistry registry = getOrCreateRegistry(serviceName); if (!registry.contains(eventPacket.getName())) { registry.createProxy(eventPacket.getName(), false, true); // listeners will be called if proxy is created here. } } catch (HazelcastInstanceNotActiveException ignored) { ignore(ignored); } } else { final ProxyRegistry registry = registries.get(serviceName); if (registry != null) { registry.destroyProxy(eventPacket.getName(), false); } } }
eventService.executeEventCallback(callback); if (publishEvent) { publish(new DistributedObjectEventPacket(CREATED, serviceName, name));
eventService.executeEventCallback(callback); if (publishEvent) { publish(new DistributedObjectEventPacket(CREATED, serviceName, name));