public static JarEntry jarEntry(URL url, $.Var<JarFile> jarFileBag) { E.illegalArgumentIfNot("jar".equals(url.getProtocol()), "jar URL expected"); String path = url.getPath(); E.unexpectedIfNot(path.startsWith("file:"), "Expected `file:` prefix in the path, found: " + path); E.unexpectedIfNot(path.contains("!"), "`!` not found in the path: " + path); S.Pair pair = S.binarySplit(path, '!'); String jarFilePath = pair.left().substring(5); String entryPath = pair.right(); try { JarFile jarFile = new JarFile(jarFilePath); jarFileBag.set(jarFile); if (entryPath.startsWith("/")) { entryPath = entryPath.substring(1); } return jarFile.getJarEntry(entryPath); } catch (IOException e) { throw E.ioException(e); } }
public static JarEntry jarEntry(URL url, $.Var<JarFile> jarFileBag) { E.illegalArgumentIfNot("jar".equals(url.getProtocol()), "jar URL expected"); String path = url.getPath(); E.unexpectedIfNot(path.startsWith("file:"), "Expected `file:` prefix in the path, found: " + path); E.unexpectedIfNot(path.contains("!"), "`!` not found in the path: " + path); S.Pair pair = S.binarySplit(path, '!'); String jarFilePath = pair.left().substring(5); String entryPath = pair.right(); try { JarFile jarFile = new JarFile(jarFilePath); jarFileBag.set(jarFile); if (entryPath.startsWith("/")) { entryPath = entryPath.substring(1); } return jarFile.getJarEntry(entryPath); } catch (IOException e) { throw E.ioException(e); } }
private Link cascadeWith(Link downstream, TypeConverterRegistry registry) { E.unexpectedIfNot(downstream.isSource(this.to)); $.TypeConverter chained = new ChainedConverter(this.converter, downstream.converter); return new Link(chained, registry); }
private Link cascadeWith(Link downstream, TypeConverterRegistry registry) { E.unexpectedIfNot(downstream.isSource(this.to)); $.TypeConverter chained = new ChainedConverter(this.converter, downstream.converter); return new Link(chained, registry); }
public JPADao() { DB db = modelType().getAnnotation(DB.class); String svcId = null == db ? DEFAULT : db.value(); DbServiceManager dbm = Act.app().dbServiceManager(); DbService dbService = dbm.dbService(svcId); E.invalidConfigurationIf(null == dbService, "cannot find db service by id: %s", svcId); E.unexpectedIfNot(dbService instanceof JPAService, "expected JPAService, found: " + dbService.getClass().getSimpleName()); setJPAService((JPAService) dbService); }
/** * Implement Java Servlet's `RequestDispatcher.forward(String)` semantic. * * This method has the following restrictions: * * 1. the URL must be started with single `/`. i.e. it must be absolute PATH of current service. * 2. the request method must be `GET`. * * @param url * the url template * @param args * the url argument */ public void forward(String url, Object... args) { E.illegalArgumentIfNot(url.startsWith("/"), "forward URL must starts with single '/'"); E.illegalArgumentIf(url.startsWith("//"), "forward URL must starts with single `/`"); E.unexpectedIfNot(H.Method.GET == req().method(), "forward only support on HTTP GET request"); uploads.clear(); extraParams.clear(); bodyParams = null; String target = S.fmt(url, args); urlPath = UrlPath.of(target); UndertowRequest req = $.cast(req()); state = State.CREATED; req.forward(target); final RequestHandler requestHandler = router.getInvoker(H.Method.GET, url, this); requestHandler.handle(this); }
/** * Implement Java Servlet's `RequestDispatcher.forward(String)` semantic. * * This method has the following restrictions: * * 1. the URL must be started with single `/`. i.e. it must be absolute PATH of current service. * 2. the request method must be `GET`. * * @param url * the url template * @param args * the url argument */ public void forward(String url, Object... args) { E.illegalArgumentIfNot(url.startsWith("/"), "forward URL must starts with single '/'"); E.illegalArgumentIf(url.startsWith("//"), "forward URL must starts with single `/`"); E.unexpectedIfNot(H.Method.GET == req().method(), "forward only support on HTTP GET request"); uploads.clear(); extraParams.clear(); bodyParams = null; String target = S.fmt(url, args); urlPath = UrlPath.of(target); UndertowRequest req = $.cast(req()); state = State.CREATED; req.forward(target); final RequestHandler requestHandler = router.getInvoker(H.Method.GET, url, this); requestHandler.handle(this); }