1 5 6 package com.hp.hpl.jena.joseki; 7 8 import org.apache.commons.logging.* ; 9 import java.net.* ; 10 11 import com.hp.hpl.jena.rdf.model.* ; 13 16 import com.hp.hpl.jena.rdql.* ; 17 18 24 public class QueryEngineHTTP implements QueryExecution 25 { 26 static final Log logger = LogFactory.getLog(QueryEngineHTTP.class.getName()) ; 27 28 Query query ; 29 HttpQuery qHTTP ; 30 Model resultModel = null ; 31 32 public QueryEngineHTTP(Query q, String urlStr) 33 { 34 query = q ; 35 String queryString = q.toString().replaceAll("\\s{2,}", " ") ; 36 qHTTP = new HttpQuery(urlStr, "RDQL") ; 37 qHTTP.addParam("query", queryString) ; 38 } 39 40 public QueryEngineHTTP(Query q, URL u) 41 { 42 query = q ; 43 String queryString = q.toString().replaceAll("\\s{2,}", " ") ; 44 qHTTP = new HttpQuery(u, "RDQL") ; 45 qHTTP.addParam("query", queryString) ; 46 } 47 48 52 53 public void init() 54 { 55 return ; 56 } 57 58 public QueryResults exec(ResultBinding rb) 59 { 60 logger.error("Initial bindings not supported") ; 61 return null ; 62 } 63 public QueryResults exec() 65 { 66 try { 67 68 resultModel = null ; 69 try { 70 resultModel = qHTTP.exec() ; 71 } catch (HttpException httpEx) 72 { 73 logger.debug("Error on remote invokation: "+httpEx) ; 74 throw httpEx ; 75 } 76 77 if ( resultModel.size() == 0 ) 78 logger.debug("Model size is zero") ; 79 80 query.setSource(resultModel); 82 QueryExecution qexec = new QueryEngine(query); 83 return qexec.exec() ; 84 } 85 catch (RDFException rdfEx) 86 { 87 logger.debug("RDFException: "+rdfEx) ; 88 return null; 89 } 90 } 91 92 96 public void abort() { } 97 98 99 public void close() { resultModel = null ; } 100 101 102 public Model getResultModel() { return resultModel ; } 103 104 105 public void releaseResultModel() { resultModel = null ; } 106 107 public HttpQuery getHttpQuery() { return qHTTP ; } 108 } 109 110 136 | Popular Tags |