@Override public void upgradeHTTP2(Request request, SettingsFrame settings, Promise<HTTP2ClientConnection> promise, ClientHTTPHandler upgradeHandler, ClientHTTPHandler http2ResponseHandler) { throw new CommonRuntimeException("The current connection version is http2, it does not need to upgrading."); }
@Override public void upgradeWebSocket(Request request, WebSocketPolicy policy, Promise<WebSocketConnection> promise, ClientHTTPHandler upgradeHandler, IncomingFrames incomingFrames) { throw new CommonRuntimeException("The current connection version is http2, it can not upgrade WebSocket."); }
@Override public void upgradeHTTP2(Request request, SettingsFrame settings, Promise<HTTP2ClientConnection> promise, ClientHTTPHandler upgradeHandler, ClientHTTPHandler http2ResponseHandler) { throw new CommonRuntimeException("The current connection version is http2, it does not need to upgrading."); }
@Override public void upgradeWebSocket(Request request, WebSocketPolicy policy, Promise<WebSocketConnection> promise, ClientHTTPHandler upgradeHandler, IncomingFrames incomingFrames) { throw new CommonRuntimeException("The current connection version is http2, it can not upgrade WebSocket."); }
private static Class<?> getClass(String name) { try { return Class.forName(name, false, classLoader); } catch (ClassNotFoundException e) { throw new CommonRuntimeException(e); } }
private static URI toURI(String name) { try { return new URI(name); } catch (URISyntaxException e) { throw new CommonRuntimeException(e); } }
private static URI toURI(String name) { try { return new URI(name); } catch (URISyntaxException e) { throw new CommonRuntimeException(e); } }
@Override public Document getDocument(String file) { try (InputStream is = DefaultDom.class.getResourceAsStream("/" + file)) { if (is == null) { throw new CommonRuntimeException("the configuration file: " + file + " is not found"); } Document doc = db.parse(is); return doc; } catch (Exception e) { throw new CommonRuntimeException(e); } }
private static Class<?> getClass(String name) { try { return Class.forName(name, false, classLoader); } catch (ClassNotFoundException e) { throw new CommonRuntimeException(e); } }
@Override public Document getDocument(String file) { try (InputStream is = DefaultDom.class.getResourceAsStream("/" + file)) { if (is == null) { throw new CommonRuntimeException("the configuration file: " + file + " is not found"); } Document doc = db.parse(is); return doc; } catch (Exception e) { throw new CommonRuntimeException(e); } }
public DefaultDom() { try { db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new CommonRuntimeException(e); } }
public DefaultDom() { try { db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new CommonRuntimeException(e); } }
public StaticResourceHandler() { try { Path path = Paths.get(SysRouterInstaller.class.getResource("/").toURI()); staticFileHandler = new StaticFileHandler(path.toAbsolutePath().toString()); } catch (Exception e) { throw new CommonRuntimeException(e); } }
private void shutdown() { try { shutdown = true; workQueue.put(new ShutdownCommand()); } catch (InterruptedException e) { throw new CommonRuntimeException(e); } }
private void shutdown() { try { shutdown = true; workQueue.put(new ShutdownCommand()); } catch (InterruptedException e) { throw new CommonRuntimeException(e); } }
public Object copyOf(List<Object> list) { Object ret = Array.newInstance(elementMetaInfo.getExtractedType(), list.size()); for (int i = 0; i < list.size(); i++) { try { ReflectUtils.arraySet(ret, i, list.get(i)); } catch (Throwable e) { throw new CommonRuntimeException(e); } } return ret; }
public Object copyOf(List<Object> list) { Object ret = Array.newInstance(elementMetaInfo.getExtractedType(), list.size()); for (int i = 0; i < list.size(); i++) { try { ReflectUtils.arraySet(ret, i, list.get(i)); } catch (Throwable e) { throw new CommonRuntimeException(e); } } return ret; }
public static String toJson(Object obj) { try (JsonWriter writer = new JsonStringWriter()) { SerialStateMachine.toJson(obj, writer); return writer.toString(); } catch (IOException e) { throw new CommonRuntimeException(e); } }
public static Object construct(Class<?> klass, Object[] arguments) throws InvocationTargetException, NoSuchMethodException { Objects.requireNonNull(klass, "Class cannot be null"); for (Constructor<?> constructor : klass.getConstructors()) { if (arguments == null) { // null arguments in .newInstance() is allowed if (constructor.getParameterCount() != 0) continue; } else if (constructor.getParameterCount() != arguments.length) continue; try { return constructor.newInstance(arguments); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException e) { throw new CommonRuntimeException(e); } } throw new NoSuchMethodException("<init>"); }
public static String toJson(Object obj) { try (JsonWriter writer = new JsonStringWriter()) { SerialStateMachine.toJson(obj, writer); return writer.toString(); } catch (IOException e) { throw new CommonRuntimeException(e); } }