Search in sources :

Example 1 with InitializingObject

use of com.hazelcast.spi.InitializingObject in project hazelcast by hazelcast.

the class ProxyRegistry method doCreateProxy.

private DistributedObjectFuture doCreateProxy(String name, boolean publishEvent, boolean initialize, DistributedObjectFuture proxyFuture) {
    DistributedObject proxy;
    try {
        proxy = service.createDistributedObject(name);
        if (initialize && proxy instanceof InitializingObject) {
            try {
                ((InitializingObject) proxy).initialize();
            } catch (Exception e) {
                // log and throw exception to be handled in outer catch block
                proxyService.logger.warning("Error while initializing proxy: " + proxy, e);
                throw e;
            }
        }
        proxyFuture.set(proxy);
    } catch (Throwable e) {
        // proxy creation or initialization failed
        // deregister future to avoid infinite hang on future.get()
        proxyFuture.setError(e);
        proxies.remove(name);
        throw ExceptionUtil.rethrow(e);
    }
    InternalEventService eventService = proxyService.nodeEngine.getEventService();
    ProxyEventProcessor callback = new ProxyEventProcessor(proxyService.listeners.values(), CREATED, serviceName, name, proxy);
    eventService.executeEventCallback(callback);
    if (publishEvent) {
        publish(new DistributedObjectEventPacket(CREATED, serviceName, name));
    }
    return proxyFuture;
}
Also used : DistributedObject(com.hazelcast.core.DistributedObject) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) InternalEventService(com.hazelcast.spi.impl.eventservice.InternalEventService) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException)

Aggregations

DistributedObject (com.hazelcast.core.DistributedObject)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)1 InitializingObject (com.hazelcast.spi.InitializingObject)1 InternalEventService (com.hazelcast.spi.impl.eventservice.InternalEventService)1