/** * Get an executor task for opening a service. * * @param newChannel the new service channel * @param listener the service open listener * @return the runnable task */ public static Runnable getServiceOpenTask(final Channel newChannel, final OpenListener listener) { return new ServiceOpenTask(listener, newChannel); }
@Override public SSLSession getSslSession() { return connectionHandler.getSslSession(); }
/** * Called exactly once when the {@code close()} method is invoked; the actual close operation should take place here. * This method <b>must</b> call {@link #closeComplete()}, directly or indirectly, for the close operation to finish * (it may happen in another thread but it must happen). * * This method should not expect the {@link #closeComplete()} call to be made from another thread from the same thread pool * that may cause {@link #close()}. As close will block, this can result in situations where all threads in the pool are * blocked on {@link #close()} method calls, which means the {@link #closeComplete()} will never be run. * * @throws RemotingException if the close failed */ protected void closeAction() throws IOException { closeComplete(); }
/** * {@inheritDoc} */ public Key addCloseHandler(final CloseHandler<? super T> handler) { Assert.checkNotNullParam("handler", handler); synchronized (closeLock) { if (state == State.OPEN || state == State.CLOSING) { final Key key = new KeyImpl<T>(this); final Map<Key, CloseHandler<? super T>> closeHandlers = this.closeHandlers; if (closeHandlers == null) { final IdentityHashMap<Key, CloseHandler<? super T>> newMap = new IdentityHashMap<Key, CloseHandler<? super T>>(); this.closeHandlers = newMap; newMap.put(key, handler); } else { closeHandlers.put(key, handler); } return key; } } runCloseTask(new CloseHandlerTask(handler, null)); return new NullKey(); }
ConnectionImpl(final EndpointImpl endpoint, final ConnectionHandlerFactory connectionHandlerFactory, final ConnectionProviderContext connectionProviderContext, final URI peerUri, final SaslAuthenticationFactory authenticationFactory, final AuthenticationConfiguration authenticationConfiguration, final String saslProtocol) { super(endpoint.getExecutor(), true); this.endpoint = endpoint; this.peerUri = peerUri; this.protocol = connectionProviderContext.getProtocol(); this.authenticationConfiguration = authenticationConfiguration; this.saslProtocol = saslProtocol; this.connectionHandler = connectionHandlerFactory.createInstance(endpoint.new LocalConnectionContext(connectionProviderContext, this)); this.authenticationFactory = authenticationFactory; this.peerIdentityContext = new ConnectionPeerIdentityContext(this, connectionHandler.getOfferedMechanisms(), getConnectionHandler().getPeerSaslServerName(), saslProtocol); }
RemoteConnectionChannel(final RemoteConnectionHandler connectionHandler, final RemoteConnection connection, final int channelId, final int outboundWindow, final int inboundWindow, final int maxOutboundMessages, final int maxInboundMessages, final long maxOutboundMessageSize, final long maxInboundMessageSize) { super(connectionHandler.getConnectionContext().getConnectionProviderContext().getExecutor(), true); this.maxOutboundMessageSize = maxOutboundMessageSize; this.maxInboundMessageSize = maxInboundMessageSize; connectionHandlerContext = connectionHandler.getConnectionContext(); this.connectionHandler = connectionHandler; this.connection = connection; this.channelId = channelId; this.outboundWindow = outboundWindow; this.inboundWindow = inboundWindow; this.maxOutboundMessages = maxOutboundMessages; this.maxInboundMessages = maxInboundMessages; }
public IoFuture<Channel> openChannel(final String serviceType, final OptionMap optionMap) { FutureResult<Channel> result = new FutureResult<Channel>(getExecutor()); result.addCancelHandler(connectionHandler.open(serviceType, result, optionMap)); return result.getIoFuture(); }
public Connection getConnection() { return connectionHandlerContext.getConnection(); }
protected Executor getExecutor() { return super.getExecutor(); }
public String getRemoteEndpointName() { return connectionHandler.getRemoteEndpointName(); }
public void close() { try { super.close(); } catch (IOException e) { throw new IllegalStateException(e); } }
protected void closeAction() throws IOException { synchronized (lock) { closed = true; lock.notifyAll(); } otherSide.connectionHandlerContext.remoteClosed(); closeComplete(); }
@Override public boolean supportsRemoteAuth() { return connectionHandler.supportsRemoteAuth(); }
public SocketAddress getLocalAddress() { return connectionHandler.getLocalAddress(); }
public SecurityIdentity getLocalIdentity() { return connectionHandler.getLocalIdentity(); }
public SocketAddress getPeerAddress() { return connectionHandler.getPeerAddress(); }
public Principal getPrincipal() { return connectionHandler.getPrincipal(); }
protected void closeComplete() { try { super.closeComplete(); } finally { if (server != null && objectName != null) { try { server.unregisterMBean(objectName); } catch (Throwable ignored) { } } } }
public Connection getConnection() { return connectionHandlerContext.getConnection(); }
/** * Make this method visible. */ protected void closeComplete() { super.closeComplete(); remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this); }