• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apache CXF SOAP Client Caching

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a WebService for which I generate my client using the Apache CXF framework. I then call my services using the code below:



I have a couple of questions around it:

Can I cache the factory that I create as the first step in the code above?

Should I cache the myServiceClient that I create above and re-use if for subsequent WebService calls? or should I create one client per request?

The reason is that I will be calling these WebServices every 15 seconds or so and I'm not sure which one to have in cache so that I don't end up creating too many instances!
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any suggestions?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is an inherent characteristic of the Factory design pattern that you should be able to construct a Factory once and re-use it thereafter. Otherwise, why bother with a Factory instead of just using a constructor?

Instances created by a factory are a different matter. The other characteristic of a Factory is to be able to produce a product rapidly, which it may do by employing an internal cache or pool. So the overhead for factory products is typically very low. And the properties of the product in question may either have a limited lifetime (for example, network connections that time out), need cleanup (files and connections to close), or may become so dirty in the course of use that it's less trouble to simple obtain a new one.

So as a general rule, I'd cache the factory and use it to create clients on-demand.

It doesn't hurt to read the instructions, though, just in case there are special considerations.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic