juergen     02/02/28 01:46:17

  Modified:    src/share/org/apache/slide/common AbstractServiceBase.java
                        Namespace.java Service.java Uri.java
               src/share/org/apache/slide/store AbstractStore.java
  Log:
  Ekehard/Juergen: Added a new method (connect and connectIfNeeded) with the 
SlideToken as a parameter. For compatibility reasons the old methods are still 
available, and if the child store does not overwrite the new connect method, the old 
one is still called.
  
  Revision  Changes    Path
  1.5       +41 -5     
jakarta-slide/src/share/org/apache/slide/common/AbstractServiceBase.java
  
  Index: AbstractServiceBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractServiceBase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractServiceBase.java  26 Jul 2001 21:29:39 -0000      1.4
  +++ AbstractServiceBase.java  28 Feb 2002 09:46:17 -0000      1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractServiceBase.java,v 
1.4 2001/07/26 21:29:39 dirkv Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/07/26 21:29:39 $
  + * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/AbstractServiceBase.java,v 
1.5 2002/02/28 09:46:17 juergen Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/02/28 09:46:17 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,7 @@
    * Slide Service abstract implementation.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public abstract class AbstractServiceBase implements Service {
       
  @@ -80,7 +80,7 @@
       // -------------------------------------------------------------- Constants
       
       protected String LOG_CHANNEL = this.getClass().getName();
  -     
  +    
      
       // ----------------------------------------------------- Instance Variables
       
  @@ -147,6 +147,19 @@
       
       /**
        * Connects to the underlying data source (if any is needed).
  +     * Compatibility implementation for the previous store implementations
  +     *
  +     * @param token the slide token containing e.g. the credential
  +     * @exception ServiceConnectionFailedException Connection failed
  +     */
  +    public void connect(SlideToken token) throws ServiceConnectionFailedException {
  +        connect();
  +    }
  +    
  +    
  +    
  +    /**
  +     * Connects to the underlying data source (if any is needed).
        *
        * @exception ServiceConnectionFailedException Connection failed
        */
  @@ -193,6 +206,29 @@
        */
       public abstract boolean isConnected()
           throws ServiceAccessException;
  +    
  +    
  +    /**
  +     * Connects to the service, if we were not previously connected.
  +     *
  +     * @return boolean true if we were not already connected
  +     * @exception ServiceAccessException Unspecified service access error
  +     * @exception ServiceConnectionFailedException Connection failed
  +     */
  +    public boolean connectIfNeeded(SlideToken token)
  +        throws ServiceConnectionFailedException, ServiceAccessException {
  +        boolean result = true;
  +        try {
  +            result = !isConnected();
  +        } catch (ServiceAccessException e) {
  +            // Ignore : Will try to reconnect
  +        }
  +        if (result) {
  +            connect(token);
  +        }
  +        return result;
  +    }
  +    
       
       
       /**
  
  
  
  1.44      +10 -9     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.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- Namespace.java    8 Jan 2002 14:23:29 -0000       1.43
  +++ Namespace.java    28 Feb 2002 09:46:17 -0000      1.44
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v 1.43 
2002/01/08 14:23:29 juergen Exp $
  - * $Revision: 1.43 $
  - * $Date: 2002/01/08 14:23:29 $
  + * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v 1.44 
2002/02/28 09:46:17 juergen Exp $
  + * $Revision: 1.44 $
  + * $Date: 2002/02/28 09:46:17 $
    *
    * ====================================================================
    *
  @@ -125,7 +125,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
    * @author Dirk Verbeeck
  - * @version $Revision: 1.43 $
  + * @version $Revision: 1.44 $
    */
   public final class Namespace {
       
  @@ -507,14 +507,15 @@
        * Connects a data source on demand.
        *
        * @param service Service on which a connection attempt will be made
  +     * @param token the slide token containing e.g. the credential
        * @exception ServiceConnectionFailedException Error connecting service
        * @exception ServiceAccessException Unspecified low level service
        * access exception
        */
  -    public void connectService(Service service)
  +    public void connectService(Service service, SlideToken token)
           throws ServiceConnectionFailedException, ServiceAccessException {
           // Try to connect ...
  -        boolean newConnection = service.connectIfNeeded();
  +        boolean newConnection = service.connectIfNeeded(token);
           
           // If successfull (ie, no exception was thrown), we add it to the list
           // of the connected components.
  @@ -608,11 +609,11 @@
        * @exception ServiceConnectionFailedException Connection to Store failed
        * @exception ServiceAccessException Unspecified service access exception
        */
  -    public Store retrieveStore(Scope scope)
  +    public Store retrieveStore(Scope scope, SlideToken token)
           throws ServiceConnectionFailedException, ServiceAccessException {
           Store store = getStore(scope);
           if (store != null) {
  -            connectService(store);
  +            connectService(store, token);
           }
           return store;
       }
  @@ -668,8 +669,8 @@
           } else {
               result = (Uri) temp;
               result = result.cloneObject();
  -            result.reconnectServices();
               result.setToken(token);
  +            result.reconnectServices();
           }
           
           // if a different forceEnlistment value want to be used
  
  
  
  1.8       +28 -4     jakarta-slide/src/share/org/apache/slide/common/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Service.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Service.java      30 Mar 2001 11:18:02 -0000      1.7
  +++ Service.java      28 Feb 2002 09:46:17 -0000      1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/Service.java,v 1.7 
2001/03/30 11:18:02 juergen Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/03/30 11:18:02 $
  + * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/Service.java,v 1.8 
2002/02/28 09:46:17 juergen Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/02/28 09:46:17 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,7 @@
    * Slide Service interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public interface Service
       extends XAResource {
  @@ -121,6 +121,17 @@
        * Connects to the underlying data source (if any is needed).
        *
        * @exception ServiceConnectionFailedException Connection failed
  +     * @param token the slide token containing e.g. the credential
  +     */
  +    void connect(SlideToken token)
  +        throws ServiceConnectionFailedException;
  +    
  +    
  +    
  +    /**
  +     * Connects to the underlying data source (if any is needed).
  +     *
  +     * @exception ServiceConnectionFailedException Connection failed
        */
       void connect()
           throws ServiceConnectionFailedException;
  @@ -169,6 +180,19 @@
       /**
        * Connects to the service, if we were not previously connected.
        *
  +     * @param token the slide token containing e.g. the credential
  +     * @return boolean true if we were not already connected
  +     * @exception ServiceAccessException Unspecified service access error
  +     * @exception ServiceConnectionFailedException Connection failed
  +     */
  +    boolean connectIfNeeded(SlideToken token)
  +        throws ServiceConnectionFailedException, ServiceAccessException;
  +    
  +    
  +    /**
  +     * Connects to the service, if we were not previously connected.
  +     *
  +     * @deprecated
        * @return boolean true if we were not already connected
        * @exception ServiceAccessException Unspecified service access error
        * @exception ServiceConnectionFailedException Connection failed
  
  
  
  1.8       +50 -50    jakarta-slide/src/share/org/apache/slide/common/Uri.java
  
  Index: Uri.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Uri.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Uri.java  30 Aug 2001 17:26:29 -0000      1.7
  +++ Uri.java  28 Feb 2002 09:46:17 -0000      1.8
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Uri.java,v 
1.7 2001/08/30 17:26:29 remm Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/08/30 17:26:29 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Uri.java,v 
1.8 2002/02/28 09:46:17 juergen Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/02/28 09:46:17 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -15,7 +15,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -23,15 +23,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written 
  + *    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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   package org.apache.slide.common;
   
  @@ -70,11 +70,11 @@
   import org.apache.slide.store.*;
   
   /**
  - * This class manages the unique identifier of an object which is 
  + * This class manages the unique identifier of an object which is
    * manipulated by Slide.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public final class Uri implements Cloneable, java.io.Serializable {
       
  @@ -84,7 +84,7 @@
       
       /**
        * Constructor.
  -     * 
  +     *
        * @param namespace Namespace associated with this Uri
        * @param uri Uri
        */
  @@ -95,7 +95,7 @@
       
       /**
        * Constructor.
  -     * 
  +     *
        * @param token Slide token
        * @param namespace Namespace associated with this Uri
        * @param uri Uri
  @@ -167,7 +167,7 @@
       
       /**
        * Scope accessor.
  -     * 
  +     *
        * @return StringTokenizer
        */
       public Scope getScope() {
  @@ -178,8 +178,8 @@
       /**
        * Returns the scopes tokenized by the ScopeTokenizer associated
        * with this Uri object.
  -     * 
  -     * @return Enumeration 
  +     *
  +     * @return Enumeration
        */
       public Enumeration getScopes() {
           return this.scopes.elements();
  @@ -188,7 +188,7 @@
       
       /**
        * Store accessor.
  -     * 
  +     *
        * @return Store
        */
       public Store getStore() {
  @@ -198,8 +198,8 @@
       
       /**
        * Token accessor.
  -     * 
  -     * @return The SlideToken, or null if no token has been set 
  +     *
  +     * @return The SlideToken, or null if no token has been set
        * (which is valid)
        */
       public SlideToken getToken() {
  @@ -209,7 +209,7 @@
       
       /**
        * Token mutator.
  -     * 
  +     *
        * @param token New Slide token
        */
       public void setToken(SlideToken token) {
  @@ -222,7 +222,7 @@
       
       /**
        * Return the namespace to which this Uri belongs.
  -     * 
  +     *
        * @return Namespace
        */
       public Namespace getNamespace() {
  @@ -232,7 +232,7 @@
       
       /**
        * Get the parent uri.
  -     * 
  +     *
        * @return Uri
        */
       public Uri getParentUri() {
  @@ -244,7 +244,7 @@
       
       
       /**
  -     * Invalidate the current Services and PK. Used if there are changes in 
  +     * Invalidate the current Services and PK. Used if there are changes in
        * the namespace at runtime.
        */
       public void invalidateServices() {
  @@ -259,7 +259,7 @@
        */
       public void reconnectServices() {
           try {
  -            store.connectIfNeeded();
  +            store.connectIfNeeded(token);
           } catch (ServiceConnectionFailedException e) {
               parseUri(this.uri);
           } catch (ServiceAccessException e) {
  @@ -281,7 +281,7 @@
       
       /**
        * String representation of the uri object.
  -     * 
  +     *
        * @return String
        */
       public String toString() {
  @@ -291,17 +291,17 @@
       
       /**
        * Hash code.
  -     * 
  +     *
        * @return int hash code
        */
       public int hashCode() {
  -     return pk;
  +    return pk;
       }
       
       
       /**
        * Tests equivalence of two Uris.
  -     * 
  +     *
        * @param obj Object to test
        * @return boolean
        */
  @@ -330,7 +330,7 @@
       
       /**
        * Tests if the given uri represents a parent object.
  -     * 
  +     *
        * @param uri Uri to test
        * @return boolean
        */
  @@ -344,44 +344,44 @@
       
       /**
        * This function is called by the constructor and when uri is changed.
  -     * 
  +     *
        * @param uri Uri to parse
        */
       private void parseUri(String uri) {
  -     // We first try to tokenize the uri string.
  -     
  -     scopes = new ScopeTokenizer(namespace, uri);
  -     
  +    // We first try to tokenize the uri string.
  +    
  +    scopes = new ScopeTokenizer(namespace, uri);
  +    
           this.uri = scopes.getUri();
           
  -     // Find the qualifiying stuff from the registry.
  -     // Then we contentStore the scope of the found Data Source 
  +    // Find the qualifiying stuff from the registry.
  +    // Then we contentStore the scope of the found Data Source
           // within scope.
  -     store = null;
  -     while ((store == null) && (scopes.hasMoreElements())) {
  -         Scope courScope = scopes.nextScope();
  -         try {
  +    store = null;
  +    while ((store == null) && (scopes.hasMoreElements())) {
  +        Scope courScope = scopes.nextScope();
  +        try {
                   if (store == null) {
  -                 store = namespace.retrieveStore(courScope);
  +            store = namespace.retrieveStore(courScope, token);
                       if (store != null) {
                           scope = courScope;
  -                        // The PK in the current descriptorsStore is the 
  +                        // The PK in the current descriptorsStore is the
                           // portion of the URI relative
                           // to the Data Source.
                           this.pk = uri.substring(scope.toString().length())
                               .hashCode();
                       }
  -             }
  -         } catch (ServiceConnectionFailedException e) {
  -             // Problem ...
  +        }
  +        } catch (ServiceConnectionFailedException e) {
  +            // Problem ...
                   // FIXME : Throw a RuntimeException ??
  -         } catch (ServiceAccessException e) {
  -             // Problem ...
  +        } catch (ServiceAccessException e) {
  +            // Problem ...
                   // FIXME : Throw a RuntimeException ??
  -         }
  +        }
           }
           
  -        // If descriptorsStore or contentStore is still null, then no valid 
  +        // If descriptorsStore or contentStore is still null, then no valid
           // scope is defined in the namespace ...
           if (store == null) {
               throw new ServiceMissingOnRootNodeException();
  
  
  
  1.27      +20 -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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- AbstractStore.java        14 Feb 2002 18:07:27 -0000      1.26
  +++ AbstractStore.java        28 Feb 2002 09:46:17 -0000      1.27
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java,v 1.26 
2002/02/14 18:07:27 remm Exp $
  - * $Revision: 1.26 $
  - * $Date: 2002/02/14 18:07:27 $
  + * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java,v 1.27 
2002/02/28 09:46:17 juergen Exp $
  + * $Revision: 1.27 $
  + * $Date: 2002/02/28 09:46:17 $
    *
    * ====================================================================
    *
  @@ -89,7 +89,7 @@
    * Abstract implementation of a store. Handles all caching operations.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  - * @version $Revision: 1.26 $
  + * @version $Revision: 1.27 $
    */
   public abstract class AbstractStore extends AbstractSimpleService
       implements Store {
  @@ -222,6 +222,22 @@
           ServiceParameterMissingException {
           this.parameters = parameters;
       }
  +    
  +    
  +    /**
  +     * Connects to descriptors store.
  +     *
  +     * @exception DataException
  +     */
  +    public void connect(SlideToken token)
  +        throws ServiceConnectionFailedException {
  +        
  +        for (int i = 0; i < resourceManagers.length; i++) {
  +            resourceManagers[i].connect(token);
  +        }
  +        
  +    }
  +    
       
       
       /**
  
  
  

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

Reply via email to