@Override /* Callable */ public T call() throws Exception { return getResponse(type, args); } }
@Override /* Callable */ public T call() throws Exception { return getResponse(type, args); } }
@Override /* Callable */ public T call() throws Exception { return getResponse(type); } }
@Override /* Callable */ public T call() throws Exception { return getResponse(type, args); } }
@Override /* Callable */ public T call() throws Exception { return getResponse(type); } }
@Override /* Callable */ public T call() throws Exception { return getResponse(type); } }
/** * Parses the output from the connection into the specified type and then wraps that in a {@link PojoRest}. * * <p> * Useful if you want to quickly retrieve a single value from inside of a larger JSON document. * * @param innerType The class type of the POJO being wrapped. * @return The parsed output wrapped in a {@link PojoRest}. * @throws IOException If a connection error occurred. * @throws ParseException * If the input contains a syntax error or is malformed for the <code>Content-Type</code> header. */ public PojoRest getResponsePojoRest(Class<?> innerType) throws IOException, ParseException { return new PojoRest(getResponse(innerType)); }
/** * Parses the output from the connection into the specified type and then wraps that in a {@link PojoRest}. * * <p> * Useful if you want to quickly retrieve a single value from inside of a larger JSON document. * * @param innerType The class type of the POJO being wrapped. * @return The parsed output wrapped in a {@link PojoRest}. * @throws IOException If a connection error occurred. * @throws ParseException * If the input contains a syntax error or is malformed for the <code>Content-Type</code> header. */ public PojoRest getResponsePojoRest(Class<?> innerType) throws IOException, ParseException { return new PojoRest(getResponse(innerType)); }
/** * Parses the output from the connection into the specified type and then wraps that in a {@link PojoRest}. * * <p> * Useful if you want to quickly retrieve a single value from inside of a larger JSON document. * * @param innerType The class type of the POJO being wrapped. * @return The parsed output wrapped in a {@link PojoRest}. * @throws IOException If a connection error occurred. * @throws ParseException * If the input contains a syntax error or is malformed for the <code>Content-Type</code> header. */ public PojoRest getResponsePojoRest(Class<?> innerType) throws IOException, ParseException { return new PojoRest(getResponse(innerType)); }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the value of * an HTTP header on the response. * * <p> * Useful if you're only interested in a particular header value from the response and not the body of the response. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @param name The header name. * @return The response header as a string, or <jk>null</jk> if the header was not found. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseHeader(String name) throws IOException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); return h == null ? null : h.getValue(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the value of * an HTTP header on the response. * * <p> * Useful if you're only interested in a particular header value from the response and not the body of the response. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @param name The header name. * @return The response header as a string, or <jk>null</jk> if the header was not found. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseHeader(String name) throws IOException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); return h == null ? null : h.getValue(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the value of * an HTTP header on the response. * * <p> * Useful if you're only interested in a particular header value from the response and not the body of the response. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @param name The header name. * @return The response header as a string, or <jk>null</jk> if the header was not found. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseHeader(String name) throws IOException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); return h == null ? null : h.getValue(); } catch (IOException e) { isFailed = true; close(); throw e; } }
StringBuilder sb = new StringBuilder(); HttpUriRequest req = restCall.getRequest(); HttpResponse res = restCall.getResponse(); if (req != null) { sb.append("\n=== HTTP Call (outgoing) =======================================================");
StringBuilder sb = new StringBuilder(); HttpUriRequest req = restCall.getRequest(); HttpResponse res = restCall.getResponse(); if (req != null) { sb.append("\n=== HTTP Call (outgoing) =======================================================");
/** * Same as {@link #getResponseHeader(String)} except parses the header value using the specified part parser and schema. * * @param name The header name. * @param partParser The part parser to use for parsing the header. * @param schema The part schema. Can be <jk>null</jk>. * @param type The type to convert the part into. * @param args The type arguments to convert the part into. * @return The parsed part. * @throws IOException * @throws ParseException */ public <T> T getResponseHeader(HttpPartParser partParser, HttpPartSchema schema, String name, Type type, Type...args) throws IOException, ParseException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); if (h == null) return null; String hs = h.getValue(); if (partParser == null) partParser = client.getPartParser(); return partParser.parse(schema, hs, type, args); } catch (IOException e) { isFailed = true; close(); throw e; } }
@Override /* InvocationHandler */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { RemoteInterfaceMethod rim = rm.getMethodMeta(method); if (rim == null) throw new RuntimeException("Method is not exposed as a remote method."); String url = rim.getUrl(); try (RestCall rc = doCall("POST", url, true)) { rc.serializer(serializer).parser(parser).body(args); Object v = rc.getResponse(method.getGenericReturnType()); if (v == null && method.getReturnType().isPrimitive()) v = ClassUtils.getPrimitiveDefault(method.getReturnType()); return v; } catch (RestCallException e) { // Try to throw original exception if possible. e.throwServerException(interfaceClass.getClassLoader(), method.getExceptionTypes()); throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } });
/** * Same as {@link #getResponseHeader(String)} except parses the header value using the specified part parser and schema. * * @param name The header name. * @param partParser The part parser to use for parsing the header. * @param schema The part schema. Can be <jk>null</jk>. * @param type The type to convert the part into. * @param args The type arguments to convert the part into. * @return The parsed part. * @throws IOException * @throws ParseException */ public <T> T getResponseHeader(HttpPartParser partParser, HttpPartSchema schema, String name, Type type, Type...args) throws IOException, ParseException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); if (h == null) return null; String hs = h.getValue(); if (partParser == null) partParser = client.getPartParser(); return partParser.parse(schema, hs, type, args); } catch (IOException e) { isFailed = true; close(); throw e; } }
@Override /* InvocationHandler */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { RemoteInterfaceMethod rim = rm.getMethodMeta(method); if (rim == null) throw new RuntimeException("Method is not exposed as a remote method."); String url = rim.getUrl(); try (RestCall rc = doCall("POST", url, true)) { rc.serializer(serializer).parser(parser).body(args); Object v = rc.getResponse(method.getGenericReturnType()); if (v == null && method.getReturnType().isPrimitive()) v = ClassUtils.getPrimitiveDefault(method.getReturnType()); return v; } catch (RestCallException e) { // Try to throw original exception if possible. e.throwServerException(interfaceClass.getClassLoader(), method.getExceptionTypes()); throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } });
@Override /* InvocationHandler */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { RemoteInterfaceMethod rim = rm.getMethodMeta(method); if (rim == null) throw new RuntimeException("Method is not exposed as a remote method."); String url = rim.getUrl(); try (RestCall rc = doCall("POST", url, true)) { rc.serializer(serializer).parser(parser).body(args); Object v = rc.getResponse(method.getGenericReturnType()); if (v == null && method.getReturnType().isPrimitive()) v = ClassUtils.getPrimitiveDefault(method.getReturnType()); return v; } catch (RestCallException e) { // Try to throw original exception if possible. e.throwServerException(interfaceClass.getClassLoader(), method.getExceptionTypes()); throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } });
/** * Same as {@link #getResponseHeader(String)} except parses the header value using the specified part parser and schema. * * @param name The header name. * @param partParser The part parser to use for parsing the header. * @param schema The part schema. Can be <jk>null</jk>. * @param type The type to convert the part into. * @param args The type arguments to convert the part into. * @return The parsed part. * @throws IOException * @throws ParseException */ public <T> T getResponseHeader(HttpPartParser partParser, HttpPartSchema schema, String name, Type type, Type...args) throws IOException, ParseException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); if (h == null) return null; String hs = h.getValue(); if (partParser == null) partParser = client.getPartParser(); return partParser.parse(schema, hs, type, args); } catch (IOException e) { isFailed = true; close(); throw e; } }