public void accept(final ConnectionHandlerFactory connectionHandlerFactory, final SaslAuthenticationFactory authenticationFactory) { synchronized (connectionLock) { try { resourceUntick("an inbound connection"); } catch (NotOpenException e) { throw new IllegalStateException("Accept after endpoint close", e); } boolean ok = false; try { final ConnectionImpl connection = new ConnectionImpl(EndpointImpl.this, connectionHandlerFactory, this, null, authenticationFactory, AuthenticationConfiguration.empty(), saslProtocol); connections.add(connection); connection.getConnectionHandler().addCloseHandler(SpiUtils.asyncClosingCloseHandler(connection)); connection.addCloseHandler(connectionCloseHandler); connection.addCloseHandler(resourceCloseHandler); ok = true; } finally { if (! ok) closeTick1("a failed inbound connection"); } } }
public Registration registerService(final String serviceType, final OpenListener openListener, final OptionMap optionMap) throws ServiceRegistrationException { if (! VALID_SERVICE_PATTERN.matcher(serviceType).matches()) { throw new IllegalArgumentException("Service type must match " + VALID_SERVICE_PATTERN); } final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(RemotingPermission.REGISTER_SERVICE); } final RegisteredServiceImpl registeredService = new RegisteredServiceImpl(openListener, optionMap); if (registeredServices.putIfAbsent(serviceType, registeredService) != null) { throw new ServiceRegistrationException("Service type '" + serviceType + "' is already registered"); } final MapRegistration<RegisteredServiceImpl> registration = new MapRegistration<RegisteredServiceImpl>(registeredServices, serviceType, registeredService) { protected void closeAction() throws IOException { try { openListener.registrationTerminated(); } finally { super.closeAction(); } } }; // automatically close the registration when the endpoint is closed final Key key = addCloseHandler(SpiUtils.closingCloseHandler(registration)); registration.addCloseHandler((closed, exception) -> key.remove()); return registration; }
connection.getExecutor().execute(SpiUtils.getServiceOpenTask(connectionChannel, openListener)); break; } finally {
SpiUtils.safeHandleClose(handler, (T) AbstractHandleableCloseable.this, null); SpiUtils.safeHandleClose(handler, (T) AbstractHandleableCloseable.this, null); final IOException clone = clone(failure); if (failure != clone) { SpiUtils.glueStackTraces(failure, Thread.currentThread().getStackTrace(), 1, "asynchronous close");
public void handleFailed(final IOException exception, final Void attachment) { log.logf(getClass().getName(), Logger.Level.TRACE, exception, "Registered exception result"); closeTick1("a failed connection (2)"); SpiUtils.glueStackTraces(exception, mark, 1, "asynchronous invocation"); futureResult.setException(exception); }
SpiUtils.safeHandleClose(handler, (T) AbstractHandleableCloseable.this, null); SpiUtils.safeHandleClose(handler, (T) AbstractHandleableCloseable.this, null); final IOException clone = clone(failure); if (failure != clone) { SpiUtils.glueStackTraces(failure, Thread.currentThread().getStackTrace(), 1, "asynchronous close");
SpiUtils.safeHandleClose(handler, (T) AbstractHandleableCloseable.this, null); SpiUtils.safeHandleClose(handler, (T) AbstractHandleableCloseable.this, null); final IOException clone = clone(failure); if (failure != clone) { SpiUtils.glueStackTraces(failure, Thread.currentThread().getStackTrace(), 1, "asynchronous close");
public Cancellable open(final String serviceType, final Result<Channel> result, final OptionMap optionMap) { LocalChannel channel = new LocalChannel(executor, context); try { final OpenListener openListener = context.getServiceOpenListener(serviceType); if (openListener == null) { throw new ServiceNotFoundException("Unable to find service type '" + serviceType + "'"); } context.getConnectionProviderContext().getExecutor().execute(SpiUtils.getServiceOpenTask(channel.getOtherSide(), openListener)); } catch (ServiceNotFoundException e) { result.setException(e); return nullCancellable(); } result.setResult(channel); return nullCancellable(); }
public void accept(final ConnectionHandlerFactory connectionHandlerFactory) { synchronized (connectionLock) { try { resourceUntick("an inbound connection"); } catch (NotOpenException e) { throw new IllegalStateException("Accept after endpoint close", e); } boolean ok = false; try { final ConnectionImpl connection = new ConnectionImpl(EndpointImpl.this, connectionHandlerFactory, this); connections.add(connection); connection.getConnectionHandler().addCloseHandler(SpiUtils.asyncClosingCloseHandler(connection)); connection.addCloseHandler(connectionCloseHandler); connection.addCloseHandler(resourceCloseHandler); ok = true; } finally { if (! ok) closeTick1("a failed inbound connection"); } } }
public Registration registerService(final String serviceType, final OpenListener openListener, final OptionMap optionMap) throws ServiceRegistrationException { if (! VALID_SERVICE_PATTERN.matcher(serviceType).matches()) { throw new IllegalArgumentException("Service type must match " + VALID_SERVICE_PATTERN); } final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(REGISTER_SERVICE_PERM); } final RegisteredServiceImpl registeredService = new RegisteredServiceImpl(openListener, optionMap); if (registeredServices.putIfAbsent(serviceType, registeredService) != null) { throw new ServiceRegistrationException("Service type '" + serviceType + "' is already registered"); } final MapRegistration<RegisteredServiceImpl> registration = new MapRegistration<RegisteredServiceImpl>(registeredServices, serviceType, registeredService) { protected void closeAction() throws IOException { try { openListener.registrationTerminated(); } finally { super.closeAction(); } } }; // automatically close the registration when the endpoint is closed final Key key = addCloseHandler(SpiUtils.closingCloseHandler(registration)); registration.addCloseHandler(new CloseHandler<Registration>() { public void handleClose(final Registration closed, final IOException exception) { key.remove(); } }); return registration; }
connection.getExecutor().execute(SpiUtils.getServiceOpenTask(connectionChannel, openListener)); break; } finally {
public void accept(final ConnectionHandlerFactory connectionHandlerFactory, final SaslAuthenticationFactory authenticationFactory) { synchronized (connectionLock) { try { resourceUntick("an inbound connection"); } catch (NotOpenException e) { throw new IllegalStateException("Accept after endpoint close", e); } boolean ok = false; try { final ConnectionImpl connection = new ConnectionImpl(EndpointImpl.this, connectionHandlerFactory, this, null, authenticationFactory, AuthenticationConfiguration.empty(), saslProtocol); connections.add(connection); connection.getConnectionHandler().addCloseHandler(SpiUtils.asyncClosingCloseHandler(connection)); connection.addCloseHandler(connectionCloseHandler); connection.addCloseHandler(resourceCloseHandler); ok = true; } finally { if (! ok) closeTick1("a failed inbound connection"); } } }
public Registration registerService(final String serviceType, final OpenListener openListener, final OptionMap optionMap) throws ServiceRegistrationException { if (! VALID_SERVICE_PATTERN.matcher(serviceType).matches()) { throw new IllegalArgumentException("Service type must match " + VALID_SERVICE_PATTERN); } final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(RemotingPermission.REGISTER_SERVICE); } final RegisteredServiceImpl registeredService = new RegisteredServiceImpl(openListener, optionMap); if (registeredServices.putIfAbsent(serviceType, registeredService) != null) { throw new ServiceRegistrationException("Service type '" + serviceType + "' is already registered"); } final MapRegistration<RegisteredServiceImpl> registration = new MapRegistration<RegisteredServiceImpl>(registeredServices, serviceType, registeredService) { protected void closeAction() throws IOException { try { openListener.registrationTerminated(); } finally { super.closeAction(); } } }; // automatically close the registration when the endpoint is closed final Key key = addCloseHandler(SpiUtils.closingCloseHandler(registration)); registration.addCloseHandler((closed, exception) -> key.remove()); return registration; }
connection.getExecutor().execute(SpiUtils.getServiceOpenTask(connectionChannel, openListener)); break; } finally {