You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by sa...@apache.org on 2012/08/13 06:30:11 UTC

svn commit: r1372261 - in /jena/Experimental/jena-client: ./ src/main/java/org/apache/jena/client/ src/main/java/org/apache/jena/client/graph/ src/main/java/org/apache/jena/client/http/

Author: sallen
Date: Mon Aug 13 04:30:10 2012
New Revision: 1372261

URL: http://svn.apache.org/viewvc?rev=1372261&view=rev
Log:
jena-client -
1) Refactor much of the code and interfaces 
2) Remove Parameterizer 
3) Fill in implementation for Query and Update 

Added:
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementWrapper.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatementBase.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementWrapper.java
Removed:
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Parameterizer.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/ParameterizerBase.java
Modified:
    jena/Experimental/jena-client/pom.xml
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/ConnectionBase.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementBase.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerier.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerierWrapper.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterBase.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterWrapper.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdateStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdateStatement.java

Modified: jena/Experimental/jena-client/pom.xml
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/pom.xml?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/pom.xml (original)
+++ jena/Experimental/jena-client/pom.xml Mon Aug 13 04:30:10 2012
@@ -20,7 +20,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.jena</groupId>
   <artifactId>jena-client</artifactId>
-  <version>0.0.4-SNAPSHOT</version>
+  <version>0.0.5-SNAPSHOT</version>
   <name>JenaClient</name>
   <description>A Jena library for interacting with SPARQL endpoints.</description>
   
@@ -47,9 +47,15 @@
     <dependency>
       <groupId>org.apache.jena</groupId>
       <artifactId>jena-arq</artifactId>
-      <version>2.9.2</version>
+      <version>2.9.4-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.9</version>
+      <scope>test</scope>
     </dependency>
-  
   </dependencies>
   
   

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java Mon Aug 13 04:30:10 2012
@@ -20,6 +20,7 @@ package org.apache.jena.client;
 
 import org.openjena.atlas.lib.Closeable;
 
+import com.hp.hpl.jena.query.ParameterizedSparqlString;
 import com.hp.hpl.jena.query.Query;
 import com.hp.hpl.jena.sparql.core.Transactional;
 import com.hp.hpl.jena.update.Update;
@@ -27,7 +28,7 @@ import com.hp.hpl.jena.update.Update;
 /**
  * A connection (session) with a specific repository.  SPARQL statements are executed and results returned within the context of a connection.
  */
