5.7. Build and deploy

5.7.1. The deployment descriptor

The WSDD file must now reflect that we have two services: the factory service and the instance service.

<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultServerConfig" 
    xmlns="http://xml.apache.org/axis/wsdd/" 
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    1
    <!-- Instance service -->
    <service name="examples/core/factory/MathService" provider="Handler" use="literal" style="document">
        <parameter name="className" value="org.globus.examples.services.core.factory.impl.MathService"/>
        <wsdlFile>share/schema/examples/MathService_instance/Math_service.wsdl</wsdlFile>
        <parameter name="allowedMethods" value="*"/>
        <parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/>
        <parameter name="scope" value="Application"/>
        <parameter name="providers" value="GetRPProvider"/>
    </service>

    2
    <!-- Factory service -->
    <service name="examples/core/factory/MathFactoryService" provider="Handler" use="literal" style="document">
        <parameter name="className" value="org.globus.examples.services.core.factory.impl.MathFactoryService"/>
        <wsdlFile>share/schema/examples/FactoryService/Factory_service.wsdl</wsdlFile>
        <parameter name="allowedMethods" value="*"/>
        <parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/>
        <parameter name="scope" value="Application"/>
        <parameter name="instance" value="examples/core/factory/MathService"/> 3
    </service>

</deployment>

[Note]

This file is $EXAMPLES_DIR/org/globus/examples/services/core/factory/deploy-server.wsdd.

1

The parameters for the instance service are the same as the ones used in the previous chapter.

2

The deployment parameters of the factory are pretty straightforward. We simply specify the factory service's class (MathFactoryService) and WSDL file.

3

The only new parameter is the instance parameter, which must be set to the name of the instance service (as written in its <service> tag).

5.7.2. The JNDI deployment file

In the previous chapter we saw that this file specifies what resource home must be used by each service. When managing just one resource, this file was very simple. Now, however, we will need to specify more parameters to manage multiple resources. Furthermore, our JNDI deployment file must include two <service> tags (one for the instance service, and one for the factory service).

<?xml version="1.0" encoding="UTF-8"?>
<jndiConfig xmlns="http://wsrf.globus.org/jndi/config">

<!-- Instance service -->
<service name="examples/core/factory/MathService">
	<resource name="home" type="org.globus.examples.services.core.factory.impl.MathResourceHome"> 1
	<resourceParams>

		2
		<parameter>
			<name>resourceClass</name>
			<value>org.globus.examples.services.core.factory.impl.MathResource</value>
		</parameter>

		3
		<parameter>
			<name>resourceKeyType</name>
			<value>java.lang.Integer</value>
		</parameter>

		4
		<parameter>
			<name>resourceKeyName</name>
			<value>{http://www.globus.org/namespaces/examples/core/MathService_instance}MathResourceKey</value>
		</parameter>

		5
		<parameter>
			<name>factory</name>
			<value>org.globus.wsrf.jndi.BeanFactory</value>
		</parameter>

	</resourceParams>
	</resource>
</service>

<!-- Factory service -->
<service name="examples/core/factory/MathFactoryService">
	6
	<resourceLink name="home" target="java:comp/env/services/examples/core/factory/MathService/home"/>
</service>

</jndiConfig>

[Note]

This file is $EXAMPLES_DIR/org/globus/examples/services/core/factory/deploy-jndi-config.xml.

1

We use the <resource> tag to specify what resource home will be used by the instance service.

2

The resourceClass parameter specifies the type of our resources.

3

The value we put in the resourceKeyType parameter must match the type used in the implementation when creating the key. Remember that we used the resource's hash code, which is of type java.lang.Integer. Thus, we have to include that type in the JNDI configuration.

4

The resourceKeyName parameter must be a qualified name. Notice that we're using a name that is not mentioned in our WSDL file. This is Ok and, in fact, we could use any QName we wanted. However, for clarity we should choose a QName that is in the same namespace as the service.

5

Remember from the previous chapter that this is a common parameter which we will find in all our JNDI deployment files. However, it is important to note that, even though this parameter is called factory, it has nothing to do with the factory/instance pattern we are seeing in this chapter. It refers to a completely different factory within the Globus code.

6

The factory service uses the same resource home as the instance service. So, we do not need to repeat all the parameters of the instance service. We simply have to include a <resourceLink> tag linking to the previously specified resource home. Notice that we must do so using a special path.

5.7.3. Build and deploy

We are finally ready to build and deploy our service:

./globus-build-service.sh factory
globus-deploy-gar $EXAMPLES_DIR/org_globus_examples_services_core_factory.gar