users@jersey.java.net

[Jersey] Re: How to send a client POST with both class type and callback

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Thu, 1 Oct 2015 20:05:50 +0200

Hi Raul,

just put the type as a generic parameter of the callback:

new InvocationCallback<MyClass>() { @Override public void
completed(MyClass myClass) { } @Override public void failed(Throwable
throwable) { } });

then you are notified when the action (response is received and read) is
completed or when the error occurs.

Hope it helps,
Pavel


On 01/10/15 19:37, Raúl Guerrero Deschamps wrote:
> Hi,
>
> I'm trying to do a client post using something like:
> client
> .target(url)
> .async()
> .post(Entity.entity(myObject, MediaType.APPLICATION_JSON),
> MyClass.class));
>
> But I want to be able to also specify an InvocationCallback to see the
> server's response, but seeing the API signatures, I see that there is
> no way of doing that, I only have the following options:
> post(entity)
> post(entity, class)
> post(entity, callback)
>
> There is not one that specifies something like post(entity, class,
> callback) and this is a problem, because if I don't specify the class,
> I get a 400 error, and if I specify only entity and class, how can I
> specify a callback to handle something like an error?
>
> Thanks,
>
> Raul