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

2014-10-29 Thread Bill Burke
By default, Resteasy only allows one connection per Client.  You have to 
use ResteadyClient(Builder) to expand this.  Other than that, it should 
be threadsafe.

Personally, I'd create the Client as an application-scoped CDI bean and 
inject it, or create one with SPring and inject it, or create one in a 
servlet listener and add it to ServletContext.  If you create per 
request, then you lose any socket connection pooling that Apache Http 
Client does.

On 10/27/2014 8:21 PM, Savvas Andreas Moysidis 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 mariodi...@gmail.com
 mailto:mariodi...@gmail.com 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
 rodrigo.uc...@gmail.com mailto:rodrigo.uc...@gmail.com 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
 mailto: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


-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

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


[Resteasy-users] Use Resteasy server-side Cache

2014-10-29 Thread Frederic Eßer
Hello everyone,

I develop a software which provides webservices on a tomcat. These webservices 
parse and display data from a 3rd website with JSOUP in XML or JSON format. 
Now I want to use the server-side caching to reduce the requests be made to 
these websites.
The Project is managed with Maven and I'm using the 3.0.6.Final version of 
resteasy and it will all be deployed on an integrated Tomcat 7 for testing 
purposes. 

While researching on how to get the caching into my project I stumbled upon 
this link 
http://docs.jboss.org/resteasy/docs/1.1.GA/userguide/html/Cache_NoCache_CacheControl.html
 which I thought contained everything I needed. So I added the dependency to my 
pom

dependency
groupIdorg.jboss.resteasy/groupId
artifactIdresteasy-cache-core/artifactId
version3.0.9.Final/version
/dependency

and added the context parameter to my web.xml

context-param
param-nameresteasy.server.cache.maxsize/param-name
param-value1000/param-value
/context-param

context-param
param-nameresteasy.server.cache.eviction.wakeup.interval/param-name
param-value5000/param-value
/context-param

listener

listener-classorg.jboss.resteasy.plugins.cache.server.ServletServerCache/listener-class
/listener

But while trying to run the project on my server I get the following exception

SEVERE: Error configuring application listener of class 
org.jboss.resteasy.plugins.cache.server.ServletServerCache
java.lang.ClassNotFoundException: 
org.jboss.resteasy.plugins.cache.server.ServletServerCache
at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at 
org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at 
org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at 
org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at 
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638)
at 
org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
at 
org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

So I build the war with Maven - build and checked for the jar file in 
WEB-INF/lib/ and found the resteasy-cache-core-3.0.9.Final.jar.

What is going wrong? Or is the way on approaching the server-side cache 
implementation wrong?

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


Re: [Resteasy-users] Use Resteasy server-side Cache

2014-10-29 Thread Bill Burke
Implementation was refactored and reimplemneted in 3.0:

http://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html/Cache_NoCache_CacheControl.html#server_cache

On 10/29/2014 1:35 PM, Frederic Eßer wrote:
 Hello everyone,

 I develop a software which provides webservices on a tomcat. These
 webservices parse and display data from a 3rd website with JSOUP in XML
 or JSON format.
 Now I want to use the server-side caching to reduce the requests be made
 to these websites.
 The Project is managed with Maven and I'm using the 3.0.6.Final version
 of resteasy and it will all be deployed on an integrated Tomcat 7 for
 testing purposes.

 While researching on how to get the caching into my project I stumbled
 upon this link
 http://docs.jboss.org/resteasy/docs/1.1.GA/userguide/html/Cache_NoCache_CacheControl.html
 which I thought contained everything I needed. So I added the dependency
 to my pom

  dependency
  groupIdorg.jboss.resteasy/groupId
  artifactIdresteasy-cache-core/artifactId
  version3.0.9.Final/version
  /dependency

 and added the context parameter to my web.xml

  context-param
  param-nameresteasy.server.cache.maxsize/param-name
  param-value1000/param-value
  /context-param

  context-param

 param-nameresteasy.server.cache.eviction.wakeup.interval/param-name
  param-value5000/param-value
  /context-param

  listener

 listener-classorg.jboss.resteasy.plugins.cache.server.ServletServerCache/listener-class
  /listener

 But while trying to run the project on my server I get the following
 exception

 SEVERE: Error configuring application listener of class
 org.jboss.resteasy.plugins.cache.server.ServletServerCache
 java.lang.ClassNotFoundException:
 org.jboss.resteasy.plugins.cache.server.ServletServerCache
  at
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
  at
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
  at
 org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
  at
 org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
  at
 org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
  at
 org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638)
  at
 org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
  at
 org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:745)

 So I build the war with Maven - build and checked for the jar file in
 WEB-INF/lib/ and found the resteasy-cache-core-3.0.9.Final.jar.

 What is going wrong? Or is the way on approaching the server-side cache
 implementation wrong?

 Thank you.


 --



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


-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
___
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-29 Thread Savvas Andreas Moysidis
Great, thanks for the input Bill.

On 29 October 2014 13:20, Bill Burke bbu...@redhat.com wrote:

 By default, Resteasy only allows one connection per Client.  You have to
 use ResteadyClient(Builder) to expand this.  Other than that, it should
 be threadsafe.

 Personally, I'd create the Client as an application-scoped CDI bean and
 inject it, or create one with SPring and inject it, or create one in a
 servlet listener and add it to ServletContext.  If you create per
 request, then you lose any socket connection pooling that Apache Http
 Client does.

 On 10/27/2014 8:21 PM, Savvas Andreas Moysidis 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 mariodi...@gmail.com
  mailto:mariodi...@gmail.com 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
  rodrigo.uc...@gmail.com mailto:rodrigo.uc...@gmail.com 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
  mailto: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
 

 --
 Bill Burke
 JBoss, a division of Red Hat
 http://bill.burkecentral.com


 --
 ___
 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