/** * Creates a list of service definitions. * * @param endpointDefinitions vararg array of service definitions * @return list of service definitions */ public static List<EndpointDefinition> serviceDefinitions(final EndpointDefinition... endpointDefinitions) { return Lists.list(endpointDefinitions); }
public static Response jsonRestCall( final String url ) { return Exceptions.tryIt(Response.class, new Exceptions.TrialWithReturn<Response>() { @Override public Response tryIt() throws Exception { URLConnection connection; connection = doGet(url, null, APPLICATION_JSON, null); return extractResponseObject(connection); } }); }
@Override public Iterable<String> valueMulti() { /* We could support this. */ //noinspection unchecked return die(Iterable.class, "NOT SUPPORTED"); }
private static String readErrorResponseBody(HttpURLConnection http, int status, String charset) { InputStream errorStream = http.getErrorStream(); if (errorStream != null) { String error = charset == null ? IO.read(errorStream) : IO.read(errorStream, charset); return Exceptions.die(String.class, "STATUS CODE =" + status + "\n\n" + error); } else { return Exceptions.die(String.class, "STATUS CODE =" + status); } }
@Override public void servicesRemoved(String serviceName, int count) { puts("servicesRemoved", serviceName, count); } };
public String method2(final String arg1, final int arg2, final float arg3, final double arg4) { return sputs(arg1, arg2, arg3, arg4); }
public void foo() { counter++; if (counter % 1000 == 0) { Sys.sleep(20); } } }
@Override public void listen(Event<Object> event) { puts(event); subscriberMessageCount++; } });
@SuppressWarnings("NullableProblems") @Override public Collection<String> values() { //noinspection unchecked return die(Collection.class, "Not supported"); }
public String hello(String arg, int arg2, float arg3) { return sputs(arg, arg2, arg3); } }
public static Response postBodyTextWithContentTypeReturnResponse(final String url, final String contentType, final String body) { return Exceptions.tryIt(Response.class, new Exceptions.TrialWithReturn<Response>() { @Override public Response tryIt() throws Exception { URLConnection connection; connection = doPost(url, null, contentType, null, body); return extractResponseObject(connection); } }); }
@Override public void listen(Event<Object> event) { puts(event); consumerCount++; } });
public static Response putBodyTextWithContentTypeReturnResponse(final String url, final String contentType, final String body) { return Exceptions.tryIt(Response.class, new Exceptions.TrialWithReturn<Response>() { @Override public Response tryIt() throws Exception { URLConnection connection; connection = doPut(url, null, contentType, null, body); return extractResponseObject(connection); } }); }
@Override public void receive(String item) { puts(item); synchronized (counter) { counter[0]++; } }
public static String postForm(final String url, final Map<String, ?> headers, final Map<String, Object> formData ) { return Exceptions.tryIt(String.class, new Exceptions.TrialWithReturn<String>() { @Override public String tryIt() throws Exception { URLConnection connection; connection = doPostFormData(url, headers, formData); return extractResponseString(connection); } }); }
@Override public void accept(Long integer) { puts("Last ten second count for abc.count", integer); } }, "abc.count");
@Override public void servicesRemoved(String serviceName, int count) { puts("servicesRemoved", serviceName, count); } };