Creating a Service Instance

To create an instance of the Service JavaCalculatorExample using COMDriver, use the createService function in the DSCOMDRIVERLib package.

Dim csfactory As New DSCOMDRIVERLib.ServiceFactory
Dim service As DSCOMDRIVERLib.service
Set service = csfactory.createService("JavaCalculatorExample", "0", Nothing, Nothing)

The first line creates an instance of ServiceFactory. This is used to create TIBCO GridServer® Service instances. ServiceFactory is defined in the DSCOMDRIVERLib library, which resolves in DSCOMDriver.exe.

The second line declares a variable called service that holds the Service instance. This variable must be visible to any other part of the code that wishes to interface with the Service. You can see that the rest of the code in this section references this variable.

The third line calls the createService method, which takes four arguments:

serviceName — The name of the registered Service (String).
initData — The state initializing data for the Service (String).
options — Service options; see the Options class in the Service JavaDoc for available options.
description — Service descriptions; see the Description class in the Service Javadoc for available description options.

The third and fourth arguments are of type Properties, which is a set of name-value pairs. Consult the COMDriver documentation for details.

The method returns the created Service interface. In our example, an instance of the JavaCalculatorExample Service is initialized with the value 0, with no options and description.

If the supplied Service name is not registered on TIBCO GridServer®, the application fails with a runtime error: Service: servicename.csdd not found.