You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by jb...@apache.org on 2002/03/13 18:52:03 UTC

cvs commit: xml-xindice/java/src/org/apache/xindice/client/rpc CollectionHandle.java CollectionService.java DatabaseService.java EncodedBuffer.java KernelService.java NamedVal.java RPCException.java

jbates      02/03/13 09:52:03

  Added:       java/src/org/apache/xindice/client/rpc CollectionHandle.java
                        CollectionService.java DatabaseService.java
                        EncodedBuffer.java KernelService.java NamedVal.java
                        RPCException.java
  Log:
  First draft RPC-able interface for client/server communication in Xindice
  
  Revision  Changes    Path
  1.1                  xml-xindice/java/src/org/apache/xindice/client/rpc/CollectionHandle.java
  
  Index: CollectionHandle.java
  ===================================================================
  /*
   * CollectionHandle.java: contains CollectionHandler interface
   *
   * Created on 13 March 2002, 17:25
   */
  
  package org.apache.xindice.client.rpc;
  
  /**
   * This is a serializable "handle" to a collection, that can be sent over
   * RPC. It is basically a wrapper around a Java string, which must be chosen
   * to uniquely identify the collection.
   *
   * @author James Bates <ja...@amplexor.com>
   * @version 1.0
   */
  public class CollectionHandle implements java.io.Serializable {
  
      /** identifier string for collection */
      private String id = "";
      
      /**
       * Creates new <code>CollectionHandle</code> with specified id string
       */
      public CollectionHandle(String id) {
          
          this.id = id;
      }
  
      /**
       * Returns the identifier string for this collection
       *
       * @return the identifier string
       */
      public String toString() {
          
          return id;
      }
      
      /**
       * Sets identifier string for collection
       *
       * @param id the identifier string
       */
      public void setId(String id) {
          
          this.id = id;
      }
      
      /**
       * Returns the identifier string for this collection
       *
       * @return the identifier string
       */
      public String getId() {
          
          return id;
      }
  }
  
  
  
  1.1                  xml-xindice/java/src/org/apache/xindice/client/rpc/CollectionService.java
  
  Index: CollectionService.java
  ===================================================================
  /*
   * CollectionService.java: implements CollectionService interface
   *
   * Created on 13 March 2002, 17:35
   */
  
  package org.apache.xindice.client.rpc;
  
  /**
   * RPC-able interface that provides functions that operate on collections. 
   *
   * @author James Bates <ja...@amplexor.com>
   * @version 1.0
   */
  public interface CollectionService {
  
      /**
       * Returns the collection name
       *
       * @param ch handle to collection
       */
      public String getName(CollectionHandle ch) throws RPCException;
      
      /**
       * Returns the collection canonical name
       *
       * @param ch handle to collection
       */
      public String getCanonicalName(CollectionHandle ch) throws RPCException;
      
      /**
       * Returns handle to parent collection of specified collection
       *
       * @param ch handle to collection to return parent of
       * @return handle to parent of <code>ch</code>
       */
      public CollectionHandle getParentCollection(CollectionHandle ch) throws RPCException;
      
      /**
       * Returns names of all child collections contained in specified
       * collection.
       *
       * @param ch handle to collectionm
       * @return array containing names of child collections.
       */
      public String[] listCollections(CollectionHandle ch) throws RPCException;
      
      /**
       * Returns handle to named child of specified collection
       *
       * @param ch handle to parent collection
       * @param child collection name
       * @return handle to child collection
       */
      public CollectionHandle getCollection(CollectionHandle ch, String name)
              throws RPCException;
      
      /**
       * Creates new child collection inside specified collection
       *
       * @param ch handle to parent collection
       * @param name name for new child collection
       * @return handle to new child collection
       */
      public CollectionHandle createCollection(CollectionHandle ch, String name) throws RPCException;
      
      /**
       * Drops child collection of specified collection.
       *
       * @param ch handle to parent collection
       * @param name name of child collection to drop
       */
      public void dropCollection(CollectionHandle ch, String name) throws RPCException;
      
      /**
       * Returns list of all XML object names defined in collection
       *
       * @param ch handle to collection
       * @return array containing names of indexers. May be empty, but not
       *         <code>null</code>
       */
      public String[] listXMLObjects(CollectionHandle ch) throws RPCException;
      
      /**
       * Builds new XML object in specified collection, according to configurtation
       * supplied in <code>config</code>.
       *
       * @param ch handle to collection
       * @param config buffer containing configuration for new XML object
       */
      public void createXMLObject(CollectionHandle ch, EncodedBuffer config) throws RPCException;
      
      /**
       * Drops XML object from specified collection
       *
       * @param ch handle to collection
       * @parma name name of XML object to drop
       */
      public void dropXMLObject(CollectionHandle ch, String name) throws RPCException;
      
      /**
       * Returns list of all indexers defined on specified collection
       *
       * @param ch handle to collection
       * @return array containing names of indexers. May be empty, but not
       *         <code>null</code>
       */
      public String[] listIndexers(CollectionHandle ch) throws RPCException;
      
      /**
       * Builds new indexer for collection, according to configurtation supplied
       * into specified collection
       *
       * @param ch handle to collection
       * @param config buffer containing configuration for new indexer
       */
      public void createIndexer(CollectionHandle ch, EncodedBuffer config) throws RPCException;
      
      /**
       * Drops indexer from specified collection
       *
       * @param ch handle to collection
       * @parma name name of indexer to drop
       */
      public void dropIndexer(CollectionHandle ch, String name) throws RPCException;
      
      /**
       * Gets content of named XML resource in specified collection
       *
       * @param ch handle to collection
       * @param name document name
       * @return content of document, as encoded XML buffer
       */
      public EncodedBuffer getDocument(CollectionHandle ch, String name) throws RPCException;
      
      /**
       * Sets contents of named XML resource in specified collection
       *
       * @param ch handle to collection
       * @parma name document name
       * @param doc document content
       */
      public void setDocument(CollectionHandle ch, String name, EncodedBuffer buf)
              throws RPCException;
      
      /**
       * Lists names of documents in specified collection
       *
       * @param ch handle to collection
       * @return names of documents
       */
      public String[] listDocuments(CollectionHandle ch) throws RPCException;
      
      /**
       * Returns number of documents in collection.\
       *
       * @param ch handle to collection
       */    
      public int getDocumentCount(CollectionHandle ch) throws RPCException;
              
      /**
       * Inserts new document into specified collection
       *
       * @param ch handle to collection
       * @param name for new document. If empty, a name will be generated
       * @param doc content for new document
       */
      public String insertDocument(CollectionHandle ch, String name, EncodedBuffer doc)
              throws RPCException;
      
      /**
       * Removes document from collection
       *
       * @param ch handle to collection
       * @param name name of document to remove
       */
      public void removeDocument(CollectionHandle ch, String name) throws RPCException;
      
      /**
       * Creates a new unique OID for specified collection
       *
       * @param ch handle to collection
       * @return the oid as a string
       */
      public String createNewOID() throws RPCException;
      
      /**
       * Executes a query against specified collection
       *
       * @param ch handle to collection
       * @param style query style (XPath or XUpdate)
       * @param query query string
       * @param namespaces namespace bindings used in query string
       * @param stamp ??? 
       * @return query result as an XML buffer
       */
      public EncodedBuffer queryCollection(CollectionHandle ch, String style,
              String query, NamedVal[] namespaces, long stamp) throws RPCException;
      
      
      /**
       * Executes a query against document in specified collection
       *
       * @param ch handle to collection
       * @param style query style (XPath or XUpdate)
       * @param query query string
       * @param namespaces namespace bindings used in query string
       * @parma name name of document in <code>ch</code> to query
       * @param stamp ??? 
       * @return query result as an XML buffer
       */
      public EncodedBuffer queryCollection(CollectionHandle ch, String style,
              String query, NamedVal[] namespaces, String name, long stamp) throws RPCException;
      
      
      /**
       * Invokes an XML object using provided uri. The URI must include the full
       * path to the XMLObject including the method name and all parameters.
       *
       * @param ch handle to collection containing XML object
       * @param uir The URI to use to locate and invoke the XML object
       * @return an encoded buffer containing the invokation result
       */
      public EncodedBuffer invokeXMLObject(CollectionHandle ch, String uri) throws RPCException;
      
  }
  
  
  
  
  1.1                  xml-xindice/java/src/org/apache/xindice/client/rpc/DatabaseService.java
  
  Index: DatabaseService.java
  ===================================================================
  /*
   * DatabaseService.java: contains DatabaseService interface
   *
   * Created on 13 March 2002, 16:55
   */
  
  package org.apache.xindice.client.rpc;
  
  /**
   * This is an RPC-able interface for Xindice databases. It can be exported 
   * through either XML-RPC or SOAP or some other RPC mechanism.
   *
   * @author James Bates <ja...@amplexor.com>
   * @version 1.0
   */
  public interface DatabaseService {
  
      /**
       * Returns name of database
       *
       * @return name
       */
      public String getName() throws RPCException;
      
      /**
       * Returns list of collection names contained in this database
       *
       * @return array containing collection names. May be empty, but
       *         not <code>null</code>.
       */
      public String[] getCollections() throws RPCException;
      
      /**
       * Returns handle to requested collection.
       *
       * @return collection handler
       */
      public CollectionHandle getCollection(String name) throws RPCException;
  }
  
  
  
  
  1.1                  xml-xindice/java/src/org/apache/xindice/client/rpc/EncodedBuffer.java
  
  Index: EncodedBuffer.java
  ===================================================================
  /*
   * EncodedBuffer.java: contains EncodedBuffer class
   *
   * Created on 13 March 2002, 17:41
   */
  
  package org.apache.xindice.client.rpc;
  
  /**
   * Provides document buffers that can be passed over RPC.
   *
   * @author James Bates <ja...@amplexor.com>
   * @version 
   */
  public class EncodedBuffer {
  
      /** timestamp */
      private long stamp;
      
      /** symbol table bytes */
      private byte[] sym;
      
      /** content buffer */
      private byte[] buf;
      
      /**
       * Creates new empty <code>EncodedBuffer</code>
       */
      public EncodedBuffer() {
          
          stamp = -1L;
          sym = new byte[0];
          buf = new byte[0];
      }
     
      /**
       * Creates new <code>EncodedBuffer</code> with filled out data fields
       *
       * @param stamp timestamp
       * @param sym symbol table bytes
       * @param buf content buffer
       */
      public EncodedBuffer(long stamp, byte[] sym, byte[] buf) {
  
          this.stamp = stamp;
          this.sym = sym;
          this.buf = buf;
      }
      
      /**
       * Getter for property stamp.
       *
       * @return Value of property stamp.
       */
      public long getStamp() {
          return stamp;
      }
      
      /**
       * Setter for property stamp.
       *
       * @param stamp New value of property stamp.
       */
      public void setStamp(long stamp) {
          this.stamp = stamp;
      }
      
      /**
       * Getter for property sym.
       *
       * @return Value of property sym.
       */
      public byte[] getSym() {
          return sym;
      }
      
      /**
       * Setter for property sym.
       *
       * @param sym New value of property sym.
       */
      public void setSym(byte[] sym) {
          this.sym = sym;
      }
      
      /**
       * Getter for property buf.
       *
       * @return Value of property buf.
       */
      public byte[] getBuf() {
          return buf;
      }
      
      /**
       * Setter for property buf.
       *
       * @param buf New value of property buf.
       */
      public void setBuf(byte[] buf) {
          this.buf = buf;
      }
     
  
  }
  
  
  
  1.1                  xml-xindice/java/src/org/apache/xindice/client/rpc/KernelService.java
  
  Index: KernelService.java
  ===================================================================
  /*
   * KernelService.java: contains KernelService interface
   *
   * Created on 13 March 2002, 17:14
   */
  
  package org.apache.xindice.client.rpc;
  
  
  /**
   * Provides RPC-able interface to the Xindice services kernel. This interface
   * can be exposed by XML-RPC or SOAP, or some other RPC mechanism.
   *
   * @author James Bates <ja...@amplexor.com>
   * @version 1.0
   */
  public interface KernelService {
  
      /**
       * Shuts down Xindice services kernel
       */
      public void shutdown() throws RPCException;
  }
  
  
  
  
  1.1                  xml-xindice/java/src/org/apache/xindice/client/rpc/NamedVal.java
  
  Index: NamedVal.java
  ===================================================================
  /*
   * NamedVal.java: contains NamedVal class
   *
   * Created on 13 March 2002, 18:38
   */
  
  package org.apache.xindice.client.rpc;
  
  /**
   * Represents a (name,value) pair of string
   *
   * @author James Bates <ja...@amplexor.com>
   * @version 1.0
   */
  public class NamedVal {
  
      /** Holds value of property name. */
      private String name;
      
      /** Holds value of property value. */
      private String value;
      
      /**
       * Creates new NamedVal with empty properties
       */
      public NamedVal() {
      }
  
      /**
       * Builds new <code>NamedValue</code> with specified properties
       *
       * @parma name name
       * @parma value value
       */
      public NamedVal(String name, String value) {
          
          this.name = name;
          this.value = value;
      }
      
      /** Getter for property name.
       * @return Value of property name.
       */
      public String getName() {
          return name;
      }
      
      /** Setter for property name.
       * @param name New value of property name.
       */
      public void setName(String name) {
          this.name = name;
      }
      
      /** Getter for property value.
       * @return Value of property value.
       */
      public String getValue() {
          return value;
      }
      
      /** Setter for property value.
       * @param value New value of property value.
       */
      public void setValue(String value) {
          this.value = value;
      }
      
  }
  
  
  
  1.1                  xml-xindice/java/src/org/apache/xindice/client/rpc/RPCException.java
  
  Index: RPCException.java
  ===================================================================
  /*
   * RPCException.java: contains RPCException class
   *
   * Created on 13 March 2002, 17:21
   */
  
  package org.apache.xindice.client.rpc;
  
  /**
   * Exception that can be thrown by the RPC methods in this package. It is used
   * exactly as other Java exceptions.
   *
   * @author James Bates <ja...@amplexor.com>
   * @version 1.0
   */
  public class RPCException extends Exception {
  
  }