/** * Reset default endpoints. Destroy all default endpoints. */ public static void reset() { EndpointManager it = getEndpointManager(); if (it.default_endpoint != null) { it.default_endpoint.destroy(); it.default_endpoint = null; } if (it.default_secure_endpoint != null) { it.default_secure_endpoint.destroy(); it.default_secure_endpoint = null; } }
/** * Reset default endpoints. Destroy all default endpoints and clear their * set. */ public static void reset() { EndpointManager it = getEndpointManager(); if (it.default_endpoint != null) { it.default_endpoint.destroy(); it.default_endpoint = null; } if (it.default_secure_endpoint != null) { it.default_secure_endpoint.destroy(); it.default_secure_endpoint = null; } if (it.default_tcp_endpoint != null) { it.default_tcp_endpoint.destroy(); it.default_tcp_endpoint = null; } if (it.default_secure_tpc_endpoint != null) { it.default_secure_tpc_endpoint.destroy(); it.default_secure_tpc_endpoint = null; } }
/** * Destroys the server, i.e., unbinds from all ports and frees all system resources. */ @Override public void destroy() { LOGGER.info("Destroy server"); for (Endpoint ep:endpoints) ep.destroy(); executor.shutdown(); // cannot be started again try { boolean succ = executor.awaitTermination(5, TimeUnit.SECONDS); if (!succ) LOGGER.warning("Server executor did not shutdown in time"); } catch (InterruptedException e) { LOGGER.log(Level.WARNING, "Exception while terminating server executor", e); } }
} finally { for (Endpoint ep : endpoints) { ep.destroy();
/** * Configures a new default endpoint. Any old default endpoint is destroyed. * @param endpoint the new default endpoint */ public void setDefaultEndpoint(Endpoint endpoint) { if (this.default_endpoint!=null) { this.default_endpoint.destroy(); } LOGGER.config(endpoint.getAddress()+" becomes default endpoint"); this.default_endpoint = endpoint; if (!this.default_endpoint.isStarted()) { try { default_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default endpoint", e); } } }
/** * Configures a new default secure endpoint. Any old default endpoint is destroyed. * @param endpoint the new default endpoint */ public void setDefaultSecureEndpoint(Endpoint endpoint) { if (this.default_secure_endpoint!=null) { this.default_secure_endpoint.destroy(); } this.default_secure_endpoint = endpoint; if (!this.default_secure_endpoint.isStarted()) { try { default_secure_endpoint.start(); LOGGER.log(Level.INFO, "Started new default secure endpoint " + default_secure_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default secure endpoint", e); } } }
/** * Configures a new default secure endpoint. Any old default endpoint is * destroyed. * * @param endpoint * the new default endpoint */ public synchronized void setDefaultSecureEndpoint(Endpoint endpoint) { if (this.default_secure_endpoint != null) { this.default_secure_endpoint.destroy(); } this.default_secure_endpoint = endpoint; if (!this.default_secure_endpoint.isStarted()) { try { default_secure_endpoint.start(); LOGGER.log(Level.INFO, "Started new default secure endpoint {0}", default_secure_endpoint.getAddress()); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default secure endpoint", e); } } }
/** * Configures a new default endpoint. Any old default endpoint is destroyed. * * @param endpoint * the new default endpoint */ public synchronized void setDefaultEndpoint(Endpoint endpoint) { if (this.default_endpoint != null) { this.default_endpoint.destroy(); } LOGGER.log(Level.CONFIG, "{0} becomes default endpoint", endpoint.getAddress()); this.default_endpoint = endpoint; if (!this.default_endpoint.isStarted()) { try { default_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new default endpoint", e); } } }
/** * Configures a new secure tcp endpoint to use by default. Any old tcp * endpoint is destroyed. * * @param endpoint * the new default secure tcp endpoint. */ public synchronized void setTcpEndpoint(Endpoint endpoint) { if (this.default_tcp_endpoint != null) { this.default_tcp_endpoint.destroy(); } LOGGER.log(Level.CONFIG, "{0} becomes tcp endpoint", endpoint.getAddress()); this.default_tcp_endpoint = endpoint; if (!this.default_tcp_endpoint.isStarted()) { try { default_tcp_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new tcp endpoint", e); } } }
/** * Configures a new secure tcp endpoint to use by default. Any old tcp * endpoint is destroyed. * * @param endpoint * the new default secure tcp endpoint. */ public synchronized void setSecureTcpEndpoint(Endpoint endpoint) { if (this.default_secure_tpc_endpoint != null) { this.default_secure_tpc_endpoint.destroy(); } LOGGER.log(Level.CONFIG, "{0} becomes secure tcp endpoint", endpoint.getAddress()); this.default_secure_tpc_endpoint = endpoint; if (!this.default_secure_tpc_endpoint.isStarted()) { try { default_secure_tpc_endpoint.start(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Could not start new secure tcp endpoint", e); } } }
@After public void destroyClient() throws Exception { clientEndpoint.destroy(); }
@After public void shutdownServer() { if (server != null) { server.destroy(); } if (client != null) { client.destroy(); } System.out.println(System.lineSeparator() + "End " + getClass().getSimpleName()); }
@After public void shutdownServer() { System.out.println(); server.destroy(); clientEndpoint.destroy(); middle.stop(); System.out.printf("End %s", getClass().getSimpleName()); }
@After public void shutdownEndpoints() { client.destroy(); server.destroy(); }
@After public void shutdownEndpoints() { client.destroy(); server.destroy(); }