Re: [Resteasy-users] Pool for javax.ws.rs.client.Client objects?

2014-10-27 Thread Rodrigo Uchôa
if Client implementations are thread-safe, shouldn't a single instance be
enough? Thus having a single instance for the whole app would do it. I
don't think it's the case.

On Mon, Oct 27, 2014 at 10:21 PM, Savvas Andreas Moysidis <
savvas.andreas.moysi...@gmail.com> wrote:

> The question, I suppose, is whether Client implementations are thread-safe
> or not which is something that is not stipulated by the interface contract.
>
> If they are(something which is sort of implied by the javadoc), then you
> could maybe declare and use a single instance like the following? (in a
> JavaEE context)
>
> @Singleton
> public class SomeService {
>
> private Client restClient;
>
> @PostConstruct
> private void init() {
> restClient = ClientBuilder.newClient();
> }
> .
> // Use restClient object here
> .
>
> @PreDestroy
> private void cleanUp() {
> restClient.close();
> }
> }
>
> On 27 October 2014 23:24, Mario Diana  wrote:
>
>> I'd be interested in hearing what common practice is regarding pooled
>> Client objects, too. Do people use the Apache objects pool library? That's
>> the only option I've heard of. Are there other mainstream solutions?
>>
>> Mario
>>
>> > On Oct 27, 2014, at 12:39 PM, Rodrigo Uchôa 
>> wrote:
>> >
>> > [...]
>>
>> > How should we implement a pool of Client objects in this scenario? Is
>> there a common solution?
>> >
>> > Regards,
>> > Rodrigo Uchoa.
>>
>>
>>
>> --
>> ___
>> Resteasy-users mailing list
>> Resteasy-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>
>
>
>
> --
>
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
>
--
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Pool for javax.ws.rs.client.Client objects?

2014-10-27 Thread Savvas Andreas Moysidis
The question, I suppose, is whether Client implementations are thread-safe
or not which is something that is not stipulated by the interface contract.

If they are(something which is sort of implied by the javadoc), then you
could maybe declare and use a single instance like the following? (in a
JavaEE context)

@Singleton
public class SomeService {

private Client restClient;

@PostConstruct
private void init() {
restClient = ClientBuilder.newClient();
}
.
// Use restClient object here
.

@PreDestroy
private void cleanUp() {
restClient.close();
}
}

On 27 October 2014 23:24, Mario Diana  wrote:

> I'd be interested in hearing what common practice is regarding pooled
> Client objects, too. Do people use the Apache objects pool library? That's
> the only option I've heard of. Are there other mainstream solutions?
>
> Mario
>
> > On Oct 27, 2014, at 12:39 PM, Rodrigo Uchôa 
> wrote:
> >
> > [...]
>
> > How should we implement a pool of Client objects in this scenario? Is
> there a common solution?
> >
> > Regards,
> > Rodrigo Uchoa.
>
>
>
> --
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Pool for javax.ws.rs.client.Client objects?

2014-10-27 Thread Mario Diana
I'd be interested in hearing what common practice is regarding pooled Client 
objects, too. Do people use the Apache objects pool library? That's the only 
option I've heard of. Are there other mainstream solutions?

Mario

> On Oct 27, 2014, at 12:39 PM, Rodrigo Uchôa  wrote:
> 
> [...]

> How should we implement a pool of Client objects in this scenario? Is there a 
> common solution?
> 
> Regards,
> Rodrigo Uchoa.


--
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] Pool for javax.ws.rs.client.Client objects?

2014-10-27 Thread Rodrigo Uchôa
Hi guys!

I have a client web application that uses the Client API to make REST calls
to a REST business layer.

The javax.ws.rs.client.Client docs clearly states that Client objects are
expensive to create and dispose, and only a small number of them should be
created, which makes me think they should be pooled somehow.

Our initial thought was to instantiate and then close every Client object
we use, making code like this:

public void doSomething() {
Client client = ClientBuilder.newClient();
//do a bunch of stuff here
client.close();
}

Every method that needs to invoke REST services are coded like the example
above. That means every time a client web request comes in, a new Client
object is created and then closed. The exact opposite of what the docs
advises us to do.

How should we implement a pool of Client objects in this scenario? Is there
a common solution?

Regards,
Rodrigo Uchoa.
--
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users