kevinross    2003/07/17 07:28:02

  Modified:    java/src/org/apache/xindice/client/xmldb DatabaseImpl.java
  Log:
  fall through default on createDriver()
  
  Revision  Changes    Path
  1.15      +147 -147  
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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DatabaseImpl.java 10 Jul 2003 21:44:03 -0000      1.14
  +++ DatabaseImpl.java 17 Jul 2003 14:28:02 -0000      1.15
  @@ -58,7 +58,6 @@
    *
    * $Id$
    */
  -
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.xindice.client.xmldb.managed.ManagedDatabaseImpl;
  @@ -81,151 +80,152 @@
    */
   public class DatabaseImpl extends CommonConfigurable implements Database {
   
  -     private static Log log = 
LogFactory.getLog("org.apache.xindice.client.xmldb");
  +    private static Log log = 
LogFactory.getLog("org.apache.xindice.client.xmldb");
   
  -     protected Database driver;
  +    protected Database driver;
   
  -     /**
  -      * These are the URI prefixes this proxy impl understands.
  -      *
  -      * XML-RPC is the default.
  -      */
  -     public static String XMLRPC_URI = "xindice://";
  -     public static String EMBED_URI = "xindice-embed://";
  -     public static String MANAGED_URI = "xindice-managed://";
  -
  -     /**
  -      * Name used in the uri for collections associated with this instance.
  -      */
  -     public static String INSTANCE_NAME = "xindice, xindice-embed, 
xindice-managed";
  -
  -     /**
  -        * The XML:DB API Core Level Conformance of this implementation.
  -      */
  -     public static String CONFORMANCE_LEVEL = "0";
  -
  -     /**
  -      * Constructor for the DatabaseImpl object
  -      */
  -     public DatabaseImpl() {
  -             super();
  -     }
  -
  -     /**
  -      * Returns the prefix used in XML:DB to denote URI's that this driver 
can
  -      * handle.
  -      *
  -      * @return the prefix driver name
  -      * @exception XMLDBException with expected error codes.<br />
  -      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -      *  specific errors that occur.<br />
  -      */
  -     public String getName() throws XMLDBException {
  -             return INSTANCE_NAME;
  -     }
  -
  -     /**
  -      * Creates a Collection instance using the URI to locate the collection 
in
  -      * the Xindice instance. Applications should not call this method 
directly.
  -      * Instead they should call 
org.xmldb.api.base.DatabaseManager.getCollection().
  -      * <p />
  -      * The URI format accepted by this method:
  -      * xindice:/[Nameservice host]//[Database Instance Name in the CORBA 
Name Service]/[collection path]
  -      * <p />
  -      * Nameservice host is optional.
  -      *
  -      * This usually looks something like this:
  -      * xindice:///db/root/ocs. or
  -      * xindice://some.host.com:8309/db/root/ocs
  -      * <p />
  -      * When you pass the URI to DatabaseManager.getCollection(uri) you must
  -      * prepend an xmldb: to the beginning to make it a valid XML:DB URI.
  -      * So to normal users of the API URIs will look like this:
  -      * xmldb:xindice:///db/root/ocs. DatabaseManager will strip the
  -      * xmldb: before handing the URI to this getCollection implementation.
  -      * <p />
  -      * @param uri The URI specifing the location of the collection.
  -      * @return The Collection value
  -      * @exception XMLDBException
  -      */
  -     public org.xmldb.api.base.Collection getCollection(String uri, String 
username, String password) throws XMLDBException {
  -
  -             createDriver(uri);
  -
  -             return driver.getCollection(uri, username, password);
  -     }
  -
  -     /**
  -      * Returns the XML:DB API Conformance level for the implementation. 
This can
  -      * be used by client programs to determine what functionality is 
available to
  -      * them.
  -      *
  -      * @return the XML:DB API conformance level for this implementation.
  -      * @exception XMLDBException with expected error codes.<br />
  -      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -      *  specific errors that occur.<br />
  -      */
  -     public String getConformanceLevel() throws XMLDBException {
  -             return CONFORMANCE_LEVEL;
  -     }
  -
  -     /**
  -      * Determines whether this <code>Database</code> implementation  can 
handle
  -      * the URI. It should return true if the Database instance knows how to
  -      * handle the URI and false otherwise. <p />
  -      *
  -      * This method is called by org.xmldb.api.base.DatabaseManager.
  -      *
  -      * @param uri the URI to check for.
  -      * @return true if the URI can be handled, false otherwise.
  -      * @exception XMLDBException with expected error codes.<br />
  -      *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  -      *  specific errors that occur.<br />
  -      *  <code>ErrroCodes.INVALID_URI</code> If the URI is not in a valid 
format. <br />
  -      * @see #getCollection for a description of the URI's format
  -      */
  -     public boolean acceptsURI(String uri) throws XMLDBException {
  -             if (uri == null || uri.equals("")) {
  -                     return false;
  -             }
  -
  -             createDriver(uri);
  -             if (driver == null) {
  -                     return false;
  -             }
  -             else {
  -                     return driver.acceptsURI(uri);
  -             }
  -     }
  -
  -     protected void createDriver(String uri) throws XMLDBException {
  -             // Determine which driver was requested.
  -             try {
  -                     if (driver == null) {
  -                             if (uri.startsWith(XMLRPC_URI)) {
  -                                     /*
  -                                      * The only way that a particular 
instance of xmlrpc.DatabaseImpl
  -                                      * can be informed of the path to the 
XML-RPC service in the
  -                                      * web server is by setting a property 
on the DatabaseImpl object
  -                                      * which is in turn passed to the 
CollectionImpl object.  Whew!
  -                                      * Since the user never sees the actual 
xmlrpc.DatabaseImpl object,
  -                                      * this is the only way to make sure 
that they can set that property.
  -                                      */
  -                                     driver = new 
org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl(this);
  -                             }
  -                             else if (uri.startsWith(EMBED_URI)) {
  -                                     driver = new 
org.apache.xindice.client.xmldb.embed.DatabaseImpl();
  -                             }
  -                             else if (uri.startsWith(MANAGED_URI)) {
  -                                     driver = new ManagedDatabaseImpl();
  -                             }
  -                     }
  -             }
  -             catch (Exception e) {
  -                     if (log.isInfoEnabled()) {
  -                             log.info("Exception during creation of the 
Database", e);
  -                     }
  -                     throw new XMLDBException(ErrorCodes.INVALID_URI, uri, 
e);
  -             }
  -     }
  +    /**
  +     * These are the URI prefixes this proxy impl understands.
  +     *
  +     * XML-RPC is the default.
  +     */
  +    public static String XMLRPC_URI = "xindice://";
  +    public static String EMBED_URI = "xindice-embed://";
  +    public static String MANAGED_URI = "xindice-managed://";
  +
  +    /**
  +     * Name used in the uri for collections associated with this instance.
  +     */
  +    public static String INSTANCE_NAME = "xindice, xindice-embed, 
xindice-managed";
  +
  +    /**
  +       * The XML:DB API Core Level Conformance of this implementation.
  +     */
  +    public static String CONFORMANCE_LEVEL = "0";
  +
  +    /**
  +     * Constructor for the DatabaseImpl object
  +     */
  +    public DatabaseImpl() {
  +        super();
  +    }
  +
  +    /**
  +     * Returns the prefix used in XML:DB to denote URI's that this driver can
  +     * handle.
  +     *
  +     * @return the prefix driver name
  +     * @exception XMLDBException with expected error codes.<br />
  +     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +     *  specific errors that occur.<br />
  +     */
  +    public String getName() throws XMLDBException {
  +        return INSTANCE_NAME;
  +    }
  +
  +    /**
  +     * Creates a Collection instance using the URI to locate the collection 
in
  +     * the Xindice instance. Applications should not call this method 
directly.
  +     * Instead they should call 
org.xmldb.api.base.DatabaseManager.getCollection().
  +     * <p />
  +     * The URI format accepted by this method:
  +     * xindice:/[Nameservice host]//[Database Instance Name in the CORBA 
Name Service]/[collection path]
  +     * <p />
  +     * Nameservice host is optional.
  +     *
  +     * This usually looks something like this:
  +     * xindice:///db/root/ocs. or
  +     * xindice://some.host.com:8309/db/root/ocs
  +     * <p />
  +     * When you pass the URI to DatabaseManager.getCollection(uri) you must
  +     * prepend an xmldb: to the beginning to make it a valid XML:DB URI.
  +     * So to normal users of the API URIs will look like this:
  +     * xmldb:xindice:///db/root/ocs. DatabaseManager will strip the
  +     * xmldb: before handing the URI to this getCollection implementation.
  +     * <p />
  +     * @param uri The URI specifing the location of the collection.
  +     * @return The Collection value
  +     * @exception XMLDBException
  +     */
  +    public org.xmldb.api.base.Collection getCollection(String uri, String 
username, String password) throws XMLDBException {
  +
  +        createDriver(uri);
  +
  +        return driver.getCollection(uri, username, password);
  +    }
  +
  +    /**
  +     * Returns the XML:DB API Conformance level for the implementation. This 
can
  +     * be used by client programs to determine what functionality is 
available to
  +     * them.
  +     *
  +     * @return the XML:DB API conformance level for this implementation.
  +     * @exception XMLDBException with expected error codes.<br />
  +     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +     *  specific errors that occur.<br />
  +     */
  +    public String getConformanceLevel() throws XMLDBException {
  +        return CONFORMANCE_LEVEL;
  +    }
  +
  +    /**
  +     * Determines whether this <code>Database</code> implementation  can 
handle
  +     * the URI. It should return true if the Database instance knows how to
  +     * handle the URI and false otherwise. <p />
  +     *
  +     * This method is called by org.xmldb.api.base.DatabaseManager.
  +     *
  +     * @param uri the URI to check for.
  +     * @return true if the URI can be handled, false otherwise.
  +     * @exception XMLDBException with expected error codes.<br />
  +     *  <code>ErrorCodes.VENDOR_ERROR</code> for any vendor
  +     *  specific errors that occur.<br />
  +     *  <code>ErrroCodes.INVALID_URI</code> If the URI is not in a valid 
format. <br />
  +     * @see #getCollection for a description of the URI's format
  +     */
  +    public boolean acceptsURI(String uri) throws XMLDBException {
  +        if (uri == null || uri.equals("")) {
  +            return false;
  +        }
  +
  +        createDriver(uri);
  +        if (driver == null) {
  +            return false;
  +        }
  +        else {
  +            return driver.acceptsURI(uri);
  +        }
  +    }
  +
  +    protected void createDriver(String uri) throws XMLDBException {
  +        // Determine which driver was requested.
  +        try {
  +            if (driver == null) {
  +                if (uri.startsWith(XMLRPC_URI)) {
  +                    /*
  +                     * The only way that a particular instance of 
xmlrpc.DatabaseImpl
  +                     * can be informed of the path to the XML-RPC service in 
the
  +                     * web server is by setting a property on the 
DatabaseImpl object
  +                     * which is in turn passed to the CollectionImpl object. 
 Whew!
  +                     * Since the user never sees the actual 
xmlrpc.DatabaseImpl object,
  +                     * this is the only way to make sure that they can set 
that property.
  +                     */
  +                    driver = new 
org.apache.xindice.client.xmldb.xmlrpc.DatabaseImpl(this);
  +                }
  +                else if (uri.startsWith(EMBED_URI)) {
  +                    driver = new 
org.apache.xindice.client.xmldb.embed.DatabaseImpl();
  +                }
  +                else if (uri.startsWith(MANAGED_URI)) {
  +                    driver = new ManagedDatabaseImpl();
  +                }
  +                else {
  +                    throw new XMLDBException(ErrorCodes.INVALID_URI, uri);
  +                }
  +            }
  +        }
  +        catch (Exception e) {
  +            log.info("Exception during creation of the Database", e);
  +            throw new XMLDBException(ErrorCodes.INVALID_URI, uri, e);
  +        }
  +    }
   }
  
  
  

Reply via email to