Globus Toolkit 4: Programming Java Services

In the previous chapter, we saw how to implement a single-resource stateful web service. We did this the simplest possible way: implementing the service and the resource in the same class. In this chapter, although we will continue to have a single resource, we will learn more about the preferred way of implementing web services in GT4: using a separate class for the service and the resource. To do this, we will learn more about resource homes.
In this chapter, we will split our implementation into three files. We will see that, for the most part, we will simply take code from the previous chapter and divide it among the three files.
The resource: $EXAMPLES_DIR/org/globus/examples/services/core/singleton/ impl/MathResource.java
The resource home: $EXAMPLES_DIR/org/globus/examples/services/core/ singleton/impl/MathResourceHome.java
The service itself: $EXAMPLES_DIR/org/globus/examples/services/core/ singleton/impl/MathService.java
Before looking at the actual Java code, let's make sure we understand how these three implementation files are related.
The service is the stateless frontend (the client only interacts with this class, even if there are more classes lurking around in the background). Remember from Chapter 4, WSRF section that, since we're following a "resource approach" to statefulness, the web service will always be stateless. However, we can give the impression of being stateful by retrieving a stateful resource whenever we want to access state information.
The resource is the stateful