-public interface Connection extends Updater, Transactional, Closeable
+public interface Connection extends Transactional, Closeable
 {
     
 //    void isAutoCommit();
@@ -35,19 +36,12 @@ public interface Connection extends Upda
     
 //    Service getServices();
     
-    
+    /**
+     * Retrieves the {@link Repository} object that produced this <code>Connection</code> object.
+     * @return the repository that produced this connection
+     */
     Repository getRepository();
     
-    
-//    // These set up the services to use for the connection.  They'll be set to a reasonable default when the connection is created.
-//    void setQueryService(QueryService service);
-//    void setUpdateService(UpdateService service);
-//    void setBulkService(UpdateService service);
-//    
-//    QueryService getQueryService();
-//    UpdateService getUpdateService();
-//    UpdateService getBulkService();
-    
     /**
      * Answers whether the {@link Connection} supports Transactions.  If it does then the {@link Transactional} methods
      * can be used to control transactions.  If it doesn't, then the {@link Transactional} methods are no-ops.
@@ -56,14 +50,17 @@ public interface Connection extends Upda
      */
     boolean supportsTransactions();
     
-    
-    QueryStatement createQueryStatement(String queryString);
     QueryStatement createQueryStatement(Query query);
+    QueryStatement createQueryStatement(String queryString);
+    QueryStatement createQueryStatement(ParameterizedSparqlString paramQuery);
     
-    UpdateStatement createUpdateStatement(String updateString);
     UpdateStatement createUpdateStatement(Update update);
+    UpdateStatement createUpdateStatement(Iterable<? extends Update> update);
+    UpdateStatement createUpdateStatement(String updateString);
+    UpdateStatement createUpdateStatement(ParameterizedSparqlString paramUpdate);
+    
 
-    Updater createBulkUpdater();
+    Updater createStreamingUpdater();
     
     // I think we'll not expose these...  The original idea was to better support the
     // SPARQL Graph Store Protocol, which would not allow mixing these operations into a

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/ConnectionBase.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/ConnectionBase.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/ConnectionBase.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/ConnectionBase.java Mon Aug 13 04:30:10 2012
@@ -3,148 +3,164 @@ package org.apache.jena.client;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.util.Iterator;
 
 import org.openjena.atlas.lib.Closeable;
 
-import com.hp.hpl.jena.sparql.core.Quad;
+import com.hp.hpl.jena.query.ParameterizedSparqlString;
+import com.hp.hpl.jena.query.Query;
 import com.hp.hpl.jena.update.Update;
 
-public abstract class ConnectionBase extends UpdaterBase implements Connection
+public abstract class ConnectionBase implements Connection
 {
-    protected Closeable bulkOperator = null;
+    protected final Repository repo;
+    
+    protected Closeable operator = null;
 
-    protected abstract boolean hasBulkUpdater();
-    protected abstract Updater doCreateBulkUpdater();
-//    protected abstract UpdateInserter doCreateBulkUpdateInserter();
-//    protected abstract UpdateDeleter doCreateBulkUpdateDeleter();
-//    protected abstract UpdateQuerier doCreateBulkUpdateQuerier();
+    public ConnectionBase(Repository repo)
+    {
+        if (null == repo)
+        {
+            throw new IllegalArgumentException("repo must not be null");
+        }
+        
+        this.repo = repo;
+    }
+    
+    
+    protected abstract QueryStatement doCreateQueryStatement(Query query);
+    protected abstract QueryStatement doCreateQueryStatement(String queryString);
     
+    protected abstract UpdateStatement doCreateUpdateStatement(Update update);
+    protected abstract UpdateStatement doCreateUpdateStatement(Iterable<? extends Update> update);
+    protected abstract UpdateStatement doCreateUpdateStatement(String updateString);
     
-    protected void checkBulkOperationOngoing()
+    protected abstract Updater doCreateStreamingUpdater();
+    protected abstract boolean hasStreamingUpdater();
+    
+    @Override
+    public Repository getRepository()
     {
-        if (bulkOperator != null)
+        return repo;
+    }
+    
+    protected void checkOperationOngoing()
+    {
+        if (operator != null)
         {
-            throw new IllegalStateException("You must close any open bulk operations before other operations are allowed on this Connection");
+            throw new IllegalStateException("You must close any open operations before new operations are allowed on this Connection");
         }
     }
 
     @Override
-    public final Updater createBulkUpdater()
+    public final Updater createStreamingUpdater()
     {
-        if (!hasBulkUpdater())
+        if (!hasStreamingUpdater())
         {
-            throw new IllegalAccessError("This Connection does not support retreiving a bulk Modifier.  You can check this with hasBulkModifier()");
+            throw new IllegalAccessError("This Connection does not support retreiving a streaming Updater.  You can check this with hasStreamingUpdater()");
         }
-        checkBulkOperationOngoing();
-        Updater toReturn = new UpdaterWrapper(doCreateBulkUpdater())
+        checkOperationOngoing();
+        Updater toReturn = new UpdaterWrapper(doCreateStreamingUpdater())
         {
-            @Override
-            public void close()
-            {
-                super.close();
-                bulkOperator = null;
-            }
+            @Override public void close() { super.close(); operator = null; }
         };
-        bulkOperator = toReturn;
+        operator = toReturn;
         return toReturn; 
     }
     
-    // Disabled, use createBulkUpdater() for all your update needs
-//    @Override
-//    public final UpdateInserter createBulkUpdateInserter()
-//    {
-//        checkBulkOperationOngoing();
-//        //UpdateInserter toReturn = getProxy(Inserter.class, doCreateBulkInserter());
-//        UpdateInserter toReturn = new UpdateInserterWrapper(doCreateBulkUpdater())
-//        {
-//            @Override
-//            public void close()
-//            {
-//                super.close();
-//                bulkOperator = null;
-//            }
-//        };
-//        bulkOperator = toReturn;
-//        return toReturn;
-//    }
-//    
-//    @Override
-//    public final UpdateDeleter createBulkUpdateDeleter()
-//    {
-//        checkBulkOperationOngoing();
-//        UpdateDeleter toReturn = new UpdateDeleterWrapper(doCreateBulkUpdater())
-//        {
-//            @Override
-//            public void close()
-//            {
-//                super.close();
-//                bulkOperator = null;
-//            }
-//        };
-//        bulkOperator = toReturn;
-//        return toReturn;
-//    }
-//    
-//    @Override
-//    public final UpdateQuerier createBulkUpdateQuerier()
-//    {
-//        checkBulkOperationOngoing();
-//        UpdateQuerier toReturn = new UpdateQuerierWrapper(doCreateBulkUpdater())
-//        {
-//            @Override
-//            public void close()
-//            {
-//                super.close();
-//                bulkOperator = null;
-//            }
-//        };
-//        bulkOperator = toReturn;
-//        return toReturn;
-//    }
-    
-    @Override
-    protected void doInsert(Iterator<? extends Quad> it)
-    {
-        checkBulkOperationOngoing();
-        //UpdateInserter op = doCreateBulkUpdateInserter();
-        Updater op = doCreateBulkUpdater();
-        op.insert(it);
-        op.close();
-    }
-    
-    @Override
-    protected void doDelete(Iterator<? extends Quad> it)
-    {
-        checkBulkOperationOngoing();
-        //UpdateDeleter op = doCreateBulkUpdateDeleter();
-        Updater op = doCreateBulkUpdater();
-        op.delete(it);
-        op.close();
-    }
-    
-    @Override
-    protected void doUpdate(Iterator<? extends Update> it)
-    {
-        checkBulkOperationOngoing();
-        //UpdateQuerier op = doCreateBulkUpdateQuerier();
-        Updater op = doCreateBulkUpdater();
-        op.update(it);
-        op.close();
+    @Override
+    public final QueryStatement createQueryStatement(String queryString)
+    {
+        checkOperationOngoing();
+        return registerQueryStatement(doCreateQueryStatement(queryString));
+    }
+    
+    @Override
+    public final QueryStatement createQueryStatement(ParameterizedSparqlString paramQuery)
+    {
+        if (null == paramQuery)
+        {
+            throw new NullPointerException("paramQuery");
+        }
+        return createQueryStatement(paramQuery.toString());
+    }
+    
+    @Override
+    public final QueryStatement createQueryStatement(Query query)
+    {
+        checkOperationOngoing();
+        return registerQueryStatement(doCreateQueryStatement(query));
+    }
+    
+    @Override
+    public final UpdateStatement createUpdateStatement(String updateString)
+    {
+        checkOperationOngoing();
+        //return registerUpdateStatement(doCreateUpdateStatement(updateString));
+        // TODO we are relying on the fact that UpdateStatementBase will use a streaming updater, so we don't want to double register here...
+        return doCreateUpdateStatement(updateString);
+    }
+    
+    @Override
+    public final UpdateStatement createUpdateStatement(ParameterizedSparqlString paramUpdate)
+    {
+        if (null == paramUpdate)
+        {
+            throw new NullPointerException("paramQuery");
+        }
+        return createUpdateStatement(paramUpdate.toString());
+    }
+    
+    @Override
+    public final UpdateStatement createUpdateStatement(Update update)
+    {
+        checkOperationOngoing();
+        //return registerUpdateStatement(doCreateUpdateStatement(update));
+        // TODO we are relying on the fact that UpdateStatementBase will use a streaming updater, so we don't want to double register here...
+        return doCreateUpdateStatement(update);
+    }
+    
+    @Override
+    public final UpdateStatement createUpdateStatement(Iterable<? extends Update> updates)
+    {
+        checkOperationOngoing();
+        //return registerUpdateStatement(doCreateUpdateStatement(update));
+        // TODO we are relying on the fact that UpdateStatementBase will use a streaming updater, so we don't want to double register here...
+        return doCreateUpdateStatement(updates);
+    }
+    
+    private QueryStatement registerQueryStatement(QueryStatement qs)
+    {
+        QueryStatement toReturn = new QueryStatementWrapper(qs)
+        {
+            @Override public void close() { super.close(); operator = null; }
+        };
+        operator = toReturn;
+        return toReturn;
+    }
+    
+    @SuppressWarnings("unused")
+    private UpdateStatement registerUpdateStatement(UpdateStatement us)
+    {
+        UpdateStatement toReturn = new UpdateStatementWrapper(us)
+        {
+            @Override public void close() { super.close(); operator = null; }
+        };
+        operator = toReturn;
+        return toReturn;
     }
     
     @Override
     public void close()
     {
-        if (null != bulkOperator)
+        if (null != operator)
         {
-            bulkOperator.close();
+            operator.close();
         }
         end();
     }
     
     
-    // Cool idea to prevent having to create *Wrapper classes.  But it uses reflection, which will be slower (by how much?)
+    // Cool idea to avoid having to create *Wrapper classes.  But it uses reflection, which will be slower (by how much?)
     @SuppressWarnings({ "unchecked", "unused" })
     private <T> T getProxy(Class<T> intf, final T obj)
     {
@@ -152,11 +168,13 @@ public abstract class ConnectionBase ext
         {
             public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
             {
+                Object toReturn = method.invoke(obj, args);
+                
                 if ("close".equals(method.getName()))
                 {
-                    bulkOperator = null;
+                    operator = null;
                 }
-                return method.invoke(obj, args);
+                return toReturn;
             }
         });
     }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatement.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatement.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatement.java Mon Aug 13 04:30:10 2012
@@ -1,7 +1,6 @@
 package org.apache.jena.client;
 
 import java.util.Iterator;
-import java.util.concurrent.TimeUnit;
 
 import com.hp.hpl.jena.graph.Triple;
 import com.hp.hpl.jena.query.ResultSet;
@@ -15,16 +14,9 @@ import com.hp.hpl.jena.rdf.model.Stateme
  * @see Connection#createQueryStatement
  * @see ResultSet
  */
-public interface QueryStatement extends Parameterizer
+public interface QueryStatement extends SparqlStatement
 {
     /**
-     * Retrieves the {@link Connection} object that produced this <code>QueryStatement</code> object.
-     * @return the connection that produced this statement
-     * @throws SPARQLException if a database access error occurs or this method is called on a closed <code>QueryStatement</code>
-     */
-    Connection getConnection();
-    
-    /**
      * Execute a SELECT query.
      *  
      * @return a ResultSet with the results of the select query.
@@ -114,56 +106,4 @@ public interface QueryStatement extends 
      * @return a <code>boolean</code> corresponding to the result of the ASK query 
      */
     boolean execAsk();
-    
-    /**
-     * Cancels this <code>QueryStatement</code> object mid-execution if the implementation supports it.
-     * This method can be called by a different thread than is currently executing the query.  There
-     * is no guarantee that the concrete implementation actually will stop or that it will do so immediately.
-     * <p/>
-     * No operations on the query execution or any associated result set are permitted after this call
-     * and may cause exceptions to be thrown.
-     */
-    void cancel();
-    
-    // TODO Need to update the implementations to follow the timeout behavior specified here, specifically the zero and negative timeout
-    // TODO We need to emphasize that these are client-side options only.  The server may enforce different timeouts.
-    /**
-     * Set the number of milliseconds to wait for a <code>QueryStatement</code> to return the first result.
-     * @param timeout the new query timeout limit in milliseconds; zero or a negative number means there is no limit
-     * @see #setTimeout(long, TimeUnit)
-     */
-    void setTimeout(long timeout);
-    
-    /**
-     * Set the amount of time to wait for a <code>QueryStatement</code> to return the first result.
-     * @param timeout the new query timeout limit in <code>timeoutUnits</code>; zero or a negative number means there is no limit
-     * @param timeoutUnits the time units in which <code>timeout</code> is specified
-     */
-    void setTimeout(long timeout, TimeUnit timeoutUnits);
-    
-    /**
-     * Set the number of milliseconds to wait for execution; the first timeout refers to time to first result, the second
-     * refers to overall query execution after the first result.  Processing will be aborted if a timeout expires. 
-     * @param timeout1   the new timeout limit for the first result in milliseconds; zero or a negative number means there is no limit 
-     * @param timeout2   the new timeout limit for the total execution time in milliseconds; zero or a negative number means there is no limit
-     */
-    void setTimeout(long timeout1, long timeout2);
-    
-    /**
-     * Set timeouts on the query execution; the first timeout refers to time to first result, the second
-     * refers to overall query execution after the first result.  Processing will be aborted if a timeout expires. 
-     * @param timeout1   the new timeout limit for the first result in <code>timeUnit1</code>; zero or a negative number means there is no limit 
-     * @param timeUnit1  the time units in which <code>timeout1</code> is specified
-     * @param timeout2   the new timeout limit for the total execution time in <code>timeUnit2</code>; zero or a negative number means there is no limit
-     * @param timeUnit2  the time units in which <code>timeUnit2</code> is specified
-     */
-    void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2);
-    
-    
-    /**
-     * Returns the Query as a String.
-     * @return the query represented as a String.
-     */
-    @Override
-    String toString();
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementBase.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementBase.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementBase.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementBase.java Mon Aug 13 04:30:10 2012
@@ -1,9 +1,11 @@
 package org.apache.jena.client;
 
 import java.util.Iterator;
-import java.util.concurrent.TimeUnit;
 
 import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryCancelledException;
+import com.hp.hpl.jena.query.QueryExecution;
 import com.hp.hpl.jena.query.ResultSet;
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
@@ -11,133 +13,141 @@ import com.hp.hpl.jena.rdf.model.Stateme
 import com.hp.hpl.jena.rdf.model.impl.StmtIteratorImpl;
 import com.hp.hpl.jena.sparql.util.ModelUtils;
 
-public abstract class QueryStatementBase extends ParameterizerBase implements QueryStatement
+public abstract class QueryStatementBase<T extends QueryExecution> extends SparqlStatementBase implements QueryStatement
 {
-    private final Connection connection;
-    private long timeout1;
-    private long timeout2;
+    protected final String queryString;
+    protected final Query queryObject;
     
-    public QueryStatementBase(Connection connection)
-    {
-        this.connection = connection;
-    }
+    protected boolean cancelRequestedBeforeExecution = false;
     
-    public abstract ResultSet doExecSelect();
-    public abstract Iterator<Triple> doExecConstructTriples();
-    public abstract Iterator<Triple> doExecDescribeTriples();
-    public abstract boolean doExecAsk();
-    
-    @Override
-    public abstract void cancel();
+    protected final Object lock = new Object();
+    protected T qe;
     
-
-    @Override
-    public Connection getConnection()
+    protected QueryStatementBase(String queryString, Connection connection)
     {
-        return connection;
+        super(connection);
+        this.queryString = queryString;
+        this.queryObject = null;
     }
-
-    @Override
-    public ResultSet execSelect()
-    {
-        startTimer();
-        return doExecSelect();
-    }
-
-    @Override
-    public Model execConstruct()
+    
+    protected QueryStatementBase(Query query, Connection connection)
     {
-        return execConstruct(ModelFactory.createDefaultModel());
+        super(connection);
+        this.queryString = null;
+        this.queryObject = query;
     }
 
     @Override
-    public Model execConstruct(Model model)
+    public void close()
     {
-        return model.add(new StmtIteratorImpl(execConstructStatements(model)));
+        qe.close();
     }
     
-    @Override
-    public Iterator<Statement> execConstructStatements(final Model refModel)
+    protected void doCancel()
     {
-        return ModelUtils.triplesToStatements(execConstructTriples(), refModel);
+        qe.abort();
     }
-
-    @Override
-    public Iterator<Triple> execConstructTriples()
+    
+    protected abstract T createQueryExecution();
+    
+    protected void createAndSetQueryExecution()
     {
-        startTimer();
-        return doExecConstructTriples();
+        T qe = createQueryExecution();
+        qe.setTimeout(timeout1, timeout2);
+        
+        synchronized(lock)
+        {
+            if (null != this.qe)
+            {
+                throw new IllegalStateException("QueryStatement objects may only be used once");
+            }
+            
+            if (cancelRequestedBeforeExecution)
+            {
+                throw new QueryCancelledException();
+            }
+            this.qe = qe;
+        }
     }
 
     @Override
-    public Model execDescribe()
-    {
-        return execDescribe(ModelFactory.createDefaultModel());
+    public void cancel()
+    {
+        synchronized (lock)
+        {
+            if (null != qe)
+            {
+                doCancel();
+            }
+            else
+            {
+                cancelRequestedBeforeExecution = true;
+            }
+        }
     }
-
+    
     @Override
-    public Model execDescribe(Model model)
+    public ResultSet execSelect()
     {
-        return model.add(new StmtIteratorImpl(execDescribeStatements(model)));
+        createAndSetQueryExecution();
+        return qe.execSelect();
     }
     
     @Override
-    public Iterator<Statement> execDescribeStatements(final Model refModel)
+    public Iterator<Triple> execConstructTriples()
     {
-        return ModelUtils.triplesToStatements(execDescribeTriples(), refModel);
+        createAndSetQueryExecution();
+        return qe.execConstructTriples();
     }
 
     @Override
     public Iterator<Triple> execDescribeTriples()
     {
-        startTimer();
-        return doExecDescribeTriples();
+        createAndSetQueryExecution();
+        return qe.execDescribeTriples();
     }
 
     @Override
     public boolean execAsk()
     {
-        startTimer();
-        return doExecAsk();
+        createAndSetQueryExecution();
+        return qe.execAsk();
     }
 
+
     @Override
-    public void setTimeout(long timeout)
+    public Model execConstruct()
     {
-        setTimeout(timeout, TimeUnit.MILLISECONDS);
+        return execConstruct(ModelFactory.createDefaultModel());
     }
 
     @Override
-    public void setTimeout(long timeout, TimeUnit timeoutUnits)
+    public Model execConstruct(Model model)
     {
-        setTimeout(timeout, timeoutUnits, 0, TimeUnit.MILLISECONDS);
+        return model.add(new StmtIteratorImpl(execConstructStatements(model)));
     }
-
+    
     @Override
-    public void setTimeout(long timeout1, long timeout2)
+    public Iterator<Statement> execConstructStatements(final Model refModel)
     {
-        setTimeout(timeout1, TimeUnit.MILLISECONDS, timeout2, TimeUnit.MILLISECONDS);
+        return ModelUtils.triplesToStatements(execConstructTriples(), refModel);
     }
 
     @Override
-    public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2)
+    public Model execDescribe()
     {
-        timeout1 = asMillis(timeout1, timeUnit1);
-        timeout2 = asMillis(timeout2, timeUnit2);
+        return execDescribe(ModelFactory.createDefaultModel());
     }
-    
-    protected void startTimer()
+
+    @Override
+    public Model execDescribe(Model model)
     {
-        // TODO what are the semantics of the timeouts?  Do they get reset each time we get a new result?
-        // Look at QueryExecutionBase to see how it's currently being done
-        
-        //if (timeoutExpired) cancel();
+        return model.add(new StmtIteratorImpl(execDescribeStatements(model)));
     }
     
-    
-    private static long asMillis(long duration, TimeUnit timeUnit)
+    @Override
+    public Iterator<Statement> execDescribeStatements(final Model refModel)
     {
-        return (duration < 0 ) ? duration : timeUnit.toMillis(duration) ;
+        return ModelUtils.triplesToStatements(execDescribeTriples(), refModel);
     }
-    
 }

Added: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementWrapper.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementWrapper.java?rev=1372261&view=auto
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementWrapper.java (added)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/QueryStatementWrapper.java Mon Aug 13 04:30:10 2012
@@ -0,0 +1,121 @@
+package org.apache.jena.client;
+
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Statement;
+
+class QueryStatementWrapper implements QueryStatement
+{
+    private final QueryStatement wrappedObject;
+    
+    public QueryStatementWrapper(QueryStatement queryStatement)
+    {
+        this.wrappedObject = queryStatement;
+    }
+
+    @Override
+    public Connection getConnection()
+    {
+        return wrappedObject.getConnection();
+    }
+
+    @Override
+    public ResultSet execSelect()
+    {
+        return wrappedObject.execSelect();
+    }
+
+    @Override
+    public void close()
+    {
+        wrappedObject.close();
+    }
+
+    @Override
+    public Model execConstruct()
+    {
+        return wrappedObject.execConstruct();
+    }
+
+    @Override
+    public Model execConstruct(Model model)
+    {
+        return wrappedObject.execConstruct(model);
+    }
+
+    @Override
+    public void cancel()
+    {
+        wrappedObject.cancel();
+    }
+
+    @Override
+    public Iterator<Statement> execConstructStatements(Model refModel)
+    {
+        return wrappedObject.execConstructStatements(refModel);
+    }
+
+    @Override
+    public void setTimeout(long timeout)
+    {
+        wrappedObject.setTimeout(timeout);
+    }
+
+    @Override
+    public void setTimeout(long timeout, TimeUnit timeoutUnits)
+    {
+        wrappedObject.setTimeout(timeout, timeoutUnits);
+    }
+
+    @Override
+    public Iterator<Triple> execConstructTriples()
+    {
+        return wrappedObject.execConstructTriples();
+    }
+
+    @Override
+    public void setTimeout(long timeout1, long timeout2)
+    {
+        wrappedObject.setTimeout(timeout1, timeout2);
+    }
+
+    @Override
+    public Model execDescribe()
+    {
+        return wrappedObject.execDescribe();
+    }
+
+    @Override
+    public Model execDescribe(Model model)
+    {
+        return wrappedObject.execDescribe(model);
+    }
+
+    @Override
+    public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2)
+    {
+        wrappedObject.setTimeout(timeout1, timeUnit1, timeout2, timeUnit2);
+    }
+
+    @Override
+    public Iterator<Statement> execDescribeStatements(Model refModel)
+    {
+        return wrappedObject.execDescribeStatements(refModel);
+    }
+
+    @Override
+    public Iterator<Triple> execDescribeTriples()
+    {
+        return wrappedObject.execDescribeTriples();
+    }
+
+    @Override
+    public boolean execAsk()
+    {
+        return wrappedObject.execAsk();
+    }
+}

Added: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatement.java?rev=1372261&view=auto
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatement.java (added)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatement.java Mon Aug 13 04:30:10 2012
@@ -0,0 +1,69 @@
+package org.apache.jena.client;
+
+import java.util.concurrent.TimeUnit;
+
+import org.openjena.atlas.lib.Closeable;
+
+public interface SparqlStatement extends Closeable
+{
+
+    /**
+     * Retrieves the {@link Connection} object that produced this <code>SparqlStatement</code> object.
+     * @return the connection that produced this statement
+     */
+    public Connection getConnection();
+
+    /**
+     * Releases this Statement's resources immediately instead of waiting for this to happen when it is
+     * automatically closed. It is generally good practice to release resources as soon as you are finished
+     * with them to avoid tying up database resources.  Calling the method close on a Statement object that
+     * is already closed has no effect.
+     */
+    @Override
+    public void close();
+    
+    /**
+     * Cancels this <code>SparqlStatement</code> object mid-execution if the implementation supports it.
+     * This method can be called by a different thread than is currently executing the query.  There
+     * is no guarantee that the concrete implementation actually will stop or that it will do so immediately.
+     * <p/>
+     * No operations on the query execution or any associated result set are permitted after this call
+     * and may cause exceptions to be thrown.
+     */
+    public void cancel();
+
+    // TODO Need to update the implementations to follow the timeout behavior specified here, specifically the zero and negative timeout
+    // TODO We need to emphasize that these are client-side options only.  The server may enforce different timeouts.
+    /**
+     * Set the number of milliseconds to wait for a <code>SparqlStatement</code> to return the first result.
+     * @param timeout the new query timeout limit in milliseconds; zero or a negative number means there is no limit
+     * @see #setTimeout(long, TimeUnit)
+     */
+    public void setTimeout(long timeout);
+
+    /**
+     * Set the amount of time to wait for a <code>SparqlStatement</code> to return the first result.
+     * @param timeout the new query timeout limit in <code>timeoutUnits</code>; zero or a negative number means there is no limit
+     * @param timeoutUnits the time units in which <code>timeout</code> is specified
+     */
+    public void setTimeout(long timeout, TimeUnit timeoutUnits);
+
+    /**
+     * Set the number of milliseconds to wait for execution; the first timeout refers to time to first result, the second
+     * refers to overall query execution after the first result.  Processing will be aborted if a timeout expires. 
+     * @param timeout1   the new timeout limit for the first result in milliseconds; zero or a negative number means there is no limit 
+     * @param timeout2   the new timeout limit for the total execution time in milliseconds; zero or a negative number means there is no limit
+     */
+    public void setTimeout(long timeout1, long timeout2);
+
+    /**
+     * Set timeouts on the query execution; the first timeout refers to time to first result, the second
+     * refers to overall query execution after the first result.  Processing will be aborted if a timeout expires. 
+     * @param timeout1   the new timeout limit for the first result in <code>timeUnit1</code>; zero or a negative number means there is no limit 
+     * @param timeUnit1  the time units in which <code>timeout1</code> is specified
+     * @param timeout2   the new timeout limit for the total execution time in <code>timeUnit2</code>; zero or a negative number means there is no limit
+     * @param timeUnit2  the time units in which <code>timeUnit2</code> is specified
+     */
+    public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2);
+
+}
\ No newline at end of file

