protected URL getResource(String resourceName) { return MoreResources.getResource(resourceName, false); }
protected Map<String, RestxSpec> buildSpecsMap(boolean searchInSources) { Map<String, RestxSpec> specsMap = Maps.newLinkedHashMap(); Map<String, URL> specs = MoreResources.findResources("", Pattern.compile(".*\\.spec\\.yaml"), searchInSources); for (final Map.Entry<String, URL> spec : specs.entrySet()) { try { specsMap.put(spec.getKey(), specLoader.load(spec.getKey(), new CharSource() { @Override public Reader openStream() throws IOException { return new InputStreamReader(spec.getValue().openStream(), Charsets.UTF_8); } })); } catch (Exception e) { logger.warn("exception while loading restx spec " + spec + ": " + e, e); } } return specsMap; }
Set<Path> sourceRoots = findSourceRoots(); for (final Path sourceRoot : sourceRoots) { try {
public static Archetype buildArchetype(String packageName) { Map<String,URL> resources = MoreResources.findResources(packageName, Pattern.compile(".*"), true); ImmutableList.Builder<ArchetypeEntry> builder = ImmutableList.builder(); for (String r : resources.keySet()) { if (r.substring(r.lastIndexOf('/') + 1).startsWith("_")) { builder.add(buildTemplate(packageName.replace('.', '/') + '/', r.substring(packageName.length() + 1))); } else { builder.add(new StaticArchetypeEntry(r.substring(packageName.length() + 1), Resources.asByteSource(Resources.getResource(r)))); } } return new Archetype(builder.build()); }
Set<Path> sourceRoots = findSourceRoots(); for (final Path sourceRoot : sourceRoots) { try {
protected URL getResource(String resourceName) { return MoreResources.getResource(resourceName, true); }
protected Map<String, RestxSpec> buildSpecsMap(boolean searchInSources) { Map<String, RestxSpec> specsMap = Maps.newLinkedHashMap(); Map<String, URL> specs = MoreResources.findResources("", Pattern.compile(".*\\.spec\\.yaml"), searchInSources); for (final Map.Entry<String, URL> spec : specs.entrySet()) { try { specsMap.put(spec.getKey(), specLoader.load(spec.getKey(), new CharSource() { @Override public Reader openStream() throws IOException { return new InputStreamReader(spec.getValue().openStream(), Charsets.UTF_8); } })); } catch (Exception e) { logger.warn("exception while loading restx spec " + spec + ": " + e, e); } } return specsMap; }
public RestxSpec load(String resource) throws IOException { return load(resource, Resources.asCharSource( MoreResources.getResource(resource, true), Charsets.UTF_8)); }
public static Archetype buildArchetype(String packageName) { Map<String,URL> resources = MoreResources.findResources(packageName, Pattern.compile(".*"), true); ImmutableList.Builder<ArchetypeEntry> builder = ImmutableList.builder(); for (String r : resources.keySet()) { if (r.substring(r.lastIndexOf('/') + 1).startsWith("_")) { builder.add(buildTemplate(packageName.replace('.', '/') + '/', r.substring(packageName.length() + 1))); } else { builder.add(new StaticArchetypeEntry(r.substring(packageName.length() + 1), Resources.asByteSource(Resources.getResource(r)))); } } return new Archetype(builder.build()); }
public RestxSpec load(String resource) throws IOException { return load(resource, Resources.asCharSource( MoreResources.getResource(resource, true), Charsets.UTF_8)); }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { String relativePath = this.requestRelativePath(req); relativePath = Optional.fromNullable(aliases.get(relativePath)).or(relativePath); try { URL resource = MoreResources.getResource( baseResourcePath + relativePath, RestxContext.Modes.DEV.equals(ctx.getMode()) || RestxContext.Modes.TEST.equals(ctx.getMode()) || RestxContext.Modes.INFINIREST.equals(ctx.getMode()) ); serveCacheableResource(resp, resource, relativePath); } catch (IllegalArgumentException e) { notFound(resp, relativePath); } }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { String relativePath = this.requestRelativePath(req); relativePath = Optional.fromNullable(aliases.get(relativePath)).or(relativePath); try { URL resource = MoreResources.getResource( baseResourcePath + relativePath, RestxContext.Modes.DEV.equals(ctx.getMode()) || RestxContext.Modes.TEST.equals(ctx.getMode()) || RestxContext.Modes.INFINIREST.equals(ctx.getMode()) ); serveCacheableResource(resp, resource, relativePath); } catch (IllegalArgumentException e) { notFound(resp, relativePath); } }