public void setExecutor(ScheduledExecutorService executor) { if (this.executor!=null) this.executor.shutdown(); this.executor = executor; for (Endpoint ep:endpoints) ep.setExecutor(executor); }
/** * Sets the executor service to use for running tasks in the protocol stage. * * @param executor The thread pool to use. * @throws IllegalStateException if this server is running. */ public synchronized void setExecutor(final ScheduledExecutorService executor) { if (running) { throw new IllegalStateException("executor service can not be set on running server"); } else { this.executor = executor; for (Endpoint ep : endpoints) { ep.setExecutor(executor); } } }
/** * Adds an Endpoint to the server. WARNING: It automatically configures the * default executor of the server. Endpoints that should use their own * executor (e.g., to prioritize or balance request handling) either set it * afterwards before starting the server or override the setExecutor() * method of the special Endpoint. * * @param endpoint the endpoint to add */ @Override public void addEndpoint(final Endpoint endpoint) { endpoint.setMessageDeliverer(deliverer); endpoint.setExecutor(executor); endpoints.add(endpoint); }
/** * Adds an Endpoint to the server. WARNING: It automatically configures the * default executor of the server. Endpoints that should use their own * executor (e.g., to prioritize or balance request handling) either set it * afterwards before starting the server or override the setExecutor() * method of the special Endpoint. * * @param endpoint the endpoint to add */ @Override public void addEndpoint(Endpoint endpoint) { endpoint.setMessageDeliverer(deliverer); endpoint.setExecutor(executor); endpoints.add(endpoint); }