@Override protected boolean tearDownServer(boolean force) { if (select == null || !select.isRunning()) { return true; } select.stopEndpoint(); return !select.isRunning(); }
@Override protected void setupServer(ClassLoader classLoader) { SelectorThread select = selectorThread(adapter(classLoader)); try { select.start(); } catch (Exception e) { throw new RemotingException(this + " failed to start", e); } }
private SelectorThread newSelector(GrizzlyAdapter adapter) { SelectorThread selectorThread = new SelectorThread(); Location location = getLocation(); if (location != null) { selectorThread.setInet(location.toInetAddress()); selectorThread.setPort(location.getPort()); } selectorThread.setKeepAliveTimeoutInSeconds(keepAliveSeconds); selectorThread.setCoreThreads(coreThreads); selectorThread.setMaxThreads(maxThreads); selectorThread.setAdapter(adapter); try { selectorThread.initEndpoint(); } catch (Exception e) { throw new RemotingException( this + " failed to set up selector thread " + selectorThread + " against " + adapter + "!", e); } return selectorThread; }
private int getLowLevelPort() { try { return select.getPortLowLevel(); } catch (Exception e) { log.warn(this + " failed to get low level port from " + select + ", using 0", e); return 0; } }
@AfterClass public static void afterClass() throws Exception { if (server != null) { server.stop(); server = null; } if (threadSelector != null) { threadSelector.stopEndpoint(); threadSelector = null; } }
@AfterClass public static void stopServer() throws Exception { selectorThread.stopEndpoint(); }
static { SelectorThread.setWebAppRootPath(root().getAbsolutePath()); }
private String getHostName() { InetAddress address = select.getAddress(); return address == null ? LOCALHOST : address.getHostName(); }