List of usage examples for com.google.common.io Resources getResource
public static URL getResource(Class<?> contextClass, String resourceName)
From source file:li.klass.fhem.service.room.xmllist.Sanitiser.java
@Inject public Sanitiser() { try {// w w w . ja v a 2s. com options = new JSONObject(Resources .toString(Resources.getResource(Sanitiser.class, "deviceSanitiser.json"), Charsets.UTF_8)); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.facebook.swift.generator.util.TemplateLoader.java
protected StringTemplateGroup getTemplateGroup() throws IOException { if (stg == null) { final URL resourceUrl = Resources.getResource(this.getClass(), "/templates/" + templateFileName); final InputSupplier<InputStreamReader> is = Resources.newReaderSupplier(resourceUrl, Charsets.UTF_8); stg = new StringTemplateGroup(is.getInput(), AngleBracketTemplateLexer.class, ERROR_LISTENER); }//from w w w . j av a2 s. com return stg; }
From source file:org.sonar.server.qualitygate.ws.QGatesSearchAction.java
void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("search") .setDescription("Search for projects associated (or not) to a quality gate").setSince("4.3") .setResponseExample(Resources.getResource(this.getClass(), "example-search.json")).setHandler(this); action.createParam(QGatesWs.PARAM_GATE_ID).setDescription("Quality Gate ID").setRequired(true) .setExampleValue("1"); action.createParam(QGatesWs.PARAM_QUERY).setDescription( "To search for projects containing this string. If this parameter is set, \"selected\" is set to \"all\".") .setExampleValue("abc"); action.createParam(QGatesWs.PARAM_SELECTED) .setDescription("If \"selected\", search for projects associated to the quality gate") .setDefaultValue(ProjectQgateAssociationQuery.IN) .setPossibleValues(ProjectQgateAssociationQuery.AVAILABLE_MEMBERSHIP) .setExampleValue(ProjectQgateAssociationQuery.OUT); action.createParam(QGatesWs.PARAM_PAGE).setDescription("Page number").setDefaultValue("1") .setExampleValue("2"); action.createParam(QGatesWs.PARAM_PAGE_SIZE).setDescription("Page size").setExampleValue("10"); }
From source file:org.sonar.server.issue.ws.IssuesWs.java
private static void defineChangelogAction(NewController controller) { WebService.NewAction action = controller.createAction(CHANGELOG_ACTION) .setDescription("Display changelog of an issue").setSince("4.1").setHandler(RailsHandler.INSTANCE) .setResponseExample(Resources.getResource(IssuesWs.class, "example-changelog.json")); action.createParam("issue").setDescription("Key of the issue").setRequired(true) .setExampleValue("5bccd6e8-f525-43a2-8d76-fcb13dde79ef"); RailsHandler.addFormatParam(action); }
From source file:org.apache.isis.core.runtime.services.menu.MenuBarsLoaderServiceDefault.java
@Override public MenuBars menuBars() { final AppManifest appManifest = isisSessionFactory.getAppManifest(); final URL resource = Resources.getResource(appManifest.getClass(), "menubars.layout.xml"); try {/*from w ww . ja va2 s . com*/ String xml = Resources.toString(resource, Charsets.UTF_8); return jaxbService.fromXml(MenuBars.class, xml); } catch (IOException e) { return null; } }
From source file:org.sonar.server.issue.filter.AppAction.java
void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("app"); action.setDescription("Data required for rendering the page 'Issues'").setInternal(true).setHandler(this) .setResponseExample(Resources.getResource(this.getClass(), "app-example-show.json")); action.createParam("id").setDescription("Optionally, the ID of the current filter"); }
From source file:org.apache.isis.core.runtime.services.menubars.MenuBarsLoaderServiceDefault.java
@Override public BS3MenuBars menuBars() { final AppManifest appManifest = isisSessionFactory.getAppManifest(); try {/*from w w w . ja v a 2 s . c om*/ final URL resource = Resources.getResource(appManifest.getClass(), "menubars.layout.xml"); String xml = Resources.toString(resource, Charsets.UTF_8); return jaxbService.fromXml(BS3MenuBars.class, xml); } catch (Exception e) { return null; } }
From source file:org.sonar.server.qualitygate.ws.ShowAction.java
@Override public void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("show") .setDescription("Display the details of a quality gate").setSince("4.3") .setResponseExample(Resources.getResource(this.getClass(), "example-show.json")).setHandler(this); action.createParam(QualityGatesWsParameters.PARAM_ID) .setDescription("ID of the quality gate. Either id or name must be set").setExampleValue("1"); action.createParam(QualityGatesWsParameters.PARAM_NAME) .setDescription("Name of the quality gate. Either id or name must be set") .setExampleValue("My Quality Gate"); }
From source file:org.sonar.server.qualitygate.ws.QGatesShowAction.java
void define(WebService.NewController controller) { WebService.NewAction action = controller.createAction("show") .setDescription("Display the details of a quality gate").setSince("4.3") .setResponseExample(Resources.getResource(this.getClass(), "example-show.json")).setHandler(this); action.createParam(QGatesWs.PARAM_ID) .setDescription("ID of the quality gate. Either id or name must be set").setExampleValue("1"); action.createParam(QGatesWs.PARAM_NAME) .setDescription("Name of the quality gate. Either id or name must be set") .setExampleValue("My Quality Gate"); }
From source file:org.apache.aurora.scheduler.http.LeaderRedirectFilter.java
private void sendServiceUnavailable(HttpServletResponse response) throws IOException { response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); Resources.asByteSource(Resources.getResource(LeaderRedirectFilter.class, NO_LEADER_PAGE)) .copyTo(response.getOutputStream()); }