Hello. I'm working on a vSphere client plugin using the HTML SDK and I checked the vsphere-wssdk-service project included in the SDK as one of the examples where VimService and VimPortType classes are used to get ServiceContent for a VC and then it's used to work with VC VMODL API. In that project VimPortType instance is statically initialized because it takes several seconds. I made some tests and indeed it takes about 5-6 seconds to create VimPortType instance and since it takes so much time I'm trying to figure out how to effectively reuse that instance so my questions are:
1. Can we reuse VimPortType across multiple requests ? - it is obviously done in wssdk example in the SDK but is that part of the code production ready ?
2. Can we reuse VimPortType across multiple request handlers/dataProviders ? - so that we can initialize it statically on only one place in the server code and reuse it across different request handlers or dataProviders
3. Is VimPortType thread safe so that one instance can be safely used from multiple threads without external synchronization ? - again this is done in wssdk
4. Should we externally handle synchronization for this code from wssdk example (com.vmware.samples.vspherewssdk.DataProviderImpl) (not done in the example) :
Map<String, Object> reqContext = ((BindingProvider)_vimPort).getRequestContext();
reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceUrl);
reqContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
reqContext.put(MessageContext.HTTP_REQUEST_HEADERS, reqHeadrs);
ServiceContent serviceContent = null;
try {
serviceContent = _vimPort.retrieveServiceContent(svcInstanceRef);
} catch (RuntimeFaultFaultMsg e) {
_logger.error("getServiceContent error: " + e);
}
I checked that multiple threads work with a single instance of the data provider with a single instance of the VimPortType (_vimPort reference in the example above). Since _vimPort.requestContext is first modified with the selected VC and user session and then _vimPort.retrieveServiceContent is invoked then the whole block should be synchronized for _vimPort reference. Am I right in my guess or the whole DataProviderImpl.getProperties() is somehow externally synchronized and guaranteed that no simultaneous request are being handled which means in that case that we should not care for synchronization ?
5. And to partially reiterate my previous question - is there any external synchronization performed by vSphere client when handling server request to plugin services ?