Best Practices for Using VimPortType with JAX-WS
The JAX-WS package can leak memory due to repeated creation of
VimPort
connections with the vSphere Web Services SDK. The use of a
static VimPort
object can alleviate the memory leaks, but can lead to other
problems, especially with thread safety. JAX-WS does not provide a thread-safe
Port
implementation for the VimPort
object, which
accesses the Web Services API.
Use one or more of the following best practices, depending on the nature of your plug-in:
- For a single-threaded plug-in that does
synchronous requests to the vSphere Web Services API, create a static instance of
the
VimPort
object and reuse it for subsequent requests. - For a plug-in that does not need to
handle a large number of asynchronous requests, create a static instance of the
VimPort
object and serialize access to it. - For higher performance with a large
number of asynchronous requests, create a pool of
VimPort
objects. - Use static initializer code to issue a
dummy call to the
getPort()
method before your plug-in needs to handle actual requests. The first call togetPort()
runs slowly because it must load a large amount of WSDL code for the Web Services API.