@Override public DistributedObject getDistributedObject(String serviceName, String name) { checkServiceNameNotNull(serviceName); checkObjectNameNotNull(name); ProxyRegistry registry = getOrCreateRegistry(serviceName); return registry.getOrCreateProxy(name, true); }
/** * 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(); }
ProxyRegistry(ProxyServiceImpl proxyService, String serviceName) { this.proxyService = proxyService; this.serviceName = serviceName; this.service = getService(proxyService.nodeEngine, serviceName); }
@Override public void initializeDistributedObject(String serviceName, String name) { checkServiceNameNotNull(serviceName); checkObjectNameNotNull(name); ProxyRegistry registry = getOrCreateRegistry(serviceName); registry.createProxy(name, true, true); createdCounter.inc(); }
/** * Destroys this proxy registry. */ void destroy() { for (DistributedObjectFuture future : proxies.values()) { if (!future.isSetAndInitialized()) { continue; } DistributedObject distributedObject = extractDistributedObject(future); invalidate(distributedObject); } proxies.clear(); }
@Override public Collection<DistributedObject> getDistributedObjects(String serviceName) { checkServiceNameNotNull(serviceName); Collection<DistributedObject> result = new LinkedList<DistributedObject>(); ProxyRegistry registry = registries.get(serviceName); if (registry != null) { registry.getDistributedObjects(result); } return result; }
@Override public Collection<String> getDistributedObjectNames(String serviceName) { checkServiceNameNotNull(serviceName); ProxyRegistry registry = registries.get(serviceName); if (registry == null) { return Collections.emptySet(); } else { return registry.getDistributedObjectNames(); } }
@Override public void run() throws Exception { ProxyServiceImpl proxyService = getService(); proxyService.destroyLocalDistributedObject(serviceName, name, false); }
public ProxyRegistry createNew(String serviceName) { return new ProxyRegistry(ProxyServiceImpl.this, serviceName); } };
public void shutdown() { for (ProxyRegistry registry : registries.values()) { registry.destroy(); } registries.clear(); listeners.clear(); }
private DistributedObject extractDistributedObject(DistributedObjectFuture future) { try { return future.get(); } catch (Throwable ex) { EmptyStatement.ignore(ex); } return null; }
@Override public DistributedObject getDistributedObject(String serviceName, String name) { checkServiceNameNotNull(serviceName); checkObjectNameNotNull(name); ProxyRegistry registry = getOrCreateRegistry(serviceName); return registry.getOrCreateProxy(name, true); }
@Override public void initializeDistributedObject(String serviceName, String name) { checkServiceNameNotNull(serviceName); checkObjectNameNotNull(name); ProxyRegistry registry = getOrCreateRegistry(serviceName); registry.createProxy(name, true, true); createdCounter.inc(); }
/** * Destroys this proxy registry. */ void destroy() { for (DistributedObjectFuture future : proxies.values()) { if (!future.isSetAndInitialized()) { continue; } DistributedObject distributedObject = extractDistributedObject(future); invalidate(distributedObject); } proxies.clear(); }
/** * 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(); }
@Override public Collection<DistributedObject> getDistributedObjects(String serviceName) { checkServiceNameNotNull(serviceName); Collection<DistributedObject> result = new LinkedList<DistributedObject>(); ProxyRegistry registry = registries.get(serviceName); if (registry != null) { registry.getDistributedObjects(result); } return result; }
@Override public Collection<String> getDistributedObjectNames(String serviceName) { checkServiceNameNotNull(serviceName); ProxyRegistry registry = registries.get(serviceName); if (registry == null) { return Collections.emptySet(); } else { return registry.getDistributedObjectNames(); } }
@Override public void run() throws Exception { ProxyServiceImpl proxyService = getService(); proxyService.destroyLocalDistributedObject(serviceName, name, false); }
ProxyRegistry(ProxyServiceImpl proxyService, String serviceName) { this.proxyService = proxyService; this.serviceName = serviceName; this.service = getService(proxyService.nodeEngine, serviceName); }
public ProxyRegistry createNew(String serviceName) { return new ProxyRegistry(ProxyServiceImpl.this, serviceName); } };