public EndpointContext context(Endpoint endpoint) { EndpointContext context = (EndpointContext) endpoint.getContext(); if( context == null ) { context = new EndpointContext(this, endpoint); endpoint.setContext(context); } return context; }
@Override public void open(AsyncResult request) { this.openRequest = request; doOpen(); getEndpoint().setContext(this); }
protected final void handleOpened(AmqpProvider provider) { // perform any post open processing prior to opened state inspection. afterOpened(); if (isClosePending()) { return; } if (requestTimeoutTask != null) { requestTimeoutTask.cancel(false); } if (isOpenedEndpointValid()) { resourceInfo.setState(ResourceState.OPEN); getEndpoint().setContext(resource); getParent().addChildResource(resource); getRequest().onSuccess(); } else { // TODO: Perhaps the validate method should thrown an exception so that we // can return a specific error message to the create initiator. handleClosed(provider, new IOException("Failed to open requested endpoint")); } }
protected final void handleOpened(AmqpProvider provider) { // perform any post open processing prior to opened state inspection. afterOpened(); if (isClosePending()) { return; } if (requestTimeoutTask != null) { requestTimeoutTask.cancel(false); } if (isOpenedEndpointValid()) { resourceInfo.setState(ResourceState.OPEN); getEndpoint().setContext(resource); getParent().addChildResource(resource); getRequest().onSuccess(); } else { // TODO: Perhaps the validate method should thrown an exception so that we // can return a specific error message to the create initiator. handleClosed(provider, new IOException("Failed to open requested endpoint")); } }
protected final void handleClosed(AmqpProvider provider, Throwable cause) { // If the resource being built is closed during the creation process // then this is always an error. resourceInfo.setState(ResourceState.REMOTELY_CLOSED); // Perform any post processing relating to closure during creation attempt afterClosed(getResource(), getResourceInfo()); Throwable openError; if (hasRemoteError()) { openError = AmqpSupport.convertToException(parent.getProvider(), getEndpoint(), getEndpoint().getRemoteCondition()); } else if (cause != null) { openError = cause; } else { openError = getOpenAbortException(); } if (requestTimeoutTask != null) { requestTimeoutTask.cancel(false); } LOG.warn("Open of resource:({}) failed: {}", resourceInfo, openError.getMessage()); // This resource is now terminated. getEndpoint().close(); getEndpoint().free(); getEndpoint().setContext(null); getRequest().onFailure(openError); }
protected final void handleClosed(AmqpProvider provider, Throwable cause) { // If the resource being built is closed during the creation process // then this is always an error. resourceInfo.setState(ResourceState.REMOTELY_CLOSED); // Perform any post processing relating to closure during creation attempt afterClosed(getResource(), getResourceInfo()); Throwable openError; if (hasRemoteError()) { openError = AmqpSupport.convertToException(parent.getProvider(), getEndpoint(), getEndpoint().getRemoteCondition()); } else if (cause != null) { openError = cause; } else { openError = getOpenAbortException(); } if (requestTimeoutTask != null) { requestTimeoutTask.cancel(false); } LOG.warn("Open of resource:({}) failed: {}", resourceInfo, openError.getMessage()); // This resource is now terminated. getEndpoint().close(); getEndpoint().free(); getEndpoint().setContext(null); getRequest().onFailure(openError); }
getEndpoint().setContext(null);
getEndpoint().setContext(null);
endpoint.setContext(this); endpoint.open();
endpoint.setContext(this); endpoint.open();
getEndpoint().close(); getEndpoint().free(); getEndpoint().setContext(null);
getEndpoint().close(); getEndpoint().free(); getEndpoint().setContext(null);