6.1.1.
Using the GRIA API
Up one level
Please see the JavaDoc for a detailed descrition of the API.
The GRIA API is used to create and manage the GRIA resources representing databases, roles and subscriptions. See the AXIS plugin for OGSA-DAI clients document for instructions for using the OGSA-DAI API for OGSA-DAI operations (e.g. "perform").
Configuring your Classpath
To use the GRIA OGSA-DAI libraries from your own application, ensure that all of the following are in your application's classpath:
- All the jars from the standard graphical client's lib directory, except for gria-client-cli-2.jar, which is the default client itself.
- The gria-ogsadai-client-5.2.jar and gria-ogsadai-common-5.2.jar file from inside the client directory of this package.
- The client-config.wsdd and implementationfactory.properties files from inside gria-client-cli-2.jar.
The WSDD file causes messages to be signed correctly and contains type mappings telling Axis how to serialise various types.
The crypto.properties file from the client's conf directory, which gives details of the keystore to use.
The StateRepository
A StateRepository stores resources (accounts, SLAs, databases, roles and subscriptions) and services. There are two implementations provided with the GRIA library:
- FileStateRepository stores them in an XML format file.
- MemoryStateRepository only stores them in memory. Quitting the application will cause them to be forgotten.
Creating a StateRepository
To create a new memory repository:
StateRepository repository = new MemoryStateRepository();
To create a new repository that stores its state in a file called client.state (this is what the standard client uses):
StateRepository repository = new FileStateRepository("client.state");
It is probably easiest to use FileStateRepository as you can create objects using the standard client and then use them from your own program.
Adding services to a repository
Just as when using the graphical client interface, services must be added to the repository before they can be used. All the details about an object in a StateRepository are represented as a WS-Addressing EndpointReference. For example, to add a RemoteOgsaDaiService proxy to an OGSA-DAI service:
EndpointReference serviceEPR = new EndpointReference("https://.../services/DataService");
RemoteOgsaDaiService ogsaDaiService = repository.getOrCreateObject(RemoteOgsaDaiService.class, serviceEPR);
The getOrCreateObject method takes an EPR for the object you want, and a Java interface for the resulting object. If the object is already in the respository then it returns it, otherwise it creates a new one, adds it to the repository, and returns that.
Billing Information
For methods which create new resources, the client software will automatically add a SOAP header containing the billing information (i.e. the ID of the SLA managing the resource).
Useful Methods
The following methods will be the most useful when using the OGSA-DAI service. For a full list of classes and methods see the Javadoc.
Methods on RemoteOgsaDaiService (the service) Methods on RemoteOgsaDaiServiceHelpers (the client's service helper class)- createDataResource(String label)
- connectDataResource(String label, Map<String, String> attributes)
- connectDataResourceRole(String label, Map<String, String> attributes)
- createSubscription(String label)
- Once you have a subscription resource ID, the standard OGSA-DAI API should be used for querying the database. See example code.
Many classes have the following common methods:
- destroy()
- setLabel(String label)
- GetValidRoles()
- getAccessControlRules()
- addAccessControlRule(MatchRule rule)
- removeAccessControlRule(MatchRule rule)
