public void addListener(GatewayEventListener listener) throws GatewayException { synchronized (this.controlLock) { checkRunning(); // If endpoints are already defined, throw an exception if (hasEndpoints()) { throw new GatewayException(LocalizedStrings.GatewayImpl_GATEWAY_0_CANNOT_DEFINE_A_LISTENER_BECAUSE_AT_LEAST_ONE_ENDPOINT_IS_ALREADY_DEFINED_BOTH_LISTENERS_AND_ENDPOINTS_CANNOT_BE_DEFINED_FOR_THE_SAME_GATEWAY.toLocalizedString(this._id)); } List newListeners = new ArrayList(this._listeners); newListeners.add(listener); this._listeners = Collections.unmodifiableList(newListeners); } }
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(this._primary ? "Primary" : "Secondary"); sb.append(" Gateway to "); sb.append(this._id); if (hasEndpoints()) { if (!isConnectedNoSync()) { sb.append(" not"); } sb.append(" connected to "); sb.append(this._endpoints); // replaced and not modified in place... safe } else if (hasListeners()) { sb.append(" with listeners "); sb.append(this._listeners); // replaced and not modified in place... safe } return sb.toString(); }
/** * Test to see if we should enqueue a gateway event. */ private boolean shouldEnqueue(GatewayEventImpl gatewayEvent) { LocalRegion region = gatewayEvent.getRegion(); //GatewayEventListeners should not see events on Meta Regions //This fixes 43978 return hasEndpoints() || !region.isUsedForMetaRegion(); }
protected GatewayEventDispatcher initializeEventDispatcher() { GatewayEventDispatcher dispatcher = null; if (getGateway().hasEndpoints()) { dispatcher = new GatewayEventRemoteDispatcher(this); } else { dispatcher = new GatewayEventCallbackDispatcher(this); } return dispatcher; }