Added: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatementBase.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatementBase.java?rev=1372261&view=auto
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatementBase.java (added)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/SparqlStatementBase.java Mon Aug 13 04:30:10 2012
@@ -0,0 +1,53 @@
+package org.apache.jena.client;
+
+import java.util.concurrent.TimeUnit;
+
+abstract class SparqlStatementBase implements SparqlStatement
+{
+
+    protected final Connection connection;
+    protected long timeout1 = -1;
+    protected long timeout2 = -1;
+    
+    
+    protected SparqlStatementBase(Connection connection)
+    {
+        this.connection = connection;
+    }
+    
+    @Override
+    public Connection getConnection()
+    {
+        return connection;
+    }
+
+    @Override
+    public void setTimeout(long timeout)
+    {
+        setTimeout(timeout, TimeUnit.MILLISECONDS);
+    }
+
+    @Override
+    public void setTimeout(long timeout, TimeUnit timeoutUnits)
+    {
+        setTimeout(timeout, timeoutUnits, 0, TimeUnit.MILLISECONDS);
+    }
+
+    @Override
+    public void setTimeout(long timeout1, long timeout2)
+    {
+        setTimeout(timeout1, TimeUnit.MILLISECONDS, timeout2, TimeUnit.MILLISECONDS);
+    }
+
+    @Override
+    public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2)
+    {
+        timeout1 = asMillis(timeout1, timeUnit1);
+        timeout2 = asMillis(timeout2, timeUnit2);
+    }
+
+    private static long asMillis(long duration, TimeUnit timeUnit)
+    {
+        return (duration < 0 ) ? duration : timeUnit.toMillis(duration) ;
+    }
+}
\ No newline at end of file

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerier.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerier.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerier.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerier.java Mon Aug 13 04:30:10 2012
@@ -25,8 +25,6 @@ public interface UpdateQuerier extends C
      */
     void update(String updateQuery, String baseURI);
     
