kstaken     2002/07/11 01:38:18

  Modified:    docs     AUTHORS
               java/src/org/apache/xindice/client/xmldb DatabaseImpl.java
  Added:       java/src/org/apache/xindice/util SymbolDeserializer.java
                        SymbolSerializer.java
  Log:
  Adding new authors.
  
  Revision  Changes    Path
  1.7       +1 -0      xml-xindice/docs/AUTHORS
  
  Index: AUTHORS
  ===================================================================
  RCS file: /home/cvs/xml-xindice/docs/AUTHORS,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AUTHORS   2 Jul 2002 08:04:17 -0000       1.6
  +++ AUTHORS   11 Jul 2002 08:38:17 -0000      1.7
  @@ -29,3 +29,4 @@
      James Bates             [EMAIL PROTECTED]
      Kurt Ward          [EMAIL PROTECTED]
      Vanessa Williams   [EMAIL PROTECTED]
  +   Jeff Suttor             [EMAIL PROTECTED]
  
  
  
  1.3       +3 -3      
xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java
  
  Index: DatabaseImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/DatabaseImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DatabaseImpl.java 11 Jul 2002 03:17:07 -0000      1.2
  +++ DatabaseImpl.java 11 Jul 2002 08:38:18 -0000      1.3
  @@ -99,7 +99,7 @@
      /**
         * Name used in the uri for collections associated with this instance.
       */
  -   public static String INSTANCE_NAME = "xindice";
  +   public static String INSTANCE_NAME = "xindice-rpc";
      
      /**
         * The XML:DB API Core Level Conformance of this implementation.
  @@ -188,7 +188,7 @@
                  driver = (Database) 
Class.forName("org.apache.xindice.client.xmldb.corba.DatabaseImpl").newInstance();
               }
               else if (uri.startsWith(XMLRPC_URI)) {
  -               driver = (Database) 
Class.forName("org.apache.xindice.client.rpc.base.DatabaseImpl").newInstance();
  +               driver = (Database) 
Class.forName("org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl").newInstance();
               }
               else if (uri.startsWith(EMBED_URI)) {
   
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/util/SymbolDeserializer.java
  
  Index: SymbolDeserializer.java
  ===================================================================
  package org.apache.xindice.util;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: SymbolDeserializer.java,v 1.1 2002/07/11 08:38:18 kstaken Exp $
   */
  
  import org.apache.xindice.xml.*;
  import org.apache.xindice.xml.dom.*;
  
  import org.w3c.dom.*;
  
  import java.util.*;
  
  /**
   * SymbolDeserializer is a utility class for managing SymbolTables in
   * the client context of Wire Compression.
   */
  
  public final class SymbolDeserializer {
     private static final byte[] EmptyBytes = new byte[0];
     private static final SymbolTableSymbols hcSyms = 
SymbolTableSymbols.getInstance();
     private static final Document elemFactory = new DocumentImpl();
     
     private SymbolTable syms = null; // The Collection's SymbolTable
     private long lastMod = 0;        // Last time we caught a SymbolTable 
modification
     
     public SymbolDeserializer() {
     }
  
     /**
      * convertToDocument converts the compressed Hashtable to
      * a DOM Document.
      *
      * @param buffer The Hashtable
      * @return The Document
      */
     public Document convertToDocument(Hashtable buffer) {
        SymbolTable s = getSymbols(buffer);
        return new DocumentImpl((byte []) buffer.get("document"), s, null);
     }
     
     /**
      * getSymbols returns the current SymbolTable image for the
      * server-side Collection that is being managed.  The Symbol
      * table is shipped as part of an Hashtable when the server
      * has determined that its image of the SymbolTable is out of
      * date.  This method either returns the current image or
      * extracts the new image from the Hashtable.
      *
      * @param buffer The Hashtable
      * @return The Symbol Table
      */
     public SymbolTable getSymbols(Hashtable buffer) {
        //if ( ((Long) buffer.get("timestamp")).longValue() != lastMod ) {
          // lastMod = ((Long) buffer.get("timestamp")).longValue();
  
           Document doc = new DocumentImpl((byte []) buffer.get("symbols"), 
hcSyms, null);
  
           if ( syms == null ) {
              syms = new SymbolTable();
           }
              
           synchronized(syms) {
              syms.streamFromXML(doc.getDocumentElement());
           }
       // }
        return syms;
     }
     
     /**
      * getLastModified returns the last modified time stamp of the
      * client's image of the managed Symbol Table.
      *
      * @return The last modified stamp
      */
     public long getLastModified() {
        return lastMod;
     }
  }
  
  
  
  
  1.1                  
xml-xindice/java/src/org/apache/xindice/util/SymbolSerializer.java
  
  Index: SymbolSerializer.java
  ===================================================================
  package org.apache.xindice.util;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xindice" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999-2001, The dbXML
   * Group, L.L.C., http://www.dbxmlgroup.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: SymbolSerializer.java,v 1.1 2002/07/11 08:38:18 kstaken Exp $
   */
  
  import org.apache.xindice.xml.*;
  import org.apache.xindice.xml.dom.*;
  
  import org.w3c.dom.*;
  
  import java.util.*;
  
  /**
   * SymbolSerializer is a utility class for managing SymbolTables in
   * the server context of Wire Compression.
   */
  
  public final class SymbolSerializer {
     private static final byte[] EmptyBytes = new byte[0];
     private static final SymbolTableSymbols hcSyms = 
SymbolTableSymbols.getInstance();
     private static final DocumentImpl elemFactory = new DocumentImpl();
     
     private SymbolTable syms = null; // The Collection's SymbolTable
     private long lastMod = 0;        // Last time we caught a SymbolTable 
modification
     private byte[] symBytes = null;  // Stores a byte representation of the 
SymbolTable
     
     public SymbolSerializer(SymbolTable syms) {
        this.syms = syms;
        elemFactory.setSymbols(syms);
     }
  
     /**
      * getSymBuffer returns a new Hashtable that includes a
      * reference to the SymbolTable's byte array image for wire
      * transmission.  Depending on whether the client is up to
      * date, convertFromDocument will remove this reference.
      *
      * @return A new Hashtable
      */
     public Hashtable getSymBuffer() {
        long lm = syms.getLastModified();
        if ( lm > lastMod ) {
           synchronized ( syms ) {
              Element elem = syms.streamToXML(elemFactory);
              try {
                 symBytes = DOMCompressor.Compress(elem, hcSyms);
                 lastMod = lm;
              }
              catch ( Exception e ) {
                 org.apache.xindice.Debug.println("Problem compressing Symbol 
Table!  Very Bad!");
              }
           }
        }
        
        Hashtable result = new Hashtable();
        //result.put("timestamp", new Long(lm));
        result.put("symbols", symBytes);
        result.put("document", new byte[0]);
        return result;
     }
     
     /**
      * convertFromDocument converts a DOM Document into an
      * Hashtable that, depending on the time stamp, possibly
      * includes a current image of the managed Collection's Symbol
      * Table.
      *
      * @param doc The Document to Convert
      * @param stamp The client's last modified stamp
      * @return The Hashtable
      */
     public Hashtable convertFromDocument(Document doc, long stamp) {
        Hashtable result = getSymBuffer();
        byte[] docBytes = ((CompressedDocument)doc).getDataBytes();
        result.put("document", docBytes);
  
        /*if ( ((Long) result.get("timestamp")).longValue() == stamp ) {
           result.put("symbols", EmptyBytes);
        }*/
           
        return result;
     }
     
     /**
      * getSymbols returns the Symbol Table being managed by this
      * Serializer.
      *
      * @return The Symbol Table
      */
     public SymbolTable getSymbols() {
        return syms;
     }
     
     /**
      * getLastModified returns a time stamp of the last server-side
      * modified of the Symbol Table.  This is used to determine
      * whether or not to regenerate the byte stream, and whether
      * the client will need a new copy of the Symbol Table.
      *
      * @return Last modified stamp
      */
     public long getLastModified() {
        return lastMod;
     }
  }
  
  
  
  

Reply via email to