//(c) International Business Machines Corporation, 2002 - 2004. //(c) University of Edinburgh, 2002 - 2004. //See OGSA-DAI-Licence.txt for licencing information. package examples.tutorials.clienttoolkit; import uk.org.ogsadai.client.toolkit.GridDataService; import uk.org.ogsadai.client.toolkit.GridDataServiceFactory; import uk.org.ogsadai.client.toolkit.Response; import uk.org.ogsadai.client.toolkit.ServiceFetcher; import uk.org.ogsadai.client.toolkit.activity.xmldb.XPathQuery; /** * This is an example for a simple XPath query. The results are * returned within the response document. */ public class SimpleXPathQueryExample { public static void main(String[] args) throws Exception { // Default factory handle String handle = "http://localhost:8080/ogsa/services/ogsadai/GridDataServiceFactoryXindice"; // Factory handle may be provided as an argument if (args.length == 1) { handle = args[0]; } // Locate a Grid Data Service Factory GridDataServiceFactory factory = ServiceFetcher.getFactory(handle); System.out.println("Ready to connect to factory at " + handle); // Create a Grid Data Service GridDataService service = factory.createGridDataService(); System.out.println("Created Grid Data Service at " + service.getHandle()); // Prepare an XPath query XPathQuery query = new XPathQuery("/entry[@id<10]"); // Perform the query System.out.println("Performing query..."); Response response = service.perform(query); System.out.println("Response:\n" + response.getAsString()); // Destroy the service service.destroy(); System.out.println("Destroyed service."); } }