-    void update(UpdateStatement updateStmt);
-    
 //    void update(String updateQuery, Syntax syntax);
     
     void update(Update update);

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerierWrapper.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerierWrapper.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerierWrapper.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateQuerierWrapper.java Mon Aug 13 04:30:10 2012
@@ -30,12 +30,6 @@ class UpdateQuerierWrapper implements Up
     {
         wrappedObject.update(updateQuery, baseURI);
     }
-    
-    @Override
-    public void update(UpdateStatement updateStmt)
-    {
-        wrappedObject.update(updateStmt);
-    }
 
     @Override
     public void update(Update update)

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatement.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatement.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatement.java Mon Aug 13 04:30:10 2012
@@ -7,53 +7,11 @@ package org.apache.jena.client;
  * 
  * @see Connection#createUpdateStatement
  */
-public interface UpdateStatement extends Parameterizer
+public interface UpdateStatement extends SparqlStatement
 {
+
     /**
-     * Retrieves the {@link Connection} object that produced this <code>QueryStatement</code> object.
-     * @return the connection that produced this statement
-     * @throws SPARQLException if a database access error occurs or this method is called on a closed <code>QueryStatement</code>
+     * Execute an UPDATE query.
      */
-    Connection getConnection();
-    
-//    /**
-//     * Execute an UPDATE query.
-//     */
-//    void execUpdate();
-//    
-//    /**
-//     * Cancels this <code>UpdateStatement</code> object mid-execution if the implementation supports it.
-//     * This method can be called by a different thread than is currently executing the query.  There
-//     * is no guarantee that the concrete implementation actually will stop or that it will do so immediately.
-//     * <p/>
-//     * If the connection is not Transactional, then there are also no guarantees that implementation will honor
-//     * atomicity requirements.  It may be possible for the update to be partially applied to the database.
-//     * <p/>
-//     * No operations on the statement are permitted after this call and may cause exceptions to be thrown.
-//     */
-//    void cancel();
-//    
-//    // TODO Need to update the implementations to follow the timeout behavior specified here, specifically the zero and negative timeout
-//    // TODO We need to emphasize that these are client-side options only.  The server may enforce different timeouts.
-//    /**
-//     * Set the number of milliseconds to wait for an Update to be applied.
-//     * @param timeout the new query timeout limit in milliseconds; zero or a negative number means there is no limit
-//     * @see #setTimeout(long, TimeUnit)
-//     */
-//    void setTimeout(long timeout);
-//    
-//    /**
-//     * Set the number of milliseconds to wait for an Update to be applied.
-//     * @param timeout the new query timeout limit in <code>timeoutUnits</code>; zero or a negative number means there is no limit
-//     * @param timeoutUnits the time units in which <code>timeout</code> is specified
-//     */
-//    void setTimeout(long timeout, TimeUnit timeoutUnits);
-    
-    
-    /**
-     * Returns the Update as a String.
-     * @return the update represented as a String.
-     */
-    @Override
-    String toString();
+    void execUpdate();
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java Mon Aug 13 04:30:10 2012
@@ -1,59 +1,72 @@
 package org.apache.jena.client;
 
+import java.util.Arrays;
 
-public abstract class UpdateStatementBase extends ParameterizerBase implements UpdateStatement
+import com.hp.hpl.jena.update.Update;
+
+
+public abstract class UpdateStatementBase extends SparqlStatementBase implements UpdateStatement
 {
-    protected final Connection connection;
-    private long timeout1;
+    protected final String updateString;
+    protected final Iterable<? extends Update> updates;
     
-    public UpdateStatementBase(Connection connection)
+    private Updater updater;
+    
+    public UpdateStatementBase(String updateString, Connection connection)
     {
-        this.connection = connection;
+        super(connection);
+        this.updateString = updateString;
+        this.updates = null;
     }
     
-//    public abstract void doExecUpdate();
-//    
-//    @Override
-//    public abstract void cancel();
+    public UpdateStatementBase(Update update, Connection connection)
+    {
+        this(Arrays.asList(update), connection);
+    }
     
-
-    @Override
-    public Connection getConnection()
+    public UpdateStatementBase(Iterable<? extends Update> updates, Connection connection)
     {
-        return connection;
+        super(connection);
+        this.updateString = null;
+        this.updates = updates;
     }
     
+    @Override
+    public void execUpdate()
+    {
+        updater = connection.createStreamingUpdater();
+        try
+        {
+            if (null != updateString)
+            {
+                updater.update(updateString);
+            }
+            else
+            {
+                updater.update(updates);
+            }
+        }
+        finally
+        {
+            if (null != updater)
+            {
+                updater.close();
+            }
+        }
+    }
 
-//    @Override
-//    public void execUpdate()
-//    {
-//        startTimer();
-//        doExecUpdate();
-//    }
-//
-//    @Override
-//    public void setTimeout(long timeout)
-//    {
-//        setTimeout(timeout, TimeUnit.MILLISECONDS);
-//    }
-//
-//    @Override
-//    public void setTimeout(long timeout, TimeUnit timeoutUnits)
-//    {
-//        timeout1 = asMillis(timeout, timeoutUnits);
-//    }
-//    
-//    protected void startTimer()
-//    {
-//        // TODO what are the semantics of the timeouts?  Does it even make sense for Update queries?
-//        
-//        //if (timeoutExpired) cancel();
-//    }
-//    
-//    
-//    private static long asMillis(long duration, TimeUnit timeUnit)
-//    {
-//        return (duration < 0 ) ? duration : timeUnit.toMillis(duration) ;
-//    }
+    @Override
+    public void close()
+    {
+        if (null != updater)
+        {
+            updater.close();
+        }
+    }
     
+    @Override
+    public void cancel()
+    {
+        // TODO cancel an update?
+    }
 }

Added: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementWrapper.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementWrapper.java?rev=1372261&view=auto
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementWrapper.java (added)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementWrapper.java Mon Aug 13 04:30:10 2012
@@ -0,0 +1,61 @@
+package org.apache.jena.client;
+
+import java.util.concurrent.TimeUnit;
+
+class UpdateStatementWrapper implements UpdateStatement
+{
+    private final UpdateStatement wrappedObject;
+    
+    public UpdateStatementWrapper(UpdateStatement updateStatement)
+    {
+        this.wrappedObject = updateStatement;
+    }
+
+    @Override
+    public void execUpdate()
+    {
+        wrappedObject.execUpdate();
+    }
+
+    @Override
+    public Connection getConnection()
+    {
+        return wrappedObject.getConnection();
+    }
+
+    @Override
+    public void close()
+    {
+        wrappedObject.close();
+    }
+
+    @Override
+    public void cancel()
+    {
+        wrappedObject.cancel();
+    }
+
+    @Override
+    public void setTimeout(long timeout)
+    {
+        wrappedObject.setTimeout(timeout);
+    }
+
+    @Override
+    public void setTimeout(long timeout, TimeUnit timeoutUnits)
+    {
+        wrappedObject.setTimeout(timeout, timeoutUnits);
+    }
+
+    @Override
+    public void setTimeout(long timeout1, long timeout2)
+    {
+        wrappedObject.setTimeout(timeout1, timeout2);
+    }
+
+    @Override
+    public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2)
+    {
+        wrappedObject.setTimeout(timeout1, timeUnit1, timeout2, timeUnit2);
+    }
+}

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterBase.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterBase.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterBase.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterBase.java Mon Aug 13 04:30:10 2012
@@ -71,12 +71,6 @@ public abstract class UpdaterBase implem
         update(UpdateFactory.create(updateQuery, baseURI));
     }
     
-    @Override
-    public void update(UpdateStatement updateStmt)
-    {
-        update(updateStmt.toString());
-    }
-    
 //    @Override
 //    public void update(String updateQuery, Syntax syntax)
 //    {

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterWrapper.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterWrapper.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterWrapper.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdaterWrapper.java Mon Aug 13 04:30:10 2012
@@ -194,12 +194,6 @@ class UpdaterWrapper implements Updater
     {
         wrappedObject.update(updateQuery, baseURI);
     }
-    
-    @Override
-    public void update(UpdateStatement updateStmt)
-    {
-        wrappedObject.update(updateStmt);
-    }
 
     @Override
     public void update(Update update)

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java Mon Aug 13 04:30:10 2012
@@ -2,7 +2,6 @@ package org.apache.jena.client.graph;
 
 import org.apache.jena.client.ConnectionBase;
 import org.apache.jena.client.QueryStatement;
-import org.apache.jena.client.Repository;
 import org.apache.jena.client.UpdateStatement;
 import org.apache.jena.client.Updater;
 
@@ -14,28 +13,22 @@ import com.hp.hpl.jena.update.Update;
 
 public class DatasetGraphConnection extends ConnectionBase
 {
-    private final DatasetGraphRepository repo;
     private final DatasetGraph dsg;
     
     DatasetGraphConnection(DatasetGraphRepository repo, DatasetGraph dsg)
     {
-        if (null == repo)
-        {
-            throw new IllegalArgumentException("repo must not be null");
-        }
-        
-        this.repo = repo;
+        super(repo);
         this.dsg = dsg;
     }
     
     @Override
-    public boolean hasBulkUpdater()
+    public boolean hasStreamingUpdater()
     {
         return true;
     }
     
     @Override
-    protected Updater doCreateBulkUpdater()
+    protected Updater doCreateStreamingUpdater()
     {
         DatasetGraphUpdater updater = new DatasetGraphUpdater(dsg);
         updater.open();
@@ -43,35 +36,33 @@ public class DatasetGraphConnection exte
     }
     
     @Override
-    public Repository getRepository()
-    {
-        return repo;
-    }
-    
-    @Override
-    public QueryStatement createQueryStatement(String queryString)
+    public QueryStatement doCreateQueryStatement(String queryString)
     {
         return new DatasetGraphQueryStatement(queryString, dsg, this);
     }
 
     @Override
-    public QueryStatement createQueryStatement(Query query)
+    public QueryStatement doCreateQueryStatement(Query query)
     {
-        // TODO Auto-generated method stub
-        return null;
+        return new DatasetGraphQueryStatement(query, dsg, this);
     }
     
     @Override
-    public UpdateStatement createUpdateStatement(String updateString)
+    public UpdateStatement doCreateUpdateStatement(String updateString)
     {
         return new DatasetGraphUpdateStatement(updateString, this);
     }
 
     @Override
-    public UpdateStatement createUpdateStatement(Update update)
+    public UpdateStatement doCreateUpdateStatement(Update update)
+    {
+        return new DatasetGraphUpdateStatement(update, this);
+    }
+    
+    @Override
+    public UpdateStatement doCreateUpdateStatement(Iterable<? extends Update> updates)
     {
-        // TODO Auto-generated method stub
-        return null;
+        return new DatasetGraphUpdateStatement(updates, this);
     }
     
     @Override

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java Mon Aug 13 04:30:10 2012
@@ -1,83 +1,37 @@
 package org.apache.jena.client.graph;
 
-import java.util.Iterator;
-
 import org.apache.jena.client.QueryStatement;
 import org.apache.jena.client.QueryStatementBase;
 
-import com.hp.hpl.jena.graph.Triple;
+import com.hp.hpl.jena.query.Query;
 import com.hp.hpl.jena.query.QueryExecution;
 import com.hp.hpl.jena.query.QueryExecutionFactory;
-import com.hp.hpl.jena.query.ResultSet;
 import com.hp.hpl.jena.sparql.core.DatasetGraph;
 import com.hp.hpl.jena.sparql.core.DatasetImpl;
 
-class DatasetGraphQueryStatement extends QueryStatementBase implements QueryStatement
+class DatasetGraphQueryStatement extends QueryStatementBase<QueryExecution> implements QueryStatement
 {
-    private final String queryString;
     private final DatasetGraph dsg;
     
-    private Object lock = new Object();
-    private QueryExecution qe;
-    
     DatasetGraphQueryStatement(String queryString, DatasetGraph dsg, DatasetGraphConnection connection)
     {
-        super(connection);
-        this.queryString = queryString;
+        super(queryString, connection);
         this.dsg = dsg;
     }
     
-    private QueryExecution createQueryExecution()
+    DatasetGraphQueryStatement(Query query, DatasetGraph dsg, DatasetGraphConnection connection)
     {
-        // TODO Handle Query object in addition to QueryString
-        String sparql = toString();
-        QueryExecution qe = QueryExecutionFactory.create(sparql, DatasetImpl.wrap(dsg));
-        // TODO Set the options on qe, such as timeouts
-        synchronized (lock)
-        {
-            this.qe = qe;
-        }
-        return qe;
+        super(query, connection);
+        this.dsg = dsg;
     }
     
     @Override
-    public ResultSet doExecSelect()
+    protected QueryExecution createQueryExecution()
     {
-        return createQueryExecution().execSelect();
-    }
-
-    @Override
-    public Iterator<Triple> doExecConstructTriples()
-    {
-        return createQueryExecution().execConstructTriples();
-    }
-
-    @Override
-    public Iterator<Triple> doExecDescribeTriples()
-    {
-        return createQueryExecution().execDescribeTriples();
-    }
-
-    @Override
-    public boolean doExecAsk()
-    {
-        return createQueryExecution().execAsk();
-    }
-
-    @Override
-    public void cancel()
-    {
-        synchronized (lock)
-        {
-            if (null != qe)
-            {
-                qe.abort();
-            }
-        }
-    }
-
-    public String toString()
-    {
-        return buildFromString(queryString, null);
+        QueryExecution qe = (null != queryString) ?
+            QueryExecutionFactory.create(queryString, DatasetImpl.wrap(dsg)) :
+            QueryExecutionFactory.create(queryObject, DatasetImpl.wrap(dsg));
+        return qe;
     }
+    
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdateStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdateStatement.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdateStatement.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdateStatement.java Mon Aug 13 04:30:10 2012
@@ -1,34 +1,23 @@
 package org.apache.jena.client.graph;
 
-import org.apache.jena.client.UpdateStatement;
 import org.apache.jena.client.UpdateStatementBase;
 
-class DatasetGraphUpdateStatement extends UpdateStatementBase implements UpdateStatement
+import com.hp.hpl.jena.update.Update;
+
+public class DatasetGraphUpdateStatement extends UpdateStatementBase
 {
-    private final String updateString;
-    
     DatasetGraphUpdateStatement(String updateString, DatasetGraphConnection connection)
     {
-        super(connection);
-        this.updateString = updateString;
+        super(updateString, connection);
     }
     
-//    @Override
-//    public void doExecUpdate()
-//    {
-//        String sparql = buildFromString(updateString, null);
-//        connection.update(sparql);
-//    }
-//
-//    @Override
-//    public void cancel()
-//    {
-//        // TODO
-//    }
-
-    @Override
-    public String toString()
+    DatasetGraphUpdateStatement(Update update, DatasetGraphConnection connection)
+    {
+        super(update, connection);
+    }
+    
+    DatasetGraphUpdateStatement(Iterable<? extends Update> updates, DatasetGraphConnection connection)
     {
-        return buildFromString(updateString, null);
+        super(updates, connection);
     }
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java Mon Aug 13 04:30:10 2012
@@ -2,7 +2,6 @@ package org.apache.jena.client.http;
 
 import org.apache.jena.client.ConnectionBase;
 import org.apache.jena.client.QueryStatement;
-import org.apache.jena.client.Repository;
 import org.apache.jena.client.UpdateStatement;
 import org.apache.jena.client.Updater;
 
@@ -12,21 +11,14 @@ import com.hp.hpl.jena.update.Update;
 
 public class HttpConnection extends ConnectionBase
 {
-    private final HttpRepository repo;
-    
-    private String queryEndpoint;
-    private String updateEndpoint;
+    private final String queryEndpoint;
+    private final String updateEndpoint;
     
     private boolean useContentTypeSPARQLUpdate = true;
     
     HttpConnection(HttpRepository repo, String queryEndpoint, String updateEndpoint)
     {
-        if (null == repo)
-        {
-            throw new IllegalArgumentException("repo must not be null");
-        }
-        
-        this.repo = repo;
+        super(repo);
         this.queryEndpoint = queryEndpoint;
         this.updateEndpoint = updateEndpoint;
     }
@@ -44,13 +36,13 @@ public class HttpConnection extends Conn
     }
     
     @Override
-    public boolean hasBulkUpdater()
+    public boolean hasStreamingUpdater()
     {
         return true;
     }
     
     @Override
-    protected Updater doCreateBulkUpdater()
+    protected Updater doCreateStreamingUpdater()
     {
         HttpUpdater updater = new HttpUpdater(updateEndpoint, useContentTypeSPARQLUpdate);
         updater.open();
@@ -58,35 +50,33 @@ public class HttpConnection extends Conn
     }
     
     @Override
-    public Repository getRepository()
-    {
-        return repo;
-    }
-    
-    @Override
-    public QueryStatement createQueryStatement(String queryString)
+    public QueryStatement doCreateQueryStatement(String queryString)
     {
         return new HttpQueryStatement(queryString, queryEndpoint, this);
     }
 
     @Override
-    public QueryStatement createQueryStatement(Query query)
+    public QueryStatement doCreateQueryStatement(Query query)
     {
-        // TODO Auto-generated method stub
-        return null;
+        return new HttpQueryStatement(query, queryEndpoint, this);
     }
     
     @Override
-    public UpdateStatement createUpdateStatement(String updateString)
+    public UpdateStatement doCreateUpdateStatement(String updateString)
     {
         return new HttpUpdateStatement(updateString, this);
     }
 
     @Override
-    public UpdateStatement createUpdateStatement(Update update)
+    public UpdateStatement doCreateUpdateStatement(Update update)
+    {
+        return new HttpUpdateStatement(update, this);
+    }
+    
+    @Override
+    public UpdateStatement doCreateUpdateStatement(Iterable<? extends Update> updates)
     {
-        // TODO Auto-generated method stub
-        return null;
+        return new HttpUpdateStatement(updates, this);
     }
     
     @Override
@@ -127,80 +117,4 @@ public class HttpConnection extends Conn
         return false;
     }
     
-//    @Override
-//    public Service getServices()
-//    {
-//        // TODO Auto-generated method stub
-//        return null;
-//    }
-//
-//
-//    @Override
-//    public void setQueryService(QueryService service)
-//    {
-//        // TODO Auto-generated method stub
-//
-//    }
-//
-//    @Override
-//    public void setUpdateService(UpdateService service)
-//    {
-//        // TODO Auto-generated method stub
-//
-//    }
-//
-//    @Override
-//    public void setBulkService(UpdateService service)
-//    {
-//        // TODO Auto-generated method stub
-//
-//    }
-//
-//    @Override
-//    public QueryService getQueryService()
-//    {
-//        // TODO Auto-generated method stub
-//        return null;
-//    }
-//
-//    @Override
-//    public UpdateService getUpdateService()
-//    {
-//        // TODO Auto-generated method stub
-//        return null;
-//    }
-//
-//    @Override
-//    public UpdateService getBulkService()
-//    {
-//        // TODO Auto-generated method stub
-//        return null;
-//    }
-
-    
-//  /**
-//  * @throws IllegalArgumentException if the QueryService is not a SparqlHttpQueryService
-//  */
-// private SparqlHttpQueryService castUp(QueryService queryService)
-// {
-//     if (!(queryService instanceof SparqlHttpUpdateService))
-//     {
-//         throw new IllegalArgumentException(String.format("%1$s only accepts %2$s for %3$s",
-//                 SparqlHttpConnection.class.getSimpleName(), SparqlHttpQueryService.class.getSimpleName(), QueryService.class.getSimpleName()));
-//     }
-//     return (SparqlHttpQueryService)queryService;
-// }
-// 
-// /**
-//  * @throws IllegalArgumentException if the UpdateService is not a SparqlHttpUpdateService
-//  */
-// private SparqlHttpUpdateService castUp(UpdateService updateService)
-// {
-//     if (!(updateService instanceof SparqlHttpUpdateService))
-//     {
-//         throw new IllegalArgumentException(String.format("%1$s only accepts %2$s for %3$s",
-//                 SparqlHttpConnection.class.getSimpleName(), SparqlHttpUpdateService.class.getSimpleName(), UpdateService.class.getSimpleName()));
-//     }
-//     return (SparqlHttpUpdateService)updateService;
-// }
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java Mon Aug 13 04:30:10 2012
@@ -1,67 +1,32 @@
 package org.apache.jena.client.http;
 
-import java.util.Iterator;
-
 import org.apache.jena.client.QueryStatement;
 import org.apache.jena.client.QueryStatementBase;
 
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.query.Query;
 import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;
 
-class HttpQueryStatement extends QueryStatementBase implements QueryStatement
+class HttpQueryStatement extends QueryStatementBase<QueryEngineHTTP> implements QueryStatement
 {
-    private final String queryString;
     private final String queryEndpoint;
     
     HttpQueryStatement(String queryString, String queryEndpoint, HttpConnection connection)
     {
-        super(connection);
-        this.queryString = queryString;
+        super(queryString, connection);
         this.queryEndpoint = queryEndpoint;
     }
     
-    private QueryEngineHTTP createQueryExecution()
+    HttpQueryStatement(Query query, String queryEndpoint, HttpConnection connection)
     {
-        // TODO Handle Query object in addition to QueryString
-        String sparql = toString();
-        QueryEngineHTTP qe = new QueryEngineHTTP(queryEndpoint, sparql);
-        // TODO Set the options on qe, such as timeouts
-        return qe;
+        super(query, connection);
+        this.queryEndpoint = queryEndpoint;
     }
     
-    @Override
-    public ResultSet doExecSelect()
-    {
-        return createQueryExecution().execSelect();
-    }
-
-    @Override
-    public Iterator<Triple> doExecConstructTriples()
+    protected QueryEngineHTTP createQueryExecution()
     {
-        return createQueryExecution().execConstructTriples();
-    }
-
-    @Override
-    public Iterator<Triple> doExecDescribeTriples()
-    {
-        return createQueryExecution().execDescribeTriples();
-    }
-
-    @Override
-    public boolean doExecAsk()
-    {
-        return createQueryExecution().execAsk();
-    }
-
-    @Override
-    public void cancel()
-    {
-        // TODO
-    }
-
-    public String toString()
-    {
-        return buildFromString(queryString, null);
+        QueryEngineHTTP qe = (null != queryString) ?
+            new QueryEngineHTTP(queryEndpoint, queryString) :
+            new QueryEngineHTTP(queryEndpoint, queryObject);
+        return qe;
     }
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdateStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdateStatement.java?rev=1372261&r1=1372260&r2=1372261&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdateStatement.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdateStatement.java Mon Aug 13 04:30:10 2012
@@ -1,34 +1,23 @@
 package org.apache.jena.client.http;
 
-import org.apache.jena.client.UpdateStatement;
 import org.apache.jena.client.UpdateStatementBase;
 
-class HttpUpdateStatement extends UpdateStatementBase implements UpdateStatement
+import com.hp.hpl.jena.update.Update;
+
+class HttpUpdateStatement extends UpdateStatementBase
 {
-    private final String updateString;
-    
     HttpUpdateStatement(String updateString, HttpConnection connection)
     {
-        super(connection);
-        this.updateString = updateString;
+        super(updateString, connection);
     }
     
-//    @Override
-//    public void doExecUpdate()
-//    {
-//        String sparql = buildFromString(updateString, null);
-//        connection.update(sparql);
-//    }
-//
-//    @Override
-//    public void cancel()
-//    {
-//        // TODO
-//    }
-
-    @Override
-    public String toString()
+    HttpUpdateStatement(Update update, HttpConnection connection)
+    {
+        super(update, connection);
+    }
+    
+    HttpUpdateStatement(Iterable<? extends Update> updates, HttpConnection connection)
     {
-        return buildFromString(updateString, null);
+        super(updates, connection);
     }
 }