org.glassfish.grizzly.utils.Charsets Java Examples
The following examples show how to use
org.glassfish.grizzly.utils.Charsets.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BritishUSFilter.java From lumongo with Apache License 2.0 | 6 votes |
private static CharArrayMap<char[]> initializeDictHash() { CharArrayMap<char[]> charMap = new CharArrayMap<>(2000, false); try { URL url = Resources.getResource(BritishUSFilter.class, "british.txt"); String text = Resources.toString(url, Charsets.UTF8_CHARSET); String[] lines = text.split("\n"); for (String line : lines) { if (!line.startsWith("UK\tUS")) { String[] parts = line.split("\t"); if (parts.length == 2) { charMap.put(parts[0].toCharArray(), parts[1].toCharArray()); } } } } catch (Exception e) { throw new RuntimeException(e); } return charMap; }
Example #2
Source File: JsonRpcServer.java From nuls-v2 with MIT License | 5 votes |
public void startServer(String ip, int port) { initRpcMethodHandlers(); this.httpServer = new HttpServer(); NetworkListener listener = new NetworkListener("NULS-RPC", ip, port); TCPNIOTransport transport = listener.getTransport(); ThreadPoolConfig workerPool = ThreadPoolConfig.defaultConfig() .setCorePoolSize(8) .setMaxPoolSize(8) .setQueueLimit(2000) .setThreadFactory((new ThreadFactoryBuilder()).setNameFormat("grizzly-http-server-%d").build()); transport.configureBlocking(false); transport.setSelectorRunnersCount(2); transport.setWorkerThreadPoolConfig(workerPool); transport.setIOStrategy(WorkerThreadIOStrategy.getInstance()); transport.setTcpNoDelay(true); listener.setSecure(false); httpServer.addListener(listener); ServerConfiguration config = httpServer.getServerConfiguration(); config.addHttpHandler(new JsonRpcHandler()); config.setDefaultQueryEncoding(Charsets.UTF8_CHARSET); try { httpServer.start(); } catch (IOException e) { LoggerUtil.commonLog.error(e); httpServer.shutdownNow(); } }
Example #3
Source File: RpcServerManager.java From nuls-v2 with MIT License | 5 votes |
public void startServer(String ip, int port) { URI serverURI = UriBuilder.fromUri("http://" + ip).port(port).build(); // Create test web application context. WebappContext webappContext = new WebappContext("NULS-V2-SDK-PROVIDER-SERVER", "/"); ServletRegistration servletRegistration = webappContext.addServlet("jersey-servlet", ServletContainer.class); servletRegistration.setInitParameter("javax.ws.rs.Application", "io.nuls.provider.api.config.NulsResourceConfig"); servletRegistration.addMapping("/*"); httpServer = new HttpServer(); NetworkListener listener = new NetworkListener("grizzly2", ip, port); TCPNIOTransport transport = listener.getTransport(); ThreadPoolConfig workerPool = ThreadPoolConfig.defaultConfig() .setCorePoolSize(4) .setMaxPoolSize(4) .setQueueLimit(1000) .setThreadFactory((new ThreadFactoryBuilder()).setNameFormat("grizzly-http-server-%d").build()); transport.configureBlocking(false); transport.setSelectorRunnersCount(2); transport.setWorkerThreadPoolConfig(workerPool); transport.setIOStrategy(WorkerThreadIOStrategy.getInstance()); transport.setTcpNoDelay(true); listener.setSecure(false); httpServer.addListener(listener); ServerConfiguration config = httpServer.getServerConfiguration(); config.setDefaultQueryEncoding(Charsets.UTF8_CHARSET); webappContext.deploy(httpServer); try { ClassLoader loader = this.getClass().getClassLoader(); httpServer.start(); Log.info("http restFul server is started!url is " + serverURI.toString()); } catch (IOException e) { Log.error(e); httpServer.shutdownNow(); } }
Example #4
Source File: RpcServerManager.java From nuls-v2 with MIT License | 4 votes |
public void startServer(String ip, int port) { URI serverURI = UriBuilder.fromUri("http://" + ip).port(port).build(); // Create test web application context. WebappContext webappContext = new WebappContext("NULS-RPC-SERVER", "/api"); ServletRegistration servletRegistration = webappContext.addServlet("jersey-servlet", ServletContainer.class); servletRegistration.setInitParameter("javax.ws.rs.Application", "io.nuls.test.controller.NulsResourceConfig"); servletRegistration.addMapping("/api/*"); httpServer = new HttpServer(); NetworkListener listener = new NetworkListener("grizzly2", ip, port); TCPNIOTransport transport = listener.getTransport(); ThreadPoolConfig workerPool = ThreadPoolConfig.defaultConfig() .setCorePoolSize(4) .setMaxPoolSize(4) .setQueueLimit(1000) .setThreadFactory((new ThreadFactoryBuilder()).setNameFormat("grizzly-http-server-%d").build()); transport.configureBlocking(false); transport.setSelectorRunnersCount(2); transport.setWorkerThreadPoolConfig(workerPool); transport.setIOStrategy(WorkerThreadIOStrategy.getInstance()); transport.setTcpNoDelay(true); listener.setSecure(false); httpServer.addListener(listener); ServerConfiguration config = httpServer.getServerConfiguration(); config.setDefaultQueryEncoding(Charsets.UTF8_CHARSET); webappContext.deploy(httpServer); try { ClassLoader loader = this.getClass().getClassLoader(); addSwagerUi(loader); addClientUi(loader); httpServer.start(); log.info("http restFul server is started!url is " + serverURI.toString()); } catch (IOException e) { log.error("",e); httpServer.shutdownNow(); } }
Example #5
Source File: RpcServerManager.java From nuls with MIT License | 4 votes |
public void startServer(String ip, int port) { URI serverURI = UriBuilder.fromUri("http://" + ip).port(port).build(); // Create test web application context. WebappContext webappContext = new WebappContext("NULS-RPC-SERVER", "/api"); ServletRegistration servletRegistration = webappContext.addServlet("jersey-servlet", ServletContainer.class); servletRegistration.setInitParameter("javax.ws.rs.Application", "io.nuls.client.rpc.config.NulsResourceConfig"); servletRegistration.addMapping("/api/*"); httpServer = new HttpServer(); NetworkListener listener = new NetworkListener("grizzly2", ip, port); TCPNIOTransport transport = listener.getTransport(); ThreadPoolConfig workerPool = ThreadPoolConfig.defaultConfig() .setCorePoolSize(4) .setMaxPoolSize(4) .setQueueLimit(1000) .setThreadFactory((new ThreadFactoryBuilder()).setNameFormat("grizzly-http-server-%d").build()); transport.configureBlocking(false); transport.setSelectorRunnersCount(2); transport.setWorkerThreadPoolConfig(workerPool); transport.setIOStrategy(WorkerThreadIOStrategy.getInstance()); transport.setTcpNoDelay(true); listener.setSecure(false); httpServer.addListener(listener); ServerConfiguration config = httpServer.getServerConfiguration(); config.setDefaultQueryEncoding(Charsets.UTF8_CHARSET); webappContext.deploy(httpServer); try { ClassLoader loader = this.getClass().getClassLoader(); addSwagerUi(loader); addClientUi(loader); httpServer.start(); Log.info("http restFul server is started!url is " + serverURI.toString()); } catch (IOException e) { Log.error(e); httpServer.shutdownNow(); } }