ozeigermann    2004/05/04 05:06:27

  Modified:    src/share/org/apache/slide/store Store.java
                        AbstractStore.java
               src/share/org/apache/slide/common Namespace.java
  Added:       src/share/org/apache/slide/store SequenceStore.java
  Log:
  - Introduces a new store interfaces SequenceStore for sequences

  - Adds this interface to the Store interface

  - Adapts AbstractStore to implement the extended Store interface

  - Allows configuration of the SequenceStore in Domain.xml in Namespace class
  
  Revision  Changes    Path
  1.10      +9 -5      jakarta-slide/src/share/org/apache/slide/store/Store.java
  
  Index: Store.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/store/Store.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Store.java        11 Feb 2004 11:30:18 -0000      1.9
  +++ Store.java        4 May 2004 12:06:26 -0000       1.10
  @@ -32,7 +32,7 @@
    * @version $Revision$
    */
   public interface Store extends ContentStore, LockStore, NodeStore,
  -    RevisionDescriptorStore, RevisionDescriptorsStore, SecurityStore  {
  +    RevisionDescriptorStore, RevisionDescriptorsStore, SecurityStore, SequenceStore 
 {
       
       
       // ------------------------------------------------------ Interface Methods
  @@ -113,6 +113,10 @@
        */
       void setContentIndexer(IndexStore contentStore);
       
  +    /**
  +     * Sets the sequence store associated with this store.
  +     */
  +    void setSequenceStore(SequenceStore sequenceStore);
       
       /**
        * Returns true if binding is supported an enabled for this store
  
  
  
  1.40      +56 -4     
jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java
  
  Index: AbstractStore.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- AbstractStore.java        25 Feb 2004 10:04:29 -0000      1.39
  +++ AbstractStore.java        4 May 2004 12:06:26 -0000       1.40
  @@ -123,6 +123,11 @@
       protected IndexStore contentIndexer;
       
       /**
  +     * Sequence store
  +     */
  +    protected SequenceStore sequenceStore = null;
  +    
  +    /**
        * Active resource manager list.
        */
       protected Service resourceManagers[] = new Service[0];
  @@ -526,7 +531,54 @@
           return propertiesIndexer;
       }
       
  +    /**
  +     * Set the sequence store associated with this store.
  +     */
  +    public void setSequenceStore(SequenceStore store) {
  +        sequenceStore = store;
  +    }
           
  +    //
  +    // sequence methods 
  +    //
  +
  +    /**
  +     * @see org.apache.slide.store.SequenceStore#isSequenceSupported()
  +     */
  +    public boolean isSequenceSupported() {
  +        return (sequenceStore != null && sequenceStore.isSequenceSupported());
  +    }
  +
  +    /**
  +     * @see org.apache.slide.store.SequenceStore#sequenceExists(java.lang.String)
  +     */
  +    public boolean sequenceExists(String sequenceName) throws 
ServiceAccessException {
  +        if (!isSequenceSupported()) {
  +            throw new ServiceAccessException(this, "Sequences not supported");
  +        }
  +        return sequenceStore.sequenceExists(sequenceName);
  +    }
  +
  +    /**
  +     * @see org.apache.slide.store.SequenceStore#createSequence(java.lang.String)
  +     */
  +    public boolean createSequence(String sequenceName) throws 
ServiceAccessException {
  +        if (!isSequenceSupported()) {
  +            throw new ServiceAccessException(this, "Sequences not supported");
  +        }
  +        return sequenceStore.createSequence(sequenceName);
  +    }
  +
  +    /**
  +     * @see org.apache.slide.store.SequenceStore#nextSequenceValue(java.lang.String)
  +     */
  +    public long nextSequenceValue(String sequenceName) throws 
ServiceAccessException {
  +        if (!isSequenceSupported()) {
  +            throw new ServiceAccessException(this, "Sequences not supported");
  +        }
  +        return sequenceStore.nextSequenceValue(sequenceName);
  +    }
  +
       /**
        * Retrive an object from the Descriptors Store.
        *
  
  
  
  1.1                  
jakarta-slide/src/share/org/apache/slide/store/SequenceStore.java
  
  Index: SequenceStore.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/SequenceStore.java,v 1.1 
2004/05/04 12:06:26 ozeigermann Exp $
   * $Revision: 1.1 $
   * $Date: 2004/05/04 12:06:26 $
   *
   * ====================================================================
   *
   * Copyright 1999-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   *
   */
  
  package org.apache.slide.store;
  
  import org.apache.slide.common.Service;
  import org.apache.slide.common.ServiceAccessException;
  
  /**
   * Store for sequence support. A sequence is an entity that provides unique numbers.
   * A store supports sequences when it implements this interface and the method 
   * [EMAIL PROTECTED] isSupported} returns <code>true</code>.  
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Oliver Zeigermann</a>
   * @version $Revision: 1.1 $
   */
  public interface SequenceStore extends Service {
      
      /**
       * Checks if this store instance actually supports sequences. It may seem clear 
       * this store supports sequences as it implements this interface, but a request 
to the
       * underlying persistence store might be needed to dynamically find out.
       * 
       * @return <code>true</code> if the store supports sequences, <code>false</code> 
otherwise
       */
      public boolean isSequenceSupported();
      
      /**
       * Checks if the sequence already exists.
       * 
       * @param sequenceName the name of the sequence you want to check 
       * @return <code>true</code> if the sequence already exists, <code>false</code> 
otherwise
       * @throws ServiceAccessException if anything goes wrong while accessing the 
sequence 
       */
      public boolean sequenceExists(String sequenceName) throws ServiceAccessException;
      
      /**
       * Creates a sequence if it does not already exist.
       * 
       * @param sequenceName the name of the sequence you want to create 
       * @return <code>true</code> if the sequence has been created, 
<code>false</code> if it already existed
       * @throws ServiceAccessException if anything goes wrong while accessing the 
sequence 
       */
      public boolean createSequence(String sequenceName) throws ServiceAccessException;
      
      /**
       * Gets the next value of the sequence. Note that the sequence may not deliver 
consecutive 
       * or continuous values. The only thing that is assured is the value will be 
unique 
       * in the scope of the sequence, i.e. this method will never return the 
       * same value for the same sequence. A sequence of valid values <em>might</em> be
       * <pre>1,2,3,4,5...</pre>, but it might just as well be 
       * <pre>10,787875845,1,2,434</pre>.
       * However, it may not be 
       * <pre>1,2,1,3</pre>.
       * as a sequence must never return the same value twice or more times.
       * 
       * @param sequenceNamethe name of the sequence you want the next value for
       * @return the next value of the sequence
       * @throws ServiceAccessException if anything goes wrong while accessing the 
sequence 
       */
      public long nextSequenceValue(String sequenceName) throws ServiceAccessException;
  }
  
  
  
  1.62      +15 -5     jakarta-slide/src/share/org/apache/slide/common/Namespace.java
  
  Index: Namespace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- Namespace.java    27 Apr 2004 12:55:57 -0000      1.61
  +++ Namespace.java    4 May 2004 12:06:27 -0000       1.62
  @@ -40,6 +40,7 @@
   import org.apache.slide.store.RevisionDescriptorStore;
   import org.apache.slide.store.RevisionDescriptorsStore;
   import org.apache.slide.store.SecurityStore;
  +import org.apache.slide.store.SequenceStore;
   import org.apache.slide.store.Store;
   import org.apache.slide.structure.ObjectAlreadyExistsException;
   import org.apache.slide.structure.SubjectNode;
  @@ -103,7 +104,7 @@
       public static final String CONTENT_STORE = "contentstore";
       public static final String PROPERTIES_INDEX_STORE = "propertiesindexer";
       public static final String CONTENT_INDEX_STORE = "contentindexer";
  -    
  +    public static final String SEQUENCE_STORE = "sequencestore";
       
       
       /**
  @@ -416,6 +417,12 @@
                   
                   store.setContentIndexer (contentIndexer);
                   
  +                // assign SequenceStore
  +                SequenceStore sequenceStore =
  +                    (SequenceStore) dereferenceStore (SEQUENCE_STORE, childStores);
  +                
  +                store.setSequenceStore(sequenceStore);
  +                
                   // set the scope in the father and child stores
                   store.setScope(scope);
                   
  @@ -969,6 +976,9 @@
           
           // load default indexer, if no indexer defined
           
  +        // Loading sequence store (if any)
  +        getChildStore (storeDefinition, SEQUENCE_STORE, currentStoreChildStores, 
storeParameters);
  +
           childStores.put(storeName, currentStoreChildStores);
           